how can i map different Actionform class to single Action class

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.

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.

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.

A good workman is known by his tools.

subject: how can i map different Actionform class to single Action class