Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is Multiple Actions in Action class

 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In ActionClass we can use only one action i.e execute(), but in DispatchAction we can use multiple actions.My question is , we can use multiple actions in Action class if(action.equals("add") ,if(action.equals("update"). Then when to use Action and DispatchAction which is frequently in webapplications.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this some specific framework you're asking about? If so, which one?
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the struts framework. Not sure which one is used more than the other. I have worked on applications that use both. I guess it depends on if you have several action paths, and the functionaluty of each path is similar, then the dispath action may come in handy. Especially if the same form bean is being used for all the different paths/actions.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Struts.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doing conditional logic in an execute() method is just one way (a messy one) to implement DispatchActon. I can't think of any particular reason to do the work manually when a mechanism already exists--except if the decision-making process is more difficult than a simple string (for example, which method might depend on a combination of factors).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic