DOH! I didn't upgrade my validator-rules.xml file from 1.1 to 1.2.4.
This previous post to this mailing list solved the problem:
http://www.mail-archive.com/[EMAIL PROTECTED]/msg11592.html
Many thanks to those who responded to my original post.
Mark.
-----Original Message-----
From: Mark Songhurst
Sent: 29 September 2004 17:04
To: Struts Users Mailing List
Subject: RE: Problems with Multi Page (wizard) Validation using
DynaValidatorForm and the "page=" attribute
Thanks for the feedback! Much appreciated.
I realised that in my JSP page(s) I had the
<html:hidden property="page" value="1"/>
element declared before my form element:
<html:form action="/WizardPage1Submit" focus="firstName">
The ordering of <html:form> first, with <html:hidden> nested inside
would seem important and I guess, make sense - the hidden property page
belongs to the form submitted to my DynaValidatorForm.
I am now no longer getting the NullPointerException, but I am not
picking up any validator errors - my wizard will move onto the second
page without displaying any validation errors in the HTML.
I'm also now getting a related SEVERE message in my catalina.out log:
-----------------------------------------------
29-Sep-2004 16:50:06 org.apache.struts.validator.DynaValidatorForm
validate
SEVERE:
org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Objec
t, org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest)
org.apache.commons.validator.ValidatorException:
org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Objec
t, org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest)
at
org.apache.commons.validator.ValidatorAction.loadValidationMethod(Valida
torAction.java:627)
at
org.apache.commons.validator.ValidatorAction.executeValidationMethod(Val
idatorAction.java:557)
at
org.apache.commons.validator.Field.validateForRule(Field.java:811)
at org.apache.commons.validator.Field.validate(Field.java:890)
at org.apache.commons.validator.Form.validate(Form.java:174)
at
org.apache.commons.validator.Validator.validate(Validator.java:367)
at
org.apache.struts.validator.DynaValidatorForm.validate(DynaValidatorForm
.java:112)
at
org.apache.struts.action.RequestProcessor.processValidate(RequestProcess
or.java:921)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:
206)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
tionFilterChain.java:237)
at
-----------------------------------------------
I've listed my complete wizardpage1.jsp file below.
Again, any help would be much appreciated!
Many Thanks, Mark.
-----------------------------------------------
wizardpage1.jsp:
<html:html>
<head>
<title><bean:message key="WizardPage1.title"/></title>
<html:base/>
</head>
<body bgcolor="white">
<logic:messagesPresent>
<bean:message key="WizardForm.validation.errors.header"/>
<ul>
<html:messages id="error">
<li><bean:write name="error"/></li>
</html:messages>
</ul><hr>
</logic:messagesPresent>
<html:form action="/WizardPage1Submit" focus="firstName">
<html:hidden property="page" value="1"/>
<TABLE border="0" width="100%">
<TR>
<TH align="right"><bean:message
key="WizardForm.firstName.displayname"/>:</TH>
<TD align="left"><html:text property="firstName"/></TD>
</TR>
<TABLE align=center>
<P>
<HR>
<TR>
<TR align="left">
<TD align="left"><html:cancel property="cancel" value="Cancel"/></TD>
<TD align="right"><html:submit value="Finish"/></TD>
</TR>
<TR align="right">
<TD align="left"><html:cancel property="back" value="Back"/></TD>
<TD align="right"><html:submit value="Next"/></TD>
</TR>
</TABLE>
</TABLE>
</html:form>
</body>
---------------------------------------------------
-----Original Message-----
From: Matt Bathje [mailto:[EMAIL PROTECTED]
Sent: 29 September 2004 15:23
To: Struts Users Mailing List
Subject: Re: Problems with Multi Page (wizard) Validation using
DynaValidatorForm and the "page=" attribute
Mark - not sure if this is your problem, but based on what you pasted in
here, your JSP page is missing an <html:form element. I'm going to
assume you snipped a bit more than what you said, but just in case...
All of your code seems correct to me. The only other thing I think could
possibly be wrong is if you have a separate "loader" action for your
page 1 form, and that has the scope set to request instead of session.
Sorry I wasn't more help, but figured some ideas are better than none.
Matt
Mark Songhurst wrote:
> Hi!
>
> I'm having great pains getting DynaValidatorForm to validate only the
> "page=" attributed field elements in my validation.xml file.
>
> It's the usual scenario: one DynaValidatorForm which is completed over
> several JSP pages.
> I want validation to occur as each page is submitted, using the
> Validator plugin.
>
> However I receive the following NullPointerException when I submit the
> first page of my wizard:
>
> 2004-09-29 14:30:28 StandardWrapperValve[action]: Servlet.service()
for
> servlet action threw exception
> java.lang.NullPointerException
> at
>
org.apache.struts.validator.DynaValidatorForm.setPageFromDynaProperty(Dy
> naValidatorForm.java:142)
> at
>
org.apache.struts.validator.DynaValidatorForm.validate(DynaValidatorForm
> .java:99)
> at
>
org.apache.struts.action.RequestProcessor.processValidate(RequestProcess
> or.java:921)
> at
>
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:
> 206)
> at
>
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
> at
> org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
> at
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
> at
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> at
>
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
> tionFilterChain.java:237)
> {snip}
>
> I am only attempting to get server side validation working at the
> moment. My browser has JavaScript disabled.
> I'm using Struts 1.2.4, I've not attempted to try this with Struts 1.1
>
> I've added what I think are the relevant code snippets to the bottom
of
> this mail - longer snippets are available if needed!
>
> Please could anyone help, or point me to an online working example
(with
> source!) that can get me past my problems?
>
> Many Thanks in Advance,
>
> Mark.
>
>
>
>
> ---------------------------------------------------
> struts-config.xml:
>
> <form-beans>
>
> <!-- WizardForm form bean -->
> <form-bean name="WizardForm"
> type="org.apache.struts.validator.DynaValidatorForm">
> <form-property name="page" type="java.lang.Integer"/>
> <form-property name="firstName" type="java.lang.String"/>
> {snip}
>
> <!-- WizardPage1Submit -->
> <action path="/WizardPage1Submit"
> type="com.messagelabs.wizard.WizardBaseAction"
> name="WizardForm"
> input="/WEB-INF/web/WizardPage1.jsp"
> scope="session"
> validate="true">
> <forward name="success" path="/WEB-INF/web/WizardPage2.jsp"/>
> </action>
>
> {snip}
> ---------------------------------------------------
>
> ---------------------------------------------------
> validation.xml:
>
> <formset>
> <form name="WizardForm">
> <field property="firstName"
> depends="required,maxlength"
> page="1">
> <arg0 key="WizardForm.firstName.displayname"/>
> <arg1 key="${var:maxlength}" name="maxlength"
> resource="false"/>
> <var>
> <var-name>maxlength</var-name>
> <var-value>64</var-value>
> </var>
> </field>
> {snip}
> ---------------------------------------------------
>
> ---------------------------------------------------
> wizardpage1.jsp:
>
> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
> <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
> <%@ taglib uri="/tags/struts-html" prefix="html" %>
> <%@ taglib uri="/tags/struts-logic" prefix="logic" %>
>
> <html:html>
> <head>
> <title><bean:message key="WizardPage1.title"/></title>
> <html:base/>
> </head>
> <body bgcolor="white">
>
> <html:hidden property="page" value="1"/>
>
> {snip}
> ---------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]