Thanks David.

So are you saying that the struts2 validation framework requires one Action per JSP page? If so, it seems like that needs to be included in the "full disclosure" section of the "validation" confluence page :-)

If I don't want to go that route (1 Action : 1 JSP), are there any alternatives short of writing my own validation framework?

Thanks,
John


Kawczynski, David wrote:
Either have lots of actions in your struts.xml, or use wildcard mappings
(http://struts.apache.org/2.0.11.2/docs/wildcard-mappings.html)

-----Original Message-----
From: 928572663 [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 21, 2008 11:43 AM
To: Struts Users Mailing List
Subject: Re: [s2] Problem getting basic server side field validation to
work

Great - that fixed it.

Follow up: supposed this Action class can serve up 10 different JSP pages, all of which need validation. I would want the "input" result type to forward to whichever of the 10 JSPs that the user was in when the validation error occurred. So what is the best way to handle that?

Thanks,
John


Kawczynski, David wrote:
Yes, in the event of server-sided validation failure the framework
returns the user to this "input" page
-----Original Message-----
From: 928572663 [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 21, 2008 11:27 AM
To: Kawczynski, David
Cc: Struts Users Mailing List
Subject: Re: [s2] Problem getting basic server side field validation
to
work

Thanks David for the quick reply.

Is the 'input' result type used by the validation framework?  My
action
class does not return that.

Thanks,
John


Kawczynski, David wrote:
You need to define a <result> of type input for your action.
-----Original Message-----
From: 928572663 [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 21, 2008 11:02 AM
To: Struts Users Mailing List
Subject: [s2] Problem getting basic server side field validation to
work
I'm trying to do a very basic test app that demonstrates the server
side
field validation and am getting an exception during initial JSP page rendering. The page and action work fine without the validation.

Any ideas what I may be missing?

I've read the confluence pages on validation, and have been keeping
up
with the many posts on the mailing list, but they all seem to be
various
advanced scenarios.

Here is some info to help:

* Using struts 2.1.2 basic (no plugins to speak of)
* Using Zero Configuration (annotations) with no struts.xml
* form bean is stored in session
* action function works great w/o validation
* when adding the SampleAction-validation.xml the exception happens during initial page rendering

Here is the stack and last few logs:


DEBUG [] [2008/10/21 09:01:12] [com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor] Invoking validate() on action [EMAIL PROTECTED] DEBUG [] [2008/10/21 09:01:12] [com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil]
cannot
find method [validateDisplayForm] in action
[EMAIL PROTECTED]
DEBUG [] [2008/10/21 09:01:12] [com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil]
cannot
find method [validateDoDisplayForm] in action
[EMAIL PROTECTED]
DEBUG [] [2008/10/21 09:01:12] [com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor]
Errors
on action [EMAIL PROTECTED], returning result name 'input'
ERROR [] [2008/10/21 09:01:12] [org.apache.struts2.dispatcher.Dispatcher] Could not find action or result No result defined for action sample.SampleAction and result
input
at
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultAct
ionInvocation.java:357)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo
cation.java:259)
at
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(Vali
dationInterceptor.java:248)
at
org.apache.struts2.interceptor.validation.AnnotationValidationIntercepto
r.doIntercept(AnnotationValidationInterceptor.java:49)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(Me
thodFilterInterceptor.java:86)



/SampleAction-validation.xml

<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd";>
<validators>
    <field name="formBean.lastName">
       <field-validator type="requiredstring">
          <message>You must enter a Last Name</message>
       </field-validator>
    </field>
    <field name="formBean.maxValue">
       <field-validator type="int">
          <param name="min">13</param>
          <param name="max">19</param>
          <message>The max value must be between 13 and 19</message>
       </field-validator>
    </field>
</validators>




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

Reply via email to