DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12297>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12297

Simplified DispatchAction

           Summary: Simplified DispatchAction
           Product: Struts
           Version: 1.1 Beta 2
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Controller
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The DispatchAction is great when you need more than one Submit-Button in a Form.
But the disadvantage is, that the name of the called Action method must be the 
same what the User sees as Text on the Submit-Button. Internationalization of 
Button-Texts is not usable and the Web-Designer is not as flexible as you need.

The Struts-Solution is the more complicated LookupDispatchAction. But here you 
have to implement a Method called "getKeyMethodMap". 

I propose to alter the execute-Method of the DispatchAction class:
--------------------------------------------------------------------------
public ActionForward execute(ActionMapping mapping,
                             ActionForm form,
                             HttpServletRequest request,
                             HttpServletResponse response)
  throws Exception {

  // Identify the method name to be dispatched to
  String name = null;

  Enumeration enum = request.getParameterNames();
  while (enum.hasMoreElements()) {
    String item = (String)enum.nextElement();
    if(item.startsWith("method=")) { name=item.substring(7); break; }
  }

   if(name == null) {
       name = "unspecified";
   }

   // Invoke the named method, and return the result
   return dispatchMethod(mapping,form,request,response,name);
}
---------------------------------------------------------------------------
An in the JSP you have simple Buttons like this:

<html:submit property="method=logon">
  <bean:messagekey="prompt.logon"/>
</nested:submit>

<nested:submit property="method=something" value="Do something"/>
---------------------------------------------------------------------------
And voilą: On the first button the Method "logon" is called, on the second, the 
method "something". And this is totally independend of the visible Text for the 
User.

Oliver Henning
Softwareentwickler
__________________________________________

aloba ag

- Softwareentwicklung + Consulting -

Lyssachstrasse 15
CH-3400 Burgdorf

Tel     :       +41 34 424 17 70
Fax     :       +41 34 424 17 74
Mobil   :       +41 79 308 38 17
Internet:       www.aloba.ch
__________________________________________

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

Reply via email to