This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes LookupDispatchAction class mapping button value to wrong method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "LookupDispatchAction class mapping button value to wrong method" Watch "LookupDispatchAction class mapping button value to wrong method" New topic

LookupDispatchAction class mapping button value to wrong method


Joined: Aug 03, 2006
Posts: 1
Hi all,
My app's jsp fragment javacript function as below:
function registerData(data,page)

Properties file fragment is as below:
add.saveProgress.button=Save As In Progress
update.saveProgress.button=Save As In Progress
#add.register.button=Submit for Add Registration
#update.register.button=Submit for Update Registration

LookupDispatchAction class fragment as below:
protected Map getKeyMethodMap()
Map keys = (Map) new HashMap();
return keys;

public ActionForward register(..){.. }
public ActionForward registerUpdate(..){..}

Everytime when I click on the "add.register.button" to trigger javascript registerData() funtion , struts should invoke register() method to handle this action. But by debugging, I found it actually invokes registerUpdate()method which is supposed to handle another jsp page's action.

And if I replace the code in
getKeyMethodMap() method with the commentted code(see the above code snippet),
struts can working well to invoke correct register() method, not the wrong registerUpdate()method. Seems like that struts looks up button "label", but not "value" to decide which method to invoke. It is pretty strange and confused me. My app can work fine by the above "commented label", but not working to use the old "uncommentted" label,and my client insist to use the old one.

Any idea is appreciated,

Zip Ped
Ranch Hand

Joined: Jul 26, 2005
Posts: 336

Go through the documentation for getKeyMethodMap() method in LookupDispatchAction class. You will find your answer.
subject: LookupDispatchAction class mapping button value to wrong method
Similar Threads
Handling buttons with same names in two forms using a single Action class.
LookupDispatchAction only firing execute, not mapped methods
How to link different buttons to different action methods
LookupDispatchAction Query
Problems with multiple-bottons on one form