Yet another approach would be to use an image tag:

<html:image  page="/images/lock.gif" property="lock" />
<html:image  page="/images/unlock.gif" property="unlock" />
<html:image  page="/images/delete.gif" property="delete" />

and check parameter in action:

        if (request.getParameter("lock.x") != null) {
     // decide what to do
     // 1) either return mapping.findForward("lock");
     //     with <forward name="lock"   path="/lock.do"/> declared in struts-config
     // (this results in performace drawback, but makes design more flexible)
     // 2)  just simply call an appropriate method
        }
        else if (request.getParameter("unlock.x") != null){
     // decide what to do
        }
        else if (request.getParameter("delete.x") != null) {
     // decide what to do
        }

Of cource it could be optimized with map and base dispatcher class.

Dmitri Valdin



Datum:         15.11.2001 11:41
An:            Struts Developers List <[EMAIL PROTECTED]>




Antwort an:    "Struts Developers List" <[EMAIL PROTECTED]>

Betreff:       Re: [SUBMIT] LookupDispatchAction - how to handle multiple html:submit  
buttons
Nachrichtentext:

Most of us would not rely *solely* on Javascript for validation, since
it can be turned off, and therefor endanger your application. But
requiring it to handle multiple buttons is a different matter, so long
as the default formAction did nothing harmful if Javascript were turned
off.

The ValidatorForm in the contrib folder generates *lots* of Javascript.
The html:form tag also generates a Javascript to move the focus, as do
some others. So, I don't see anything wrong with a tag that generated
Javascript for setting a property. Heck, I'm doing by hand myself ;-)

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/


Joe Faith wrote:
>
> We have also implemented a multiple submit button system; but in our
> case we wrote a custom tag that generates javascript that sets a property
> to a specified value and submits the form when you hit the button.
>
> The tags look something like:
>
>     <my_submit property="formAction" value="delete" label="Delete this
> record"/>
>     <my_submit property="formAction" value="save" label="Save changes"/>
>     <my_submit property="formAction" value="copy" label="Copy this record"/>
>
> etc
>
> A single action object can then use the value of formAction to decide what to
> do in each case.
> This has the side-effect of reducing the number of Action classes needed.
>
> However, the tags generate javascript and I wasn't sure if this fitted the
> struts philosophy; so I
> haven't submitted the code changes. But if anyone was interested I could make
> it available.
>
> Joe Faith
>
> Runtime Collective, Ltd
> T: (+44) 01273 234294

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>






--

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn 
Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, 
informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das 
unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information. If you are not the 
intended recipient (or have received this e-mail in error) please notify the sender 
immediately and destroy this e-mail. Any unauthorized copying, disclosure or 
distribution of the material in this e-mail is strictly forbidden.



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to