File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Problem with Struts2 validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem with Struts2 validation" Watch "Problem with Struts2 validation" New topic

Problem with Struts2 validation

kooper Sivan

Joined: Jul 01, 2011
Posts: 16
I am facing an issue with Struts 2 validation.
I am using the same page for multiple users, there by the fields become hidden for different users, but i use the same action class and have a common validation.xml file,
the issue now is that since all the fields are made mandatory in the xml file, even if the fields are not visible at the front end, the submission doesn't happen.
i tried removing the piece of validation for the property not visible in that page for that user and it went through fine.

Requesting your help.

Nitin Surana
Ranch Hand

Joined: Jan 21, 2011
Posts: 129

for all those fields which are not required, simply add a <s:hidden with their name and some garbage value> so that it'll pass required validation.
kooper Sivan

Joined: Jul 01, 2011
Posts: 16
Thanks Nitin..
Will try out the same
I agree. Here's the link:
subject: Problem with Struts2 validation
jQuery in Action, 3rd edition