You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by djia002 <do...@hotmail.com> on 2008/01/25 02:13:56 UTC

Struts2 Validation

Hello , I am new to struts2. Please help me on this problem.

I have a configuration like this 
        <action name="Action1.*" method="{1}" class="ActionClass1">
            <result name="summary">/page1.jsp</result>
            <result name="detail">/page2.jsp</result>
        </action>

        <action name="Action2.*" method="{1}" class="ActionClass2">
            <result name="summary">/page1.jsp</result>
            <result name="detail">/page2.jsp</result>
            <result name="input">/page2.jsp</result>
        </action>


The flow is I submit a form from page1 to Action ActionClass2.edit method, 

public String edit() throws Exception {

// fetch some data and push into session for rendering page2.jsp ...


return "detail"; // This will forward to page2.jsp
}

You can see from the code that edit() method try to store some data in
session for displaying page2.jsp.

Everything works fine until i added ActionClass2-validation.xml for
validating the form on page2.jsp.

I got error says "No result defined for action  and result input."
so I added <result name="input">page2.jsp</result> into configuration. and
then of course it just simply try to display page2.jsp without having data
preloaded by edit() because edit() not get called at all.

How can I work around with this problem?

Thanks in advance.
Kevin
-- 
View this message in context: http://www.nabble.com/Struts2-Validation-tp15079124p15079124.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Struts2 Validation

Posted by "Jeff Hill (RR)" <dj...@tampabay.rr.com>.
Kevin,
You didn't mention what page has the form you're submitting, but let me call
that "page0". Let's say it has two buttons: Button1 for Action1, and Button2
for Action2. I'm assuming that you entered data and hit Button2, and this
worked fine until you added the validation descriptor for Action2. 

The fact that it did stop working, and that it's trying to handle "input",
says there was a vaidation failure. Trying to coerce "input" to take you to
"page2" isn't likely to help, since on the validation failure the action
isn't invoked, so edit() is never called.

So, I have to assume that, from the data you entered, you didn't *expect*
validation to fail. I'd suggest you review the validation you added,
especially if there are any custom validators - maybe there's a combination
of validators on some field that can never evaluate to true. If there's
nothing obvious then I'd suggest adding an actionerror or some fielderror
tags to page0, and let it redisplay so you can see what field is failing
validation.

...Jeff

-----Original Message-----
From: djia002 [mailto:dongmingjiang@hotmail.com] 
Sent: Thursday, January 24, 2008 8:14 PM
To: user@struts.apache.org
Subject: Struts2 Validation


Hello , I am new to struts2. Please help me on this problem.

I have a configuration like this 
        <action name="Action1.*" method="{1}" class="ActionClass1">
            <result name="summary">/page1.jsp</result>
            <result name="detail">/page2.jsp</result>
        </action>

        <action name="Action2.*" method="{1}" class="ActionClass2">
            <result name="summary">/page1.jsp</result>
            <result name="detail">/page2.jsp</result>
            <result name="input">/page2.jsp</result>
        </action>


The flow is I submit a form from page1 to Action ActionClass2.edit method, 

public String edit() throws Exception {

// fetch some data and push into session for rendering page2.jsp ...


return "detail"; // This will forward to page2.jsp
}

You can see from the code that edit() method try to store some data in
session for displaying page2.jsp.

Everything works fine until i added ActionClass2-validation.xml for
validating the form on page2.jsp.

I got error says "No result defined for action  and result input."
so I added <result name="input">page2.jsp</result> into configuration. and
then of course it just simply try to display page2.jsp without having data
preloaded by edit() because edit() not get called at all.

How can I work around with this problem?

Thanks in advance.
Kevin
-- 
View this message in context:
http://www.nabble.com/Struts2-Validation-tp15079124p15079124.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org