Looks to me like validwhen is working correctly. When you enter an "id" then
the last name validation will always fail because id is not null. Don't you
need something like the following:

1) On the "id" field check that either an "id" or "last name" have been
entered:

<field property="id" depends="validwhen>
    <var-value>((*this* != null) or (lastName != null))</var-value>
   <msg name="validwhen" key="errors.validwhen.id"/>
</field>


where..
errors.validwhen.id=Either an id or last name must be entered

2) On the "last name" field check that its either an "id" or "last name"
have been entered:

<field property="lastName" depends="validwhen>
    <var-value>((*this* == null) or ((*this* != null) and (id ==
null)))</var-value>
   <msg name="validwhen" key="errors.validwhen.lastName"/>
</field>

where..
errors.validwhen.lastName=Can't enter both a last name and id

Niall

----- Original Message ----- 
From: "Daniel Kalcevich" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Thursday, October 21, 2004 4:10 PM
Subject: RE: Struts Validator - ValidWhen


I have upgraded to 1.2.4 and the problem still exists.  I swapped out
the .jar files, the .tld files, and verified that the .xml files were
using the correct dtd.  Any other ideas about what I might be able to
check?  Thanks.

Daniel


-----Original Message-----
From: Niall Pemberton [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 20, 2004 6:33 PM
To: Struts Users Mailing List
Subject: Re: Struts Validator - ValidWhen

Version 1.2.1 of  Struts had problems and never made "ga" release
quality -
the only "ga" release for Struts 1.2 is Version 1.2.4 - some validwhen
issues were fixed in that release.

http://struts.apache.org/acquiring.html

Niall

----- Original Message ----- 
From: "Daniel Kalcevich" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, October 20, 2004 8:10 PM
Subject: Struts Validator - ValidWhen


Hello,

I have a form that contains two fields:  id & lastName.  The rule is
that if I can only enter in one or the other, not both.  I am trying to
use the ValidWhen to perform this check.  I have code similar to the
following:

<form name="searchForm">
            <field
                property="id"
                depends="validwhen,minlength,mask,validateId">
                <msg name="minlength"
key="errors.policyNumber.length"/>
                <msg name="mask"
key="errors.policyNumber.mask"/>
                    <arg0
key="searchForm.policyNumberRequired"/>
                    <arg1 name="minlength"
key="${var:minlength}" resource="false"/>
                    <var>
                              <var-name>test</var-name>
                              <var-value>((lastName == null) and (*this*
!= null))</var-value>
                            </var>
                    <var>
                       <var-name>minlength</var-name>
                       <var-value>10</var-value>
                    </var>
                    <var>
                        <var-name>mask</var-name>
                        <var-value>^[a-zA-Z0-9]*$</var-value>
                    </var>
             </field>

             <field
                property="lastName" depends="validwhen">
                <msg name="validwhen"
key="errors.lastName.entry"/>
                            <var>
                              <var-name>test</var-name>
                              <var-value>((id == null) and (*this* !=
null))</var-value>
                            </var>
            </field>

         </form>

When I enter in only a value into the "id" field, I still get the
message "Please enter a last name".  That message is the key
"errors.lastName.entry".  Any ideas on what else I need to do to get
this working?  I am using version 1.2.1.  Thanks in advance.

-Daniel


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


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