The moose likes Struts and the fly likes dispatchMethod in DispatchAction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "dispatchMethod in DispatchAction" Watch "dispatchMethod in DispatchAction" New topic

dispatchMethod in DispatchAction

san geetha
Ranch Hand

Joined: Sep 07, 2004
Posts: 44
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

Joined: Feb 15, 2005
Posts: 4864

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:



Consultant, Sima Solutions
san geetha
Ranch Hand

Joined: Sep 07, 2004
Posts: 44
Thats what iam doing now. but i dont want to pass it in a querystring.
Any other way.
san geetha
Ranch Hand

Joined: Sep 07, 2004
Posts: 44
Any idea about the dispatchMethod?
Don't get me started about those stupid light bulbs.
subject: dispatchMethod in DispatchAction
Similar Threads
[Struts Recipes] Dispatching actions
Can we call two different methods based on the same action in Struts2.
Probably a very simple Struts form question?
Problem regarding DispatchAction
Please review code for LookupDisptach using Image Buttons