• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

LookupDispatchAction

 
Ranch Hand
Posts: 502
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can any one explain me what is the use of "LookupDispatchAction". And what is the difference between "DispatchAction" and "LookupDispatchAction". if explain with example that would be great.

Thanks in Advance.
 
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In many cases it hapens that a perticular form has more than 1 button present on it.Lets say a form has 2 buttons 1> save 2> cancel. And each of this button when pressed submits the same form.
So in order to deal with such situation and to provide the different functionality for the 2 buttons "DispatchAction" is provided.
What we do is write 2 methode named save and cancle and parameters to these 2 methodes will be the same as that of the execute methode.
So whenever we click on any of the 2 button , the perticular method(save or cancel) will gets called.Thus the moral of the story is "Dispatch Action" is ment to provide the different functionality to more than 1 button which is on the same form.
code for the Dispatch action is as

If your website is in English and you're not planning to use internatoinalization, you would code the three buttons:

<html:submit property="action">save</html:submit>
<html:submit property="action">cancel</html:submit>


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

The LookUpDispatchAction is just the extention of the same.It is used for the internationalisation purpose. 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.save" /></html:submit>
<html:submit property="action"><bean:message key="label.cancel/></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.
 
That is a really big piece of pie for such a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic