• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dispatchMethod in DispatchAction

 
san geetha
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • 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?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Any idea about the dispatchMethod?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic