What is the difference between dispatchaction and mappingdispatchaction in struts




















The function it implements is quite different from the above two, which is to map multiple action-mappings to different methods of the same Action class through struts-config. It can be seen that no matter how you change, these classes actually decompose execute. Whether it is save, edit or other methods, they are actually equivalent to the original execute.

At run time, this class manages to delegate the request to one of the methods of the derived Action class.

Selection of a method depends on the value of the parameter passed from the incoming request. MappingDispatchAction uses this request parameter value and selects a corresponding action from the different action-mappings defined. This eliminates the need of creating an instance of ActionForm class. Here all the methods are taking the same input parameters but each method returns a different ActionForward like "add" in case of add method , "edit" in case of edit etc.

Each ActionForward is defined in the struts-config. Developing the Action Mapping in the struts-config. The delete button shows an alternate way to specify the value of the button. Here the main constraint is the method name and the button name should be same. So we can't have an update button like this "Update".

Inorder to avoid this you can call a javascript function on click of the button. Specify the action and submit the form from javascript. In this way we can have a different button name and method name. On click of the Add button the action value is set to " UserAction. You can download the source code of the DispatchAction example by clicking on the Download link below.

Thanks for visiting DZone today,. Edit Profile. All Sign in options. Enter a Email Address. Choose your interests Get the latest news, expert insights and market research, sent straight to your inbox.

Newsletter Topics Select minimum 1 topic. Tags: Java. Hi, Simple difference : DispatchAction An abstract Action that dispatches to a public method that is named by the request parameter whose name is specified by the parameter property of the corresponding ActionMapping.

I am asking abt DispatchAction vrs. Register or Login.



0コメント

  • 1000 / 1000