You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Varley, Roger" <Ro...@atosorigin.com> on 2004/08/27 13:26:36 UTC

LookupDispatchAction (Newbie)

Hi

I have implemented a LookupDispatchAction action class to deal with a form that contains multiple submit buttons as outlined in the sample chapter from "The Struts Survival Guide" at http://www.objectsource.com/Chapter4.pdf I've got everything working but I would be grateful if someone could either explain or point me to documentation explaining, *why* it works? 

Regards
Roger


__________________________________________________________________________
This e-mail and the documents attached are confidential and intended 
solely for the addressee; it may also be privileged. If you receive this 
e-mail in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos Origin group 
liability cannot be triggered for the message content. Although the 
sender endeavours to maintain a computer virus-free network, the sender 
does not warrant that this transmission is virus-free and will not be 
liable for any damages resulting from any virus transmitted.
__________________________________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: LookupDispatchAction (Newbie)

Posted by Michael McGrady <mi...@michaelmcgrady.com>.
Once you see how LookupDispatchAction works, you should also see that it 
is an unnecessarily complicated solution.  Try 
http://wiki.apache.org/struts/StrutsCatalogMultipleImageTagsSimplified 
which shows that all you have to do is:

    String button = null;
    Enumeration enum = request.getParameterNames();
    String parameterName = null;
    while(enum.hasMoreElements()) {
      parameterName = (String)enum.nextElement();
      if(parameterName.endsWith(".x")) {
        button = parameterName.substring(0,parameterName.indexOf('.'));
      }

    }

Isn't that a great deal simpler?  If you want to solve it with a class, 
then do somethin like:

*public class ImageTagUtil {
  public static String getName(HttpServletRequest request) {
    String command = null;
    String buttonValue = null;
    Enumeration enum = request.getParameterNames();

    while(enum.hasMoreElements()) {
      buttonValue = (String)enum.nextElement();
      if(buttonValue.endsWith(".x")) {
        command = buttonValue.substring(0,buttonValue.indexOf('.'));
      }
    }
    return command;
  }
}*

However, if you love the complications, essentially the idea is to put 
the paramter value together with method names in order to map the 
buttons to methods.  So, if you have buttons returning button.add and 
button.delete, your parameter value will be "button".  Once you know 
that the parameter is button, then you can search for button.? and ? 
will be the method name.  This is a totally unnecessary complication, 
since we already have .x and .y at the end so generously supplied by the 
standard HTML.  So the above code does the same thing without tying the 
solution to the parameter value, which frees the parameter value for 
other uses and which decouples the solution from struts.

Regards,

Michael

>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: LookupDispatchAction (Newbie)

Posted by Bill Siggelkow <bi...@bellsouth.net>.
http://struts.apache.org/api/org/apache/struts/actions/LookupDispatchAction.html

Bill Siggelkow

Varley, Roger wrote:
> Hi
> 
> I have implemented a LookupDispatchAction action class to deal with a form that contains multiple submit buttons as outlined in the sample chapter from "The Struts Survival Guide" at http://www.objectsource.com/Chapter4.pdf I've got everything working but I would be grateful if someone could either explain or point me to documentation explaining, *why* it works? 
> 
> Regards
> Roger
> 
> 
> __________________________________________________________________________
> This e-mail and the documents attached are confidential and intended 
> solely for the addressee; it may also be privileged. If you receive this 
> e-mail in error, please notify the sender immediately and destroy it.
> As its integrity cannot be secured on the Internet, the Atos Origin group 
> liability cannot be triggered for the message content. Although the 
> sender endeavours to maintain a computer virus-free network, the sender 
> does not warrant that this transmission is virus-free and will not be 
> liable for any damages resulting from any virus transmitted.
> __________________________________________________________________________


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: LookupDispatchAction (Newbie)

Posted by Leandro Melo <lt...@yahoo.com.br>.
A quick look at the DispatchAction source (if you
don`t have the source, you can download it) would the
best way for you to understand. It`s not that
complicated.

I never took a detailed look at the source, but
basically, it gets the mapping for the method
specified in struts-config.xml and then get the value
of this parameter. After that it dispatches the
request to the specifc method a calling to
dispatchMethod() method.



 --- "Varley, Roger" <Ro...@atosorigin.com>
escreveu: 
> Hi
> 
> I have implemented a LookupDispatchAction action
> class to deal with a form that contains multiple
> submit buttons as outlined in the sample chapter
> from "The Struts Survival Guide" at
> http://www.objectsource.com/Chapter4.pdf I've got
> everything working but I would be grateful if
> someone could either explain or point me to
> documentation explaining, *why* it works? 
> 
> Regards
> Roger
> 
> 
>
__________________________________________________________________________
> This e-mail and the documents attached are
> confidential and intended 
> solely for the addressee; it may also be privileged.
> If you receive this 
> e-mail in error, please notify the sender
> immediately and destroy it.
> As its integrity cannot be secured on the Internet,
> the Atos Origin group 
> liability cannot be triggered for the message
> content. Although the 
> sender endeavours to maintain a computer virus-free
> network, the sender 
> does not warrant that this transmission is
> virus-free and will not be 
> liable for any damages resulting from any virus
> transmitted.
>
__________________________________________________________________________
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
>  


	
	
		
_______________________________________________________
Yahoo! Acesso Grátis - navegue de graça com conexão de qualidade! 
http://br.acesso.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org