aspose file tools*
The moose likes Struts and the fly likes LookupDispatchAction Query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "LookupDispatchAction Query " Watch "LookupDispatchAction Query " New topic
Author

LookupDispatchAction Query

Siddharth Bhargava
Ranch Hand

Joined: Feb 23, 2007
Posts: 266
Hi Friends,
I have implemented a sample program to show LookupDispatchAction. Following is the code snippet.

index.jsp
=========


lookDispatchAction.jsp
======================



struts-config.xml
=================




LookupDispatchActionExample.java
================================




ApplicationResources.properties
===============================




The flow goes like this :

It first goes to the index.jsp. Here it displays the link to the "lookupDispatchAction.jsp". On clicking the link it goes to lookupDispatchAction.jsp. In lookupDispatchaction.jsp it displays the text in the buttons by consulting the ApplicationResources.properties files. When one clicks on the particular button then its saves the value in the parameter property. It then goes to the lookupDispatchAction and executes the LookupDispatchExample class. There you have various methods for different button clicks. As per the click of the particular button that method is called. It then return the particular string e.g. add and it checks for that particular string in action mapping and displays the appopriate jsp.

Queries :

1) Is my understanding of the lookupdispatchaction flow correct ? If not then please do give the correct flow of lookupdispatchaction and clarify my understanding.

2) Where does the "getKeyMethodMap()" come into the picture ? I didn't get the purpose of Map here.

3) Is lookupdispatchaction only used for internationalization ? Other than that isn't it simmilar to dispatchaction ?

Any help would be highly appreciated.

Thanks and Regards,
Sid.


Sumit Patil
Ranch Hand

Joined: May 25, 2009
Posts: 296

Here is a link.
Hope it helps

LookUpDispatchAction


Thanks & Regards, Sumeet
SCJP 1.4, SCWCD 5, LinkedIn Profile
Siddharth Bhargava
Ranch Hand

Joined: Feb 23, 2007
Posts: 266
Hi Sumit,
The site helped but not that much. It dosn't give the flow of lookupdispatchaction. I still didn't get what is the purpose of getKyMethodMap() where is the Map being used. resource bundle is used to label the buttons. But how is the resource bundle used in the Map.
I don't want to gulp it down. I want to clarify my concept so that I don't forget ever.


Thanks and Regards,
Siddharth Bhargava.
Sumit Patil
Ranch Hand

Joined: May 25, 2009
Posts: 296

Siddharth Bhargava wrote:I still didn't get what is the purpose of getKyMethodMap() where is the Map being used. resource bundle is used to label the buttons. But how is the resource bundle used in the Map.


Well the resource bundle is not used in the Map. You have to implement getKeyMethodMap() so that a link is created between the resource bundle, the button in jsp and the method name in action class.

Here is a example



Now in this imlementation, the key names should be the same as mentioned in the resource bunlde and their corresponding values should be the method name in action class.

Now in the jsp you will have something like this



The generated html for this would be if you have set the corresponding entry to 'Save' in resource bundle.



When you hit the Save button, parameter along with the action would be "action=Save". The action class (LookUpDispatchAction implementation ) will take this value of 'Save', find the correspoding 'message resource key' for this value in this case 'button.save'. Now with the help of getKeyMethodMap the value for this key is save() method, which will be invoked and request will be processed.

Hope this helps.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: LookupDispatchAction Query