GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  Struts
Go To First  |  Previous Question  |  Next Question 
 Struts  |  Question 5 of 102    Print  
What is DispatchAction

  
Total Answers and Comments: 8 Last Update: September 28, 2007   
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Suman Kumar Gattu
 

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.



Above answer was rated as good by the following members:
pradeepkmr18
April 22, 2005 01:19:19   #1  
Sudhir Patil        

RE: What is DispatchAction
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.

 
Is this answer useful? Yes | No
August 23, 2005 06:27:17   #2  
Anindit Sinha        

RE: What is DispatchAction
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
 
Is this answer useful? Yes | No
September 13, 2005 00:20:24   #3  
LV        

RE: What is DispatchAction

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


 
Is this answer useful? Yes | No
May 19, 2006 05:14:21   #4  
Kamal Lochan        

RE: What is DispatchAction
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()
 
Is this answer useful? Yes | No
July 12, 2007 01:43:40   #5  
pandu        

RE: What is DispatchAction
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

 
Is this answer useful? Yes | No
July 15, 2007 11:58:33   #6  
Shrikar        

RE: What is DispatchAction
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.
 
Is this answer useful? Yes | No
July 15, 2007 15:54:27   #7  
Suman Kumar Gattu        

RE: What is DispatchAction

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.


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
September 28, 2007 11:21:04   #8  
sreelatha        

RE: What is DispatchAction

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.


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape