That's a mouthful.

OGNL does have an 'in' operator

customer.creditCards[0].type in [ 'AMERICAN_EXPRESS', 'VISA', 'DISCOVER' ,
'MASTERCARD']

note that you don't have to do toString() if type is already a string ;
ognl's equality operator ( == ) already uses equals.

If it's not of type String, you might try projection :

[ 'AMERICAN_EXPRESS', 'VISA', 'DISCOVER' , 'MASTERCARD'].{? #this.equals(
customer.creditCards[0].type ) }.size() > 0 
 



Musachy Barroso wrote:
> 
> Looks ok, here is one that I have:
> 
>     <field name="customer.creditCards[0].type">
>         <field-validator type="fieldexpression">
>             
>                 'AMERICAN_EXPRESS'.equals(customer.creditCards
> [0].type.toString())
>                 || 'VISA'.equals(customer.creditCards[0].type.toString())
>                 || 'DISCOVER'.equals(customer.creditCards
> [0].type.toString())
>                 || 'MASTERCARD'.equals(customer.creditCards
> [0].type.toString())
>             
>             <message>Credit Card Type must be American Express, Visa,
> MasterCard, Discover</message>
>         </field-validator>
>     </field>
> 
> //is ther an "in" operator in OGNL?
> 
> musachy
> 
> On 7/18/07, mraible <[EMAIL PROTECTED]> wrote:
>>
>>
>> That didn't work - how about this: http://rafb.net/p/cmnEKB18.html
>>
>>
>> mraible wrote:
>> >
>> > Looks like Nabble was escaping my HTML - let's try again with HTML
>> Format
>> > checked:
>> >
>> >     <field name="reason">
>> >         <field-validator type="requiredstring">
>> >             true
>> >             <message>Reason is required.</message>
>> >         </field-validator>
>> >     </field>
>> >
>> >     <!-- Plain validator syntax -->
>> >     <validator type="fieldexpression">
>> >         friendEmail
>> >         reason.equals('friend') and friendEmail == null
>> >         <message>Please provide your friend's email</message>
>> >     </validator>
>> >
>> >     <!-- Field validator syntax -->
>> >     <field name="friendEmail">
>> >         <field-validator type="fieldexpression">
>> >             reason.equals('friend') and friendEmail == null
>> >             <message>Please provide your friend's email</message>
>> >         </field-validator>
>> >     </field>
>> >
>> >
>> > Musachy Barroso wrote:
>> >>
>> >> I've read this like 10 times just to make sure I'm not missing
>> something,
>> >> but:
>> >>
>> >>  <validator type="fieldexpression">
>> >>        friendEmail
>> >>        reason.equals('friend') and friendEmail == null
>> >>        <message>Please provide your friend's email</message>
>> >>    </validator>
>> >>
>> >>
>> >> why is "friendEmail" in the expression?(should be "
>> >> reason.equals('friend')
>> >> and friendEmail == null" right?)
>> >>
>> >> musachy
>> >>
>> >> On 7/18/07, mraible <[EMAIL PROTECTED]> 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
>> >>> --
>> >>> View this message in context:
>> >>>
>> http://www.nabble.com/FieldExpressionValidator%3A-How-do-I-reference-field-names--tf4104715.html#a11673436
>> >>> Sent from the Struts - User mailing list archive at Nabble.com.
>> >>>
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >>> For additional commands, e-mail: [EMAIL PROTECTED]
>> >>>
>> >>>
>> >>
>> >>
>> >> --
>> >> "Hey you! Would you help me to carry the stone?" Pink Floyd
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/FieldExpressionValidator%3A-How-do-I-reference-field-names--tf4104715.html#a11677727
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> 
> -- 
> "Hey you! Would you help me to carry the stone?" Pink Floyd
> 
> 

-- 
View this message in context: 
http://www.nabble.com/FieldExpressionValidator%3A-How-do-I-reference-field-names--tf4104715.html#a11679100
Sent from the Struts - User mailing list archive at Nabble.com.


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

Reply via email to