You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Daniel Kalcevich <DK...@mercuryinsurance.com> on 2004/10/20 21:10:23 UTC
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts Validator - ValidWhen
Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
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" <DK...@mercuryinsurance.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org