jQuery in Action, 2nd edition*
The moose likes Struts and the fly likes How to use only Server Side Validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to use only Server Side Validation" Watch "How to use only Server Side Validation" New topic
Author

How to use only Server Side Validation

Tarun Chatterjee
Greenhorn

Joined: Mar 07, 2005
Posts: 25
I would want to use only Server Side validation using Struts. How do i go about it.
Do i have to configure the Validation.xml,validation-rules.xml in this case?

Can i get a step wise idea of how to go about it?

Thanks

Tarun
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you do not code your JSP to plug into the client-side validation, no client-side validation will take place. The steps required to plug a JSP into client-side validation are:

* put onsubmit="return validateMyForm(this)" into the <html:form> tag, where MyForm is the ActionForm name used by this page.
* put <html:javascript form="myForm" /> somewhere in the page.

So, if you don't do this in your JSPs, only server side validation will be performed.


Merrill
Consultant, Sima Solutions
Cheenath Ajay
Ranch Hand

Joined: Jan 26, 2006
Posts: 32
Confusing,,

<action
path="/SomeAction"
type="com.a.SomeAction"
name="SomeForm"
scope="request"
validate="true"
input="/pages/input.jsp">
<forward name="success" path="/pages/success.jsp"/>
</action>

This is the way how we use a client side validation in struts.

If validate="false", struts wont do your client side validation.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The point I'm making is that even if you specify validate="true" in your action mapping, client-side validation will still not take place unless you've modified your JSP to allow for it. If you never want to use client-side validation, you don't have to do anything... just don't put the code in your JSPs.
Liju Cherian
Ranch Hand

Joined: Mar 17, 2006
Posts: 44
Hi,

For performing server side validation, you could configure the validation.xml file or u could validate in your action class itself, based on ur own custom defined rules.
For configuring the validation.xml file you can check this link out.

Hope this helps.

Liju


"What's in a name? That which we call a rose by any other name would smell just as sweet."<br />(William Shakespeare, Romeo and Juliet, Act II, Scene II)
Cheenath Ajay
Ranch Hand

Joined: Jan 26, 2006
Posts: 32
Hi Liju,

That was a really nice to know that you became an expert in Struts.

Good to know that still Java innovations are going on in Assyt.

Enjoy.

Ajay Francis.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to use only Server Side Validation
 
Similar Threads
Have a question about turn off javascript
client side validation
client side validation (message deleted I think)
JSF Validation
Custom Server Side Validation