• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

LookupDispatchAction Query

 
Siddharth Bhargava
Ranch Hand
Posts: 274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a link.
Hope it helps

LookUpDispatchAction
 
Siddharth Bhargava
Ranch Hand
Posts: 274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic