• 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

validation particular fields for different actions in a single page

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im not sure how to do this within struts, but you can use different javascript validation functions for each button.
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can check which button was click from within your ActionForm's validate method.
 
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Poop goes in a willow feeder. Wipe with this 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