• 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

chain of actions-advice

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a situation of chain of Action classes.. I remember reading that its an inefficient way of doing it.

The situation is this ,

There is a page which lists an account details which can be modified and after they do the modification and click modify, they see their workspace with the list of accounts they work on.

I have an rendermodifyaction with modifyform bean which renders the prepopulated form
and when clicked modify the ModifyAction with modifyform bean does the modification and some
business logic calls.

I have a separate AccountListAction with accountlistform which renders the List of accounts

Everything works fine when separate. I am chaining Action to Action to collate this.

As follows

<action-mappings type="org.apache.struts.action.ActionMapping">
<action path="/modifyaction"
type="com.modifyaction"
validate="false">
<forward name="success" path="/AccountListAction.do" />
</action>
<action path="/AccountListAction "
type="com.AccountListAction "
scope="session"
validate="false">
<forward name="success" path="/result.jsp" />
</action>
</action-mappings>

Is this the right way and wot is the correct way to do the same
 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's best to avoid action chaining until really needed.

A better way to do the above would be to have a Base Action which implements the AccountsList logic. and let it be called whenever you want to list the accounts.
This way modify can call AccountsList if it needed it.
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It doesn't look like you are using ActionForms... or at least if you are, they are not being controlled by the Struts framework because they are not specified in the ActionMapping. Since that is the case, I do not think you have an acceptable reason to chain Actions.

See, the benefit of Action Chaining to assist prepopulation is usually just a way to get around the fact that the Struts framework only allows one ActionForm in its control per ActionMapping. When navigating between two pages you often need two ActionForms - one for the page you are on and one for the page you are navigating to. And when you need two ActionForms in a single request (unless you create and save the forms to scope yourself, thus bypassing Struts' total control of ActionForms) you need two ActionMappings.

I anticipate that some developers will not share my views. Let the debates begin!
 
yash Vi
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use modifyform bean and Accountlistform bean.. it was just an example
of the action mapping given.I have many such situations in my project.Can you please explain the concept of Base Action class and how it can be implemented
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mannu means that you would create an Action class with a bunch of utility methods (which will be a base Action) and all of your current Action classes would then extend the base class instead of Action so they can use these methods internally.

I believe it would actually be better to place these methods in a separate class such as a Business Delegate.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic