Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

dispatchMethod in DispatchAction

 
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?
 
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?
 
I think she's lovely. It's this tiny ad that called her crazy:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic