GeekInterview.com
Series: Subject: Topic:
Question: 80 of 109

What is DispatchAction

Asked by: Interview Candidate | Asked on: Aug 23rd, 2005
Showing Answers 1 - 8 of 8 Answers
Sudhir Patil

Answered On : 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.

  
Login to rate this answer.
Anindit Sinha

Answered On : 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

  
Login to rate this answer.
LV

Answered On : Sep 13th, 2005

DispatchAction is mostly used for carrying out multiple operations with in a single Action class. Here is the link to some article that I found on this:

http://www.reumann.net/struts/lesson3/step6.do

  
Login to rate this answer.
Kamal Lochan

Answered On : 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()

  
Login to rate this answer.
pandu

Answered On : 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

  
Login to rate this answer.
Shrikar

Answered On : 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.

  
Login to rate this answer.
Suman Kumar Gattu

Answered On : 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.

Yes  1 User has rated as useful.
  
Login to rate this answer.
sreelatha

Answered On : 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.

  
Login to rate this answer.

Give your answer:

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

Related Open Questions

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Career Counselling

 Have Career Question?

 Ask Chandra

 Ask Only Career questions.

Follow us:
 

Latest Questions

Ads

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, click "Subscribe".