struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ranj Nadarajah" <>
Subject Struts Validation Question
Date Mon, 02 Jun 2003 14:03:28 GMT
I've been trying to make validator work with our application.  However, I've 
not been
very successful.  Here is what I did.  Please let me know if I missed 

I've created a form with firstName and LastName fields.  The validator 
see if that the form is not empty.  Howver, when I don't fill in and submit, 
I get
to the next page.  I don't see the validator checking for errors and 
I followed the guidelines in

1) Put the commons-validator.jar,jakarta-oro.jar and the struts.jar in the 
lib folder
2) Put the validator-rules.xml file in the web-inf directory.
3) created the validator.xml file in the web-inf directory and put the 
following in the
validation.xml file:


    <!-- ========== Default Language Form Definitions ===================== 

      <form  name="com.gdm.form.FBOrder">

         <field  property="firstName"
         	     <arg0 key="orderForm.firstname.displayname"/>
                 <arg1 name="minlength" key="${var:minlength}" 




4) Created the ActionForm class and extended it from validator.form

5) Called the ((FBOrder)form).validate(..) method from the action class

6) Created the following code in struts-config.xml

  <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
      property="pathnames" vaue="/WEB-INF/validator-rules.xml, 
/WEB-INF/validation.xml" />

7) put the following code in the jsp page.

<bean:message key="errors.header"/>
    <html:messages id="error">
      <li><bean:write name="error"/></li>

7) Put the following in the file.

# Errors
errors.header=<h3><font color="red">Validation Error</font></h3>You
correct the following error(s) before proceeding:
errors.ioException=I/O exception rendering error messages: {0}
error.database.missing=<li>User database is missing, cannot validate logon 
errors.required={0} is required.
errors.minlength={0} can not be less than {1} characters.
errors.maxlength={0} can not be greater than {1} characters.
errors.invalid={0} is invalid.

errors.byte={0} must be an byte.
errors.short={0} must be an short.
errors.integer={0} must be an integer.
errors.long={0} must be an long.
errors.float={0} must be an float.
errors.double={0} must be an double.{0} is not a date.

errors.range={0} is not in the range {1} through {2}.{0} is not a valid credit card number.{0} is an invalid e-mail address.

#Order Form
orderForm.firstname.displayname=First Name
orderForm.lastname.displayname=Last Name

Help STOP SPAM with the new MSN 8 and get 2 months FREE*

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message