I've been thinking about this topic myuself lately.
Alot of the projects I work on use images as buttons as opposed to the traditional submit buttons. In the past I've done some JavaScript gymnastics to achieve my desired results, but I think I want to move towards using <html:img> along with ActionForms containing
ImageButtonBean properties for the buttons.
You'll notice if you follow the link that Ted Husted demonstrates this by providing a getSelected() method in the ActionForm to determine which button was pressed. Well, this would still necessitate the whole if-else thing which isn't what we erally want.
What I've been thinking, and I need to go back and take a look at the source for DispatchAction to make sure I'm thinking along the proper lines, is to write a FormDispatchAction. If I remember correctly, dispatch action checks the request for the specified parameter value and dispatches accordingly. Again, I'm thinking aloud and haven't done all the necessary investigation to determine if this is all necessary, but I believe using <html:img> to submit, and without any javascript, does not leave a decent value in the request to dispatch off of. So this FormDispatchAction I'm thinking of would instead dispatch off of the value of a specified ActionForm property. This would allow you to write an ActionForm using ImageButtonBeans and a getSelected() method as shown by Ted Husted in the link I gave above.
This would probably also work for any other set of buttons with different names. Let's say we have the following jsp:
And given this ActionForm:
Then we would have our hypothetical implementation of FormDispatchAction dispatch on the "submitted" parameter.
And finally our implementation of FormDispatchAction:
Well, that's a sketch of what I've got rolling around in my head anyway. It seems something like this might be useful.
[ January 29, 2005: Message edited by: Jason Menard ]