The condition you have specified means that addressLine1 is only valid when
everything is not null. Thats why you always get the error - you need an OR
condition. In order to get appropriate "required" messages for the various
fields, how about something along the following lines....

<field property="addressLine1">
    <var> <var-name>test</var-name>
        <var-value>( (this != null) OR (
              (addressLine2 == null) AND
              ((city == null) AND
              ((state == null) AND
              ((zip == null) AND
              ((zip4 == null) AND
              (country == null))))))
        </var-value>
    </var>
</field>
<field property="city">
    <var> <var-name>test</var-name>
        <var-value>((this != null) OR (addressLine1 == null))</var-value>
    </var>
</field>
<field property="state">
    <var> <var-name>test</var-name>
        <var-value>((this != null) OR (addressLine1 == null))</var-value>
    </var>
</field>
<field property="zip">
    <var> <var-name>test</var-name>
        <var-value>((this != null) OR (addressLine1 == null))</var-value>
    </var>
</field>
<field property="country">
    <var> <var-name>test</var-name>
        <var-value>((this != null) OR (addressLine1 == null))</var-value>
    </var>
</field>

Niall

----- Original Message ----- 
From: "Todd Nine" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <user@struts.apache.org>
Sent: Friday, February 25, 2005 7:21 PM
Subject: Complex Validation with validwhen and large condition


> Hi all,
>    I'm having some issues getting validwhen to perform the way I want
> it to.  I would like the following general functionality.
>
> 1. The user can input an aseAddress.
> 2. The address as a whole is nullable, however if they fill in any of
> the fields, they must filling ALL of the address fields.
>
> Here are my properties
>
> aseAddress.addressLine1
> aseAddress.addressLine2
> aseAddress.city
> aseAddress.state
> aseAddress.zip
> aseAddress.zip4
> aseAddress.country
>
>
> addressLine2 and zip4 are not required.  However, if any field in the
> list above contains data, then all of the fields except for
> addressLine2 and zip4 are required.
>
> Here is an example contition I have tried, but I contantly get that
> the fields are required, even when they are all empty.  If anyone who
> has a better way, please let me know.
>
>
>
> <field property="aseAddress.addressLine1" depends="validwhen, mask">
> <arg0 key="prompt.common.addressLine1" />
> <var>
> <var-name>mask</var-name>
> <var-value>${allvalid}</var-value>
> </var>
> <var>
> <var-name>test</var-name>
> <var-value>
> (
> (
> (
> (
> (
> (
> (*this* != null)
> and (aseAddress.addressLine2 != null)
> ) and (aseAddress.city != null)
> ) and (aseAddress.state != null)
> ) and (aseAddress.postalCode4 != null)
> ) and (aseAddress.country != null)
> ) and (aseAddress.postalCode != null)
> )
> </var-value>
> </var>
> </field>



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

Reply via email to