Title: RE: [Juglist] Struts question

I do agree with you in the case of 3 buttons, each going to different methods and all in the same html:form on the JSP, then LookupDispatchAction is better choice.

-----Original Message-----
From: Erik Hatcher [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 04, 2003 2:23 PM
To: Research Triangle Java User's Group mailing list.
Subject: Re: [Juglist] Struts question


On Thursday, September 4, 2003, at 01:36  PM, Kilmer, Erich wrote:
> Have your Action class be of type DispatchAction. Instead of execute
> methods in your action have methods for each button, for example
> save(), delete() and cancel().
> Then in your JSP where the buttons are do something like:
> �
> �������� <html:submit property="method" title="Save thing.">
> ����������� <bean:message key="button.save"/>
> �������� </html:submit>

So you're saying that your form bean has a property called method?  Why
have it there too?  It's never used from there, right?

> And in your ApplicationResources.properties you must define
> button.save:
> button.save=Save
> �
> So when you do all of this and press the Save button you get a HTTP
> request param "method=Save" come through.
> �
> Then in Struts the DispatchAction sends it to your action and calls
> the save method.

Again I cringe at this.  Now the word "Save" is hardcoded into your
Java code and if the label changes so much your method name if you're
using DispatchAction.  Again, LookupDispatchAction was designed for
this very scenario - multiple submit buttons submitting the same form.

I recommend against using DispatchAction for this purpose, but it'll
certainly work (but beware the risks).

Or, you could switch to Tapestry and have an event listener for every
button tied directly to a method!  :)

        Erik


_______________________________________________
Juglist mailing list
[EMAIL PROTECTED]
http://trijug.org/mailman/listinfo/juglist_trijug.org

_______________________________________________
Juglist mailing list
[EMAIL PROTECTED]
http://trijug.org/mailman/listinfo/juglist_trijug.org

Reply via email to