You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mark Songhurst <ms...@messagelabs.com> on 2004/09/29 15:32:21 UTC

Problems with Multi Page (wizard) Validation using DynaValidatorForm and the "page=" attribute

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}
---------------------------------------------------



______________________________________________________________________
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problems with Multi Page (wizard) Validation using DynaValidatorForm and the "page=" attribute

Posted by Matt Bathje <mp...@ntsource.com>.
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org