File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes form validation in struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "form validation in struts2" Watch "form validation in struts2" New topic
Author

form validation in struts2

Nitesh Patel
Ranch Hand

Joined: Mar 16, 2008
Posts: 33
Hi All,

I need to validate the form which I have developed in Struts2. I need to validate it using Struts2. I am able to do simple validation using XML where my field name is something like

But when we have field as below,

Here user is our model object having different properties.

Can anybody please help me ?

Nitesh Patel
Ranch Hand

Joined: Mar 16, 2008
Posts: 33
Hi All,

Can someone please reply on this ???

Regards,
Nitesh
suraj savaratkar
Ranch Hand

Joined: May 17, 2010
Posts: 60
You could use like this.
mention here 1.0.2 dtd.
<validators>
<field name="firstName">
<field-validator type="requiredstring">
<message>Please enter the name</message>
</field-validator>
</field>
</validators>
Nitesh Patel
Ranch Hand

Joined: Mar 16, 2008
Posts: 33
Hi Suraj,

Thanks for reply, but it is not working like that. We have user (object)as one property into our action and we don't want many fields.

Regards,
Nitesh
Nitesh Patel
Ranch Hand

Joined: Mar 16, 2008
Posts: 33
Hi All,

I found the reason why our code doesn't work. When we use theme, into form, it doesn't display error messages if any. But when we don't use theme attribute into then it validate it and display error messages. We don't want to use default theme as it shows fields into thier table format. Is there any way to use validation with .

Regards,
Nitesh
Anbarasu Aladiyan
Ranch Hand

Joined: Jun 02, 2009
Posts: 182

You can use css_xhtml theme. Or can use <s:fielderror fieldName="name_of_the_field"></s:fielderror> or <s:actionerror /> tags.


A.A.Anbarasu
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: form validation in struts2
 
Similar Threads
Struts2 TextField
Need Some Help Regarding the Validation -- Struts2
Validation framework issue in struts2
Struts2 iterator
struts2 validate a checkbox