Do you also have /AppName/WEB-INF/validator-rules.xml?
Without that the validation won't work. Also make sure that you have the proper version of the validator jar.


Assuming those things are correct, take a look through your tomcat logs, I bet you are actually getting an error of some sort.


Matt



Caroline Jen wrote:

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.java: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.java: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]



Reply via email to