• 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 can i map different Actionform class to single Action class

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
In my project i have one jsp page with 5 buttons and each button has different functionality based on button click i want to call respective Action form and in my action class (only one) i want to check which button is clicked.
please tell me do we have any tag in struts for pagination.
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now, i have 2 solution to do that :

1. form per button.
2. using javascript with each action of button.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by bhumika mehta:
Hi ,
In my project i have one jsp page with 5 buttons and each button has different functionality based on button click i want to call respective Action form and in my action class (only one) i want to check which button is clicked.
please tell me do we have any tag in struts for pagination.



hi bhumika ,
In most cases there are several benefits to a single ActionForm (manageability, relationship preservation, etc...). It sounds like you just want to perform a defined operation in your Action class based on which button is selected, if this is the case check out the DispatchAction or DispatchLookup Action if you don't want to use JavaScript buttons. Let me know if you need more info.
 
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 do what you require easily.
Buttons get submitted with the rest of the form's data.

For example clicking one of these buttons:
<html:submit property="button" value="Save"/>
<html:submit property="button" value="Edit"/>
will submit a "button" parameter with the request.

I like to put accessor methods getButton/setButton in my ActionForm and then run a comparison in the Action like:
if("Save".equals(myForm.getButton())){
...
}else if("Edit".equals(myForm.getButton()){
...

If you use this method, set up constants for the "Save" and "Edit" values:
<html:submit property="button" value="<%= MyConstants.SAVE %>"/>
<html:submit property="button" value="<%= MyConstants.EDIT %>"/>
if(MyConstants.SAVE.equals(myForm.getButton())){
...
}else if(MyConstants.EDIT.equals(myForm.getButton()){
...

Don't blindly jump into this as your solution. At least check out DispatchAction as a possible solution. I don't recommend placing multiple forms on your page or using javascript to solve it.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic