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
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.
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
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:
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()
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.
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.
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.
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.