• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic