This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes How to Bypass struts validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to Bypass struts validation" Watch "How to Bypass struts validation" New topic
Author

How to Bypass struts validation

Dhaval P Patel
Greenhorn

Joined: Oct 05, 2006
Posts: 2
Hi,

In my JSP page I have 5 fields.
I have registry struts validation for these all five fields.
now in some case I am not going to hide two files among these five fields.
So at that time I want to bypass struts validation that hidden fields.

Please let me know I can I bypass struts validation only for two fields.

Thanks
Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456
hello,

process both cases with different actionmappings, and declare different validation rules for those...

hope it helps,
jan
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
One possible solution would be to create a new field on the form to indicate whether the field is displayed or not. For example, if you currently have a field named field1, add another boolean property named field1Displayed. Make it a hidden field on the JSP, and set it to true if the field is displayed and false if the field is not displayed. Then use the validWhen validation rule like this:



Note: This will work only to do a "required" check. If you need to check the data type of field1, or do anything more complicated than that, you will have to create your own custom validation rule in order to accomplish this.


Merrill
Consultant, Sima Solutions
 
 
subject: How to Bypass struts validation
 
Similar Threads
Cancel button and bypassing JavaScript validation
Stopping the struts validation for a particular non-displayed fields
Populating second list based on selection of first list
Bypass client-side struts validation
problem using validator framework with DispatchAction