hi, i am new to struts and i want to know that what is the difference between action and dispach action..
waiting for reply.
Joined: Jan 28, 2008
Hello Sagar, The answer is quiet simple. Action is a class that you extend, and overwrite the execute where you put your action logic. But there is a small problem that might face you in some applications, where in a single page you might need to give the user the opportunity to choose from several actions. The problem is that the html form can have (at a time) one and only one action.
DispatchAction is simply the same the same as the second solution, except that you don't have to write the conditions yourself. All you have to do is to create the methods that you want for that action having a signature similar to that of execute that is present in the Action class. You'll have to change the config of the action in the configuration file a little, to add a parameter. This parameter is going to be present in the form bean class and in the JSP, the values of this parameter are going to be the same as the method names. According to the value, struts will automatically call the appropriate method.
Check the pdf for advanced actions in this site. It's very informative. [ January 30, 2008: Message edited by: Alaa Nassef ]