• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

form validation in struts2

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

Can someone please reply on this ???

Regards,
Nitesh
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 182
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Tick check! Okay, I guess that was just an itch. Oh wait! Just a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic