Two Laptop Bag
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
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.
I agree. Here's the link:
subject: LookupDispatchAction class mapping button value to wrong method
It's not a secret anymore!