• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Diggerence in action

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i am new to struts and i want to know that what is the difference between action and dispach action..

waiting for reply.
 
Ranch Hand
Posts: 471
Mac OS X Hibernate Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

There are several solutions to this problem. One of them is to use javascript to change the form's action, then submit it. Another solution is to have a parameter in the form, and you check for it in your action, and according to the value of that parameter, you choose what to do through conditions in your code. A third solution is using DispatchAction.

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 ]
 
Sagar Kumbhar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey
thanks Alaa Nassef
i got my doubt cleared with such a detail explaination
thanks once again!!
 
Alaa Nassef
Ranch Hand
Posts: 471
Mac OS X Hibernate Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No problem. Always glad to help.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic