I intentionally left every single field blank and
radio buttons not selected, and then submit the form
with validation check.  All the errors pass through
the validation check and the next page gets displayed.

I have commons-validator.jar (6/29/2003) in the
AppName/WEB-INF/lib directory.  And I have the
validation.xml and validator-rules.xml in my
AppName/WEB-INF directory.

I have a form like:

[CODE]
<html:form action="/message/SendMessage">
Message Type:

      <input type="radio" name="msgtype"
value="regular">Regular E-Mail</input>
      <input type="radio" name="msgtype"
value="wireless">Wireless Mail</input>

From:

      <html:text property="sender" size="82"
maxlength="25" tabindex="1"/>

To:
      <html:text property="receiver" size="82"
maxlength="25" tabindex="1"/>

*Subject:

      <html:text property="messageTopic" size="82"
maxlength="100" tabindex="3"/>

*Priority:

      <input type="radio" name="priority"
value="info">Information Only</input>
      <input type="radio" name="priority"
value="priority">High Priority</input>
      <input type="radio" name="priority"
value="action">Action Required</input>

*Distribution Restrictions:

      <input type="radio" name="distribution"
value="ok">OK to Distribute</input>
      <input type="radio" name="distribution"
value="no">No Re-distribution</input>
      <input type="radio" name="distribution"
value="lawonly">Distribute ONLY to XXXXXX</input>

*Message:

      <textarea name="messageBody" rows="15"
cols="62"></textarea>

      <html:submit accesskey="S">Send</html:submit>
      <html:submit accesskey="C">Clear</html:submit>
</html:form>
[/CODE]

My action mapping in the struts-config.xml looks like:

[CODE]
    <action
        path="/message/SendMessage"
        type="org.dhsinfo.message.SendMessage"
        name="messageForm"
        scope="request"
        validate="false"
        input=".message.Form">
       <forward
            name="success"
            path=".message.Confirmation"/>
    </action>
[/CODE]

The messageForm in the <form-beans> element of the
struts-config.xml looks like:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts
Configuration 1.1//EN"
         
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd";>

[CODE]
     <form-bean
        name="messageForm"
       
type="org.apache.struts.validator.DynaValidatorForm">
          <form-property
            name="msgtype"
            type="java.lang.String"/>
          <form-property
            name="sender"
            type="java.lang.String"/>
          <form-property
            name="receiver"
            type="java.lang.String"/>
          <form-property
            name="messageTopic"
            type="java.lang.String"/>
          <form-property
            name="priority"
            type="java.lang.String"/>
          <form-property
            name="distribution"
            type="java.lang.String"/>
          <form-property
            name="messageBody"
            type="java.lang.String"/>
      </form-bean>
[/CODE]

In the validation.xml:

<?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_0.dtd";>

and, inside the <formset> element, I have:

[CODE]
    <form name="messageForm">
         <field
            property="msgtype"
            depends="required">
               <arg0 key="message.type"/>
         </field>
         <field
            property="sender"
            depends="required">
               <arg0 key="message.sender"/>
         </field>
         <field
            property="receiver"
            depends="required">
               <arg0 key="message.receiver"/>
         </field>
         <field
            property="messageTopic"
            depends="required">
               <arg0 key="message.topic"/>
         </field>
         <field
            property="priority"
            depends="required">
               <arg0 key="message.priority"/>
         </field>
         <field
            property="distribution"
            depends="required">
               <arg0
key="message.distribution.restriction"/>
         </field>
         <field
            property="messageBody"
            depends="required">
               <arg0 key="message.body"/>
         </field>
      </form>
[/CODE]


                
_______________________________
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]

Reply via email to