struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Rank <ericr...@lo-fi.net>
Subject Re: FieldExpressionValidator: How do I reference field names?
Date Wed, 18 Jul 2007 20:57:09 GMT
Hi Matt,

I've used the fieldexpression validator with some success. I use the  
<param name="expression"> element. I would have written the validator  
as follows:


<field name="friendEmail">
    <field-validator type="fieldexpression">
       <param name="expression"><![CDATA[ reason == 'friend' &&  
reasonEmail != null ]]></param>
       <message>Please provide your friend's email</message>
    </field-validator>
</field>

It's unrelated to your probblem directly, but I DO wish that the  
validation framework would allow a sort of inverse short circuiting.  
In some cases, if one field-validator passes, it would be nice to  
skip the others.

Eric Rank


On Jul 18, 2007, at 11:38 AM, mraible wrote:

>
> I'm trying to use a FieldExpressionValidator (or  
> ExpressionValidator) to
> compare fields. Unfortunately, it doesn't seem to be working. I  
> have a radio
> button (named "reason") and a text field named "friendEmail". If the
> selected radio has a reason of "friend", I want to require the text  
> field.
> However, the expression "reason.equals('friend') and friendEmail ==  
> null"
> doesn't seem to work. Is this expression syntax correct, or do I  
> have to do
> something additional to get a handle on the "reason" and "friendEmail"
> values?
>
>     <field name="reason">
>         <field-validator type="requiredstring">
>             true
>             <message">Reason is a required field.</message>
>         </field-validator>
>     </field>
>
>     <validator type="fieldexpression">
>         friendEmail
>         reason.equals('friend') and friendEmail == null
>         <message>Please provide your friend's email</message>
>     </validator>
>
> I've also tried the following, but no dice:
>
>     <field name="friendEmail">
>         <field-validator type="fieldexpression">
>             reason.equals('friend')
>             <message>Please provide your friend's email</message>
>         </field-validator>
>     </field>
>
> Thanks,
>
> Matt
> -- 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message