aspose file tools*
The moose likes Struts and the fly likes difference between DispatchAction and LookupDispatchAction. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "difference between DispatchAction and LookupDispatchAction." Watch "difference between DispatchAction and LookupDispatchAction." New topic
Author

difference between DispatchAction and LookupDispatchAction.

samir ware
Ranch Hand

Joined: Jul 27, 2005
Posts: 192
hi,
Can anybody tell me what is the difference between DispatchAction and LookupDispatchAction.
Thanks in advance,
Samir
Ravi Seshu
Ranch Hand

Joined: Mar 19, 2005
Posts: 38
Hi,
DispatchAction dispatches the action based on the parameter value. where as lookupdispatchAction which is a subclass of it, inherits all the properties but has one more additional method called getmethodkey() for all those mappings ... ex. specified in properties file.s..
-eswar
samir ware
Ranch Hand

Joined: Jul 27, 2005
Posts: 192
thats fine...but what is the use of the HashMap . Why do we need to store all the values in the key value pair.Can you please explanin with the practical example
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Say you have 3 buttons on your form: add, delete, and update. If your website is in English and you're not planning to use internatoinalization, you would code the three buttons:

<html:submit property="action">add</html:submit>
<html:submit property="action">update</html:submit>
<html:submit property="action">delete</html:submit>

You could then use DispatchAction and code the methods add(), update(), and delete(), and Struts would forward to the appropriate method based on the button pressed.

However, if you use internationalization, this won't work because the label of the button could be in any number of languages. In this case, you need to use LookupDispatch action and code your JSP like this:

<html:submit property="action"><bean:message key="label.add" /></html:submit>
<html:submit property="action"><bean:message key="label.update /></html:submit>
<html:submit property="action"><bean:message key="label.delete" /></html:submit>

You'll then code the getMethodKey() to find the appropriate method based on the message key. That way, regardless of what language is actually used at runtime, Struts will still dispatch to the correct method.


Merrill
Consultant, Sima Solutions
samir ware
Ranch Hand

Joined: Jul 27, 2005
Posts: 192
thanks a lot for your valuable guidance. This discusion forum is really helpfull for improving once ability in java.
Thank you once again.
carox kaur
Ranch Hand

Joined: Mar 19, 2009
Posts: 52
Although this post is very old, I do not want to start a new thread.....a part of my question is answered here I think....I am not able to differentiate between the use of LookupDispatch action and Dispatch action. what lacks in dispatch action so that we have to use Lookup dispatch action?

So this means that, when we code like this:
<html:submit property="action">add</html:submit>
<html:submit property="action">update</html:submit>
<html:submit property="action">delete</html:submit>

the value of the parameter 'action' will be selected from the caption of the buttons? How the value of the action parameter is selected? If this is true, then it may also mean that the captions on the buttons should match the method names in the action class?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: difference between DispatchAction and LookupDispatchAction.