This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can we call two different methods based on the same action in Struts2.

 
Hrishikesh Maluskar
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we call two different methods based on the same action in Struts2.

The methods will be called when two different buttons are clicked , for example login button and register button are on the same JSP page.

When we click on login button doLogin() method should be called and when we click on register button doRegister() method should be called.

 
Joe Ess
Bartender
Posts: 9280
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The action tag in struts.xml has a "method" parameter that allows you to specify a method name. The method takes no arguments and must return a String.
 
senthil kumar m
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hrishikesh Maluskar wrote:Can we call two different methods based on the same action in Struts2.

The methods will be called when two different buttons are clicked , for example login button and register button are on the same JSP page.

When we click on login button doLogin() method should be called and when we click on register button doRegister() method should be called.



then..you can use DispatchAction . Extend the DispatchAction in your action class.

And also configure accordingly in struts-config.xml, have parameter="method" as Joe Said..

Read about struts DispatchAction.that will be helpful.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic