• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to dynamically set the value of "input" in Dispatch Action for Struts Validation

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi to all

Does anyone have experience on performing Struts Validation which covers multiple methods by using DispatchAction? How do you specified the input value for each method in the dispatch action?

For example, I have a action called UserProfileAdmin, which contains 3 methods, edit user, create user, delete user. For each method it is supposed to have different value set in the attribute "input" because validation need it.

But when you use DispatchAction and defined all 3 methods in one action mapping in struts-config.xml, it allowes us to have only one "input" attribute in this action mapping definition.

In that case, no matter the validation fails in either "edit user", "create user" or "edit user", it could only forwared to a single target, which is bad...

Please help me if you know how to resolve this, thanks a lot!
 
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
Set it to validate="false".
You can manually call the validate method from DispatchAction's methods.
It will look something like this:

errors.add(form.validate());
if(!errors.isEmpty()){
saveErrors(request, mapping);
return mapping.findForward("updateFailure");
}
 
Greenhorn
Posts: 25
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even though this post is already dead being too old. But still I wanna put more appropriate answer for it.

for your 3 methods editUser(----), createUser(----) and deleteUser(----) configure your DispatchAction class 3 times in struts-config.xml with same type="" value and if you are also using single common ActionForm(form bean) class take same values for name="" in all 3 configurations. just change the input="" values according to your need.(But put 3 different action="" values in each config.)
And in validation.xml file tale <form name="action value used by particular form page to transfer control to DipatchAction class">.....
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic