What LookupDispatchAction will allow u to do is the following: 

* Have 1 Action class, with multiple executable methods in there (instead of the one 
usual "execute" method)
* Have 2 buttons in your jsp with different labels (but the same name!!!), * Depending 
on which button is clicked, one of the methods that u coded in your action class will 
be fired off

The glue is that the labels in the 2 buttons must match the keys in the 
ApplicationResources, and the button labels must map to the Action class methods via 
the getKeyMethodMap  method in your action class...

See below for some code.


/*I inherit from BaseUpdateAction */

public abstract class BaseUpdateAction extends LookupDispatchAction
{
protected Map getKeyMethodMap   () 
        {
        //this method redirects control to one of a number of methods (delete, insert, 
update)
                
        Map map = new HashMap();
        //Note: the keys must match the keys in the properties file and the labels in 
the JSP buttons
        //and the values must match methods in this class
//the methods themselves also need to math the "execute" method signature (other than 
for the name portion!)
        map.put("insert.label", "insert");
        map.put("update.label", "update");
        map.put("delete.label", "delete");
        return map;
        }

        public ActionForward insert (ActionMapping mapping, ActionForm from, 
HttpServletRequest request, HttpServletResponse response) throws Exception

        {
}

/* etc */
}

My resources file contains the following: 

insert.label=Insert
update.label=Update
delete.label=Delete

I went though all of this hassle yesterday!

Colm

-----Original Message-----
From:   Todor Sergueev Petkov [mailto:[EMAIL PROTECTED] 
Sent:   07 August 2003 12:59
To:     Struts Users Mailing List
Subject:        Button labels and DispatchActions mix?

Hello people,

I have the following code :

<html:submit property="action" value="resetg" >
<bean:message key="search.button.reset" />
</html:submit>
What I am trying to do is have a Dispatch Action so that when this button is pressed 
the request is something like search.do?action=resetg But I don't want my button to 
have the resetg title on it. I want it to have the search.button.reset title from 
ApplicationResources bundle on it. It seems tha Struts html tag library mixes the two. 
Is there a way out of this?

Thanks....




**********************************************************************
This message is sent in confidence for the addressee
only.  The contents are not allowed to be disclosed to
anyone other than the addressee.  Unauthorised 
recipients must preserve this confidentiality and should 
please advise the sender immediately of any error in
transmission.
**********************************************************************


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

Reply via email to