This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara 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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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
Author

LookupDispatchAction class mapping button value to wrong method

richard1
Greenhorn

Joined: Aug 03, 2006
Posts: 1
Hi all,
My app's jsp fragment javacript function as below:
.....
function registerData(data,page)
{
document.addForm.action='/sofTrack/registerRecord.do';
document.addForm.type.value=data;
document.addForm.pageNo.value=page;
document.addForm.submit();
}
......

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();
.....
keys.put("add.register.button","register");
keys.put("add.save.button","registerUpdate");
....
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,

Rich
Zip Ped
Ranch Hand

Joined: Jul 26, 2005
Posts: 336
Hi,

Go through the documentation for getKeyMethodMap() method in LookupDispatchAction class. You will find your answer.
 
Don't get me started about those stupid light bulbs.
 
subject: LookupDispatchAction class mapping button value to wrong method