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]