Jen,

DynaValidatorForm ALREADY has a page field so leave it out:

http://struts.apache.org/api/org/apache/struts/validator/DynaValidatorForm.h
tml

As for your validation not working with "pg" that's because the validator
uses the field name "page" to figure out which validations to test in
multi-page validations.

Additionally, WHY are you requiring a page field in your formset?  It should
be a hidden variable out of the view of the user so there is no need to
validate it.  Without it, the plugIn should assume page=0 and do the most
basic of validations in your formset.

Regards,
David

-----Original Message-----
From: Caroline Jen [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 22, 2004 4:16 PM
To: Struts Users Mailing List
Subject: Re: What Are the Causes For Validation to Throw
ClassCastException?


I have changed the property from 'page' to 'pg'.  The
ClassCastException problem is gone.  However, the
validation.xml that I put in the AppName/WEB-INF is
not doing anything.

In my action mapping (struts-config.xml), I did set

        validate="true"

and in my validation.xml, I have "required" set for
the depends attribute for every single text field.

            depends="required"

I intentionally left every field in those forms blank
and submit forms.  But, the Struts did not give me any
warning about that I leave text fields blank.


--- Matt Bathje <[EMAIL PROTECTED]> wrote:

> Caroline Jen wrote:
>
> > Do not understand the 'HTTP Status 500 -
> > java.lang.ClassCastException
> >
>
org.apache.struts.validator.DynaValidatorForm.validate(DynaValidatorForm.jav
a:141)'
> >
> >
> > 1. I have this plug-in by the very end of the
> > struts-config.xml file:
> >
> > <plug-in
> >
>
className="org.apache.struts.validator.ValidatorPlugIn">
> >    <set-property
> >        property="pathnames"
> >
> >
>
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
> > </plug-in>
> >
> > 2. I have this action mapping in the
> struts-config.xml
> > file:
> >
> >     <action
> >         path="/content/UpdateTitle"
> >         type="org.dhsinfo.content.doSomething1"
> >         name="editTitleForm"
> >         scope="request"
> >         validate="true"
> >         input=".frame.content">
> >        <forward
> >            name="success"
> >            path=".title.Confirmation"/>
> >     </action>
> >
> > 3. I have this <form-bean> inside the <form-beans>
> > element in the struts-config.xml file:
> >
> >      <form-bean
> >         name="editTitleForm"
> >
> >
>
type="org.apache.struts.validator.DynaValidatorForm">
> >           <form-property
> >             name="page"
> >             type="java.lang.String"/>
> >           <form-property
> >             name="title"
> >             type="java.lang.String"/>
> >      </form-bean>
> >
> > 4. I have the validation.xml file in the
> > AppName/WEB-INF directory
> >
> > 4.1. I changed the beginning of the validation.xml
> > file to
> >
>
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd";
> > ):
> >
> > 4.2 my validation.xml file code is shown below
> >
> > I got the HTTP Status 500 -
> > Servlet.service() for servlet action threw
> exception
> >
> > java.lang.ClassCastException
> >
>
org.apache.struts.validator.DynaValidatorForm.validate(DynaValidatorForm.jav
a:141)
> >
> > code:
> >
> > <?xml version="1.0" encoding="ISO-8859-1" ?>
> >
> > <!DOCTYPE form-validation PUBLIC
> >           "-//Apache Software Foundation//DTD
> Commons
> > Validator Rules Configuration 1.0//EN"
> >
> >
>
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd";>
> > <form-validation>
> >    <global>
> >       <constant>
> >          <constant-name>postalCode</constant-name>
> >
> <constant-value>^\d{5}\d*$</constant-value>
> >       </constant>
> >    </global>
> >
> >   <formset>
> >
> >       <form name="editTitleForm">
> >          <field
> >             property="page"
> >             depends="required">
> >                <arg0 key="request.page"/>
> >          </field>
> >          <field
> >             property="title"
> >             depends="required">
> >                <arg0 key="insert.title"/>
> >          </field>
> >       </form>
> >    </formset>
> > </form-validation>
> >
>
>
> It appears as though the problem is with your use of
> a form-property
> called "page" - based on what I am seeing around
> line 141 of the
> DynaValidatorForm code, if you have a property named
> page, it MUST be an
> integer, otherwise classcastexception is thrown.
>
> I'm guessing this is to accomodate "paged" forms
> (aka wizards)
>
> Try changing the property to have another name, and
> I think it will fix
> your problem.
>
>
> Matt
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
>
>




_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

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


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

Reply via email to