Dave,

Do you mean that you're doing a redirect after processing the post?

I've been thinking about this action chaining issue for some time since
I used it in my last project and it resulted in some code duplication.
The reason is, I was storing the setup data in my form (which I still
think is better than using multiple objects stored in request scope
under multiple keys). When doing the chaining, I didn't want my form to
get reset and lose all the request data when going to the second action,
so I had to configure two action mappings for the same action:
1- A prepare action when the page is called directly (a form bean is
configured for that one).
2- A page action when it's called from another action (no form bean is
configured to prevent resetting).

In the execute method, I was checking whether the form is null, and if
it is, I would retrieve it from the request scope. I felt later that
this was an awkward approach.

Now, I have two more solutions that I'm considering.
1- Put the setup information in the ActionForm class itself (not very
inclined to go for that one).
2- Using a MappingDispatchAction without action chaining. Put the setup
code in common methods in the action class. Configure two mappings for
the same action class that will call two different methods, e.g. prepare
and add. In both methods, I would call the common setup method before
going back to the page, so it's minimal duplicated code (although
duplication is not completely eliminated), but at least it's less
awkward than retieving the form from the request scope by hand.

Would anyone care to comment on those two approaches? Does anyone have a
different approach that I can consider?

Thanks

-----Original Message-----
From: Dave Newton [mailto:[EMAIL PROTECTED] 
Sent: Monday, May 01, 2006 6:03 PM
To: Struts Users Mailing List
Subject: Re: Is Action Chaining Strongly Discouraged?

David Evans wrote:
> Is there a reason you don't use the two action (setup and submit)
approach?
>   

I just think it's cluttery. I always use POST so it's easy to just split
my actions into GET and POST handlers; I do the setup in the GET
handler.

Dave

********************************************DISCLAIMER********************************************
This email and any files transmitted with it are confidential and contain 
privileged or copyright 
information. If you are not the intended recipient you must not copy, 
distribute or use this email
or the information contained in it for any purpose other than to notify us of 
the receipt thereof.
If you have received this message in error, please notify the sender 
immediately, and delete this
email from your system.

Please note that e-mails are susceptible to change.The sender shall not be 
liable for the improper
or incomplete transmission of the information contained in this 
communication,nor for any delay in
its receipt or damage to your system.The sender does not guarantee that this 
material is free from
viruses or any other defects although due care has been taken to minimise the 
risk.
**************************************************************************************************

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to