• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

LookupDispatchAction class mapping button value to wrong method

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Go through the documentation for getKeyMethodMap() method in LookupDispatchAction class. You will find your answer.
 
    Bookmark Topic Watch Topic
  • New Topic