aspose file tools*
The moose likes Struts and the fly likes validation particular fields for different  actions in a single page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validation particular fields for different  actions in a single page" Watch "validation particular fields for different  actions in a single page" New topic
Author

validation particular fields for different actions in a single page

Swathi Prakash
Ranch Hand

Joined: Jan 18, 2005
Posts: 49
hi all,

pls help me...

i have page with 5 fields...and two buttons... for the first button i need only 2 fields required . for second button i need all fields required...how to do in struts???for these 2 buttons i m calling the same action..



from the first button action i will get the value of third field value.. then i want to submit the second button where i required all fields...

how to use validation of struts for these conditions... i m using only one form for this page...please help me.....


SWATHI
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
Im not sure how to do this within struts, but you can use different javascript validation functions for each button.


SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

You can check which button was click from within your ActionForm's validate method.


A good workman is known by his tools.
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
if you are using declarative validation, name both buttons the same 'name' (ex. 'submitButton'), but specify different values for each (ex. 'Update', 'Add'). in your validation.xml, use the 'validwhen' rule to check the 'submitAction' value together with the required fields if you are using struts 1.2.x (see the struts user guide). use 'requiredif' to do the same if you are using struts 1.1.x. follow marc's suggestion if you are using struts 1.0.x.


-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Originally posted by alan do:
follow marc's suggestion if you are using struts 1.0.x.


... or if you aren't using declarative validation in any version of Struts.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: validation particular fields for different actions in a single page