You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Alexandre Torres <al...@gmail.com> on 2005/04/19 14:43:46 UTC

commons validator: rule for array

Hi. I'm using commons validator with struts.
I have a component with class FormA that has a set of components of
class RowB. Something like

FormA {
   public String getCode() {
   }
   public void setCode() {
   }
   public Vector getRows() {
...
   }
   public void setRows(Vector v) {
...
   }
}

RowB {
   public String getName() {
   }
   public void setName(String n) {
     ...
   }
}

I want to define a rule in validator where all "name" instances of
RowB should be required.
For FormA's property "code" I did:
..
      <field property="code" depends="required">
        <arg key="forma.code.displayname" />
      </field>
..
But , for RowB I could not figure out how to make it, since I may have
zero, one or more RowB values... I see in the example this:

      <field property="rows.name[0]" depends="required">
        <arg key="forma.row.name.displayname" />
      </field>
That validates only the first name in the set right ?
But if I have more than one name , what do I do ?

Thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: commons validator: rule for array

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
You can use the indexedListProperty to do this. In your validation.xml you
would have something like the following...

      <field property="name" indexedListProperty="rows" depends="required">
        <arg key="forma.row.name.displayname" />
      </field>


Niall

----- Original Message ----- 
From: "Alexandre Torres" <al...@gmail.com>
To: <co...@jakarta.apache.org>
Sent: Tuesday, April 19, 2005 1:43 PM
Subject: commons validator: rule for array


Hi. I'm using commons validator with struts.
I have a component with class FormA that has a set of components of
class RowB. Something like

FormA {
   public String getCode() {
   }
   public void setCode() {
   }
   public Vector getRows() {
...
   }
   public void setRows(Vector v) {
...
   }
}

RowB {
   public String getName() {
   }
   public void setName(String n) {
     ...
   }
}

I want to define a rule in validator where all "name" instances of
RowB should be required.
For FormA's property "code" I did:
..
      <field property="code" depends="required">
        <arg key="forma.code.displayname" />
      </field>
..
But , for RowB I could not figure out how to make it, since I may have
zero, one or more RowB values... I see in the example this:

      <field property="rows.name[0]" depends="required">
        <arg key="forma.row.name.displayname" />
      </field>
That validates only the first name in the set right ?
But if I have more than one name , what do I do ?

Thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org