Laurie,

Thank you.  Your suggestion works great.  Very elegant!

-Hien

-----Original Message-----
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Laurie Harper
Sent: Tuesday, May 20, 2008 1:55 PM
To: user@struts.apache.org
Subject: Re: Struts 2: After validation fail, how to change the
returning result name to other than INPUT?

Phan, Hienthuc T wrote:
> Hi,
> 
> I have a CustomerAction class.  In CustomerAction, I have two methods:
> add and update.  I have a CustomerAction-validation.xml to check for
> required fields, etc.  My struts.xml looks something like this:
> 
>       <package name="customer">
>               <action name="customer_*"
> class="com.action.CustomerAction" method="{1}">
>                       <result
> name="create">/customer_create.jsp</result>
>                       <result
> name="update">/customer_update.jsp</result>
>               </action>
>       </package>
> 
> When the validation fail, I would like it to return to the previous
page
> (either cusomer_create.jsp or customer_update.jsp).  However, Struts
> returns result = "input" automatically when the validation fail. How
do
> I change the result from "input" to either "add" or "update"?
> 
> A clunky way to solve this problem is to create two actions.  That
would
> generate too many classes.  Is there a good solution for this problem
of
> mine?  Thanks.

How do you know which one to return to? There are a few possibilities, 
but if the result name is the same as the method name you could do 
something like

   <action name="customer_*" method="{1}" ...>
     <result name="input">/customer_{1}.jsp"/>
     <result name="{1}">/customer_{1}.jsp"/>
   </action>

(note that I also collapsed your other two results using the same 
technique).

L.


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

Notice:  This e-mail message, together with any attachments, contains 
information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New 
Jersey, USA 08889), and/or its affiliates (which may be known outside the 
United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as 
Banyu - direct contact information for affiliates is available at 
http://www.merck.com/contact/contacts.html) that may be confidential, 
proprietary copyrighted and/or legally privileged. It is intended solely for 
the use of the individual or entity named on this message. If you are not the 
intended recipient, and have received this message in error, please notify us 
immediately by reply e-mail and then delete it from your system.


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

Reply via email to