| Author |
chain of actions-advice
|
yash Vi
Ranch Hand
Joined: Jul 17, 2005
Posts: 41
|
|
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
|
Thanks for your reply and time.<br />Windows 2000,j2sdk1.4.2_08
|
 |
Pranav Sharma
Ranch Hand
Joined: Oct 27, 2003
Posts: 254
|
|
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.
|
 |
Marc Peabody
pie sneak
Sheriff
Joined: Feb 05, 2003
Posts: 4725
|
|
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!
|
A good workman is known by his tools.
|
 |
yash Vi
Ranch Hand
Joined: Jul 17, 2005
Posts: 41
|
|
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
Sheriff
Joined: Feb 05, 2003
Posts: 4725
|
|
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.
|
 |
 |
|
|
subject: chain of actions-advice
|
|
|