Hi All,
   I am having trouble getting my mind around the boolean expression
semantics of the validwhen validator.  Consider the following example.

I have a form with two possible input groups depending on the user
selection.  If the entity is an individual, then I need to require
firstName etc.  If the entity is a business then I need to require a
business name.  Below is my validation code.

<field property="firstName" depends="validwhen, mask">
        <arg0 key="prompt.common.firstName" />
        <var>
                <var-name>mask</var-name>
                <var-value>${alphaname}</var-value>
        </var>
        <var>
                <var-name>test</var-name>
                <var-value>(entityType == "individual")</var-value>
        </var>
</field>

<field property="lastName" depends="validwhen, mask">
        <arg0 key="prompt.common.lastName" />
        <var>
                <var-name>mask</var-name>
                <var-value>${alphaname}</var-value>
        </var>
        <var>
                <var-name>test</var-name>
                <var-value>(entityType == "individual")</var-value>
        </var>
</field>

<field property="ssn" depends="validwhen, mask">
        <arg0 key="prompt.common.ssn" />
        <arg1 key="prompt.common.ssn.format" />
        <var>
                <var-name>mask</var-name>
                <var-value>${ssn}</var-value>
        </var>
        <var>
                <var-name>test</var-name>
                <var-value>(entityType == "individual")</var-value>
        </var>
</field>

<field property="birthDate" depends="validwhen, date">
        <arg0 key="prompt.common.birthDate" />
        <var>
                <var-name>datePatternStrict</var-name>
                <var-value>${date}</var-value>
        </var>
        <var>
                <var-name>test</var-name>
                <var-value>(entityType == "individual")</var-value>
        </var>
</field>

<field property="businessName" depends="validwhen, mask">
        <arg0 key="prompt.common.businessName" />
        <var>
                <var-name>mask</var-name>
                <var-value>${alphaname}</var-value>
        </var>
        <var>
                <var-name>test</var-name>
                <var-value>(entityType == "business")</var-value>
        </var>
</field>


However when "business" is the entityType, firstName, lastName, ssn,
and birthDate show up as required in the error messages.  When the
entityType is "individual" businessName shows up.  I thought that the
value was reversed in the jsp, hence reversing it when it is being set
into the form.  I debugged the validate method and the enityType is
being set correctly.  This operand seems sufficient to work correctly.
 However changing all of the == to != seems counterintuitive to me. 
It seems to me that my logic should work.  {firstName} is required
when {entityType} == "individual".  Can someone explain the semantics
of the need to negate all of the expressions?

Thanks,
Todd

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

Reply via email to