I used the struts validator CheckFields. 

Here is the entries in validation.xml

<formset>
        <form name="bookForm">
            <field property="title" depends="required">
                    <arg0 key="bookForm.title"/>
             </field>
          </form>
    </formset> 


Here is the entries in validation-rules.xml

<validator name="required"
            classname="org.apache.struts.validator.FieldChecks"
               method="validateRequired"
               methodParams="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionErrors,
                       javax.servlet.http.HttpServletRequest"
                  msg="errors.required">
</validator>

The FieldChecks is the struts default validator for required field.

Thanks.


-----Original Message-----
From: Mark Galbreath [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 13, 2003 1:05 PM
To: 'Struts Users Mailing List'
Subject: RE: error page


My first thought is that if you are testing for null, you will never trap an
error.  Form objects are passed as Strings - empty or not.  Test for
titleField.length() > 0 rather than != null.

Mark

-----Original Message-----
From: Zhang, Larry (L.) [mailto:[EMAIL PROTECTED]] 
Sent: Monday, January 13, 2003 12:37 PM

I am using struts 1.1b3. When the validation fails, the error can be shown
on the page using <html:errors>. Now I have an action form page(say
book.jsp, on this page there is a  required field-- book title), I want an
error.jsp, when the validation (example, title field is null) fails, the
error page is invoked. 

I tried to define a <forward> attribute in struts-config.xml and put the
target of it as the error.jsp, but struts still shows the action form page
(book.jsp) when validation fails. However, when validation passes, the
error.jsp is invoked correctly.



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

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

Reply via email to