File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

form validation in struts2

 
Nitesh Patel
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Can someone please reply on this ???

Regards,
Nitesh
 
suraj savaratkar
Ranch Hand
Posts: 96
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 182
Chrome Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use css_xhtml theme. Or can use <s:fielderror fieldName="name_of_the_field"></s:fielderror> or <s:actionerror /> tags.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic