What is DispatchAction

Showing Answers 1 - 8 of 8 Answers

Sudhir Patil

  • Apr 22nd, 2005
 

The DispatchAction class is used to group related actions into one class. DispatchAction is an abstract class, so 
you must override it to use it. It extends the Action class. 
It should be noted that you dont have to use the DispatchAction to group multiple actions into one Action class. 
You could just use a hidden field that you inspect to delegate to member() methods inside of your action.

  Was this answer useful?  Yes

Anindit Sinha

  • Aug 23rd, 2005
 

The DispatchAction is a special Action class within Struts that allows different functions to be called depending on a value of a parameter in a request object

  Was this answer useful?  Yes

Kamal Lochan

  • May 19th, 2006
 

Dispatch Action allows you to specify a class with multiple methods, where one of the method is invoked based on the value of a special request parameter specified in the configuration file. DispatchAction uses the value of the request parameter to determin which method to invoke. Your class should extend DispatchAction and should not contain execute()

  Was this answer useful?  Yes

pandu

  • Jul 12th, 2007
 

Dispatch action extends Action.
If we want to perform more than one action means (Add,Delete,Insert) from jsp
for these three buttons we can use same action class with different methods.
based on the action particular method will execute.
the methods in Dispatch action are same as execute method of Action only the names are different.

I think it makes sense

  Was this answer useful?  Yes

Shrikar

  • Jul 15th, 2007
 

Dispatch Action helps the programmer in maintaining just one Action Class for different Actions which might get triggered basing on the action (in the page, for example a JSP page, selected). Every Action in the JSP page need not have a different/Separate Action class to handle the request. Instead, one Dispatch Action class can handle all this. Basing on the action selected, a value is passed to the Dispatch Action and the corresponding method gets executed which would handle the Action. Dispatch Action extends the Action class. This way the Dispatch Action reduces the Developement time and also eases the process of maintenance.

  Was this answer useful?  Yes

Suman Kumar Gattu

  • Jul 15th, 2007
 

Basically Dispatch action is used when you have multiple submit buttons in a single form.The Dispatch action is a class which extends the Struts DispatchAction , and encpsulates all the action methods (similar to execute method in Action class)in one single class.These actions methods will get executed based on the parameter that you pass in a jsp page.In the Struts-Config.xml you need to define the DispatchAction class and the parameter name that you passing in the URL.Based on the parameter the Controller will invoke the action method.

Suppose you have 3 submit buttons in a single form
Add
Delete
Save


You have a parameter name as actionparameter,when the user clicks on the Add button "actionparameter="add""  will get appended to the URL.

Register the "actionparameter" in the action mapping of the struts config file.


Then the controller will call the appropriate action method based on the user submit button.

sreelatha

  • Sep 28th, 2007
 

Please give me code for this :In single JSP how we maintain only one

Basically Dispatch action is used when you have multiple submit buttons in a single form.The Dispatch action is a class which extends the Struts DispatchAction , and encapsulates all the action methods (similar to execute method in Action class)in one single class.These actions methods will get executed based on the parameter that you pass in a jsp page.In the Struts-Config.xml you need to define the Dispatch Action class and the parameter name that you passing in the URL.Based on the parameter the Controller will invoke the action method.

Suppose you have 3 submit buttons in a single form
Add
Delete
Save


You have a parameter name as actionparameter,when the user clicks on the Add button "actionparameter="add""  will get appended to the URL.

Register the "actionparameter" in the action mapping of the struts config file.


Then the controller will call the appropriate action method based on the user submit button.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions