• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

dispatchMethod in DispatchAction

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Scenario:
To implement pagination i have an action class that extends the DispatchAction. Have also declared the parameter attribute in the config.xml
At runtime i want to set the method to be called in the action class. Say sthg like, either first, prev, next, last... anything can be clicked, depending upon what is being clicked the respective method in the action class should be called.
I dont want to do this in javascript... is there any other way?
while going thru the API i saw the dispatchMethod()... wud that help?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
San,

In order to do this, you simply create a new java class that extends DispatchAction and has methods named prev(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception .. another named next with the same signature, another named first, etc.

Then in your html code, you would create a link such as:


The action will call a method named for whatever value you put in the parameter "method".

For further information, see the documentation:

http://struts.apache.org/api/org/apache/struts/actions/DispatchAction.html

Merrill
 
san geetha
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Merrill,
Thats what iam doing now. but i dont want to pass it in a querystring.
Any other way.
 
san geetha
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any idea about the dispatchMethod?
 
The overall mission is to change the world. When you've done that, then you can read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic