This is a great approach as well and I think we've giving good answers. 1 way you change the Form, and another way you change the Action.
I didn't know you could do it the way you described, thanks for the tip!
Rick Reumann wrote:
Riyad Kalla wrote:
1) Yes you can do it
2) Given each button a different value, like "List Products" and "List All Products"
3) Add a "buttonValue" (or some other adequetly names) property to your form for the respective action, it will capture the button clicked.
4) In your action:
if(form.getButtonValue().equals("List Products")) // do stuff else if(form.getButtonValue().equals("List All Products")) // do more stuff
You can do it much easier using either of the approachs below:
1) Use the LookUpDispatch Action. You simply give the submit button your dispatch property name (ie property="UserAction" ) then the value of the button gets looked up from a map in your LookUpDispatchAction (see the docs). Much cleaner.. although..
2) I still prefer to set a hidden variable of a dispatch Action with javascript when a button is clicked. Then simply use a regular DispatchAction or someone mentioned even a MapplingDispatchAction which I wasn't aware of (maybe this later is in Struts 1.2?). Assuming a regular dispatch action you have buttons like..
<html:submit onclick="document.yourForm.userAction.value='Update'">Update</html:submit>
<html:submit onclick="document.yourForm.userAction.value='Cancel'">Cancel</html:submit>
<html:hidden property="userAction"/>
Then just make sure you are using a DispatchAction. (In the above it's better if you use the resources properties file for you button names: <bean:message key="button.update"/> Just in case later the button names change, it's easier to modify one resources file.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]