Swing - 2004-07-24

Hi,

Can someone help me with the following simple validator
problem in Struts??

I have modified the simple logon application from the
book 'Struts in Action' to use validation framework.

Basically only 2 fields to validate in a form.
1 field named username, the other named password.
Both are required and have maximum length of 8.

The follwing is my validation.xml

<form-validation>
  <formset>
      <form name="logonForm">
          <field property="username" depends="required,maxlength">
    <msg name="required" key="error.username.required"/>
        <arg0 name="maxlength" key="Username" resource="false"/>
        <arg1 name="maxlength" key="${var:maxlength}" resource="false"/>
          <var>
    <var-name>maxlength</var-name>
    <var-value>8</var-value>
          </var>
         </field>
         <field property="password" depends="required,maxlength">
              <msg name="required" key="error.password.required"/>
              <arg0 name="maxlength" key="Password" resource="false"/>
              <arg1 name="maxlength" key="${var:maxlength}" resource="false"/>
         <var>                  
             <var-name>maxlength</var-name>
    <var-value>8</var-value>
         </var>
        </field>
      </form>
   </formset>
</form-validation>

---------------------

My application.properties file

error.username.required=Username is required
error.password.required=Password is required
errors.maxlength={0} can not be greater than {1} characters.

Problem:

    Scenarios

* Nothing on username and password fields
Works ok, got pop-up display:

        Username is required
        Password is required
       
* username: 123456789
  password:      // Nothing
 
  Got pop-up display:
 
  Username can not be greater than 8 characters.
      
  Why no message for password?? i.e. Password is required
 
* username:
  password: 1234567889
 
  Got pop-up display:
 
  Username can not be greater than 8 characters.

  Helloooooo? What about over sized password?
 
* username: 11
  password: 123456789
 
  Got server side validation message instead in browser instead of client side!!!
 
  Password can not be greater than 8 characters.
 
  Even though, username field validation passed, password field didn't. I wud expect a pop-up message in clien side validation.
  Why is this the case???

-----------

It doesn't look like client side validation can do both fields except in the first case where both fields are empty.

It seemed if username field pass 'required' and maxlength  validation, then validation passed to server side straight away. So ..

Is there something wrong with my validation.xml or is it normal??

Thanks