Thanks Wendy. I am trying to validate an array of ints.

The following should be true:

1. The array is not null. 
2. The first value in its index should be higher than 0.
3. If the first value is 0 then its length must be greater than 2.

The following validation failed miserably:


  <field property="roleIds" depends="validwhen">
             <arg0 key="lms.role"/>
              <var>
      <var-name>test</var-name>
      <var-value> ((roleIds != null) or ( ( (roleIds[0] == -1) and
(roleIds.length > 1 ) ) or  ( roleIds[0] > 0 ) ) )</var-value>
    </var>
   </field>  
  


Thanks.

Chetan

-----Original Message-----
From: Wendy Smoak [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 27, 2006 12:15 PM
To: Struts Users Mailing List
Subject: Re: How to validate an integer array

On 9/26/06, Chetan Pandey <[EMAIL PROTECTED]> wrote:

> In my form I have
> Int [] roleIds = null.
> This is used as the Underlying Datatype of a multiple-select Drop-down.
> Everything works fine but I am not sure how to validate?
> The following that I tried did not work:
> <field property="roleIds" depends="validwhen">
>              <arg0 key="lms.role"/>
>               <var>
>       <var-name>test</var-name>
>       <var-value> (*this* != 0)</var-value>
>     </var>
>    </field>

I think validwhen only works with String and Integer.  Here's the
ANTLR grammar file:
http://svn.apache.org/repos/asf/struts/struts1/trunk/core/src/main/java/org/
apache/struts/validator/validwhen/ValidWhenParser.g

What are you trying to validate?  Generally, validwhen is used when
validation for one field depends on the value of some other field.

Also, there may be some problems with validwhen and arrays, Google
turned up a couple of mailing list threads and a JIRA issue
(STR-2802).

-- 
Wendy

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






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

Reply via email to