Just to follow up, I've created my own custom FieldExpressionValidator to get
my desired behavior. The code is below in case anyone wants to use it.
Here's how:
1. Create a validators.xml in your WEB-INF/classes (or src/main/resources
for M2) to override the "fieldexpression" validator:
http://w
--- mraible <[EMAIL PROTECTED]> wrote:
> The following expression seems to do the trick:
> reason != 'friend' or (reason == 'friend' and
friendEmail != '')
>
> Writing it in Java seems more logical:
>
> public void validate() {
> if (reason != null && reason.equals("friend") &&
friendEmail.eq
The following expression seems to do the trick:
reason != 'friend' or (reason == 'friend' and friendEmail != '')
However, this doesn't seem very intuitive, does it? Writing it in Java seems
more logical:
public void validate() {
if (reason != null && reason.equals("friend") && friendEmail
I wish the solution was that easy - I tried your expression below and still
no dice. Maybe it's something so small I can't see it? Does it have
something to do with the fact that "reason" is a radio button that sets a
String value?
Matt
Eric Rank-2 wrote:
>
> Hi Matt,
>
> I tried out your sce
My Bad, there's another scenario when this field will validate. When
reason != 'friend'
Better expression:
(reason != 'friend') or ((reason ==
'friend') and (friendEmail != null) and (friendEmail.trim().size() >
0))
Eric
On Jul 19, 2007, at 1:33 PM, Eric Rank wrote:
Hi Matt,
I trie
Hi Matt,
I tried out your scenario, and I think I found the problem. In my
test, it also validated when I left the friendEmail field blank. It
seems that the value of friendEmail is not null, but an empty string.
To solve the problem, I added another clause to check for String
length. Aft
If you're right, I'd expect the following expression make friendEmail
required when the "friend" reason is checked (it's a radio button):
reason == 'friend' and friendEmail != null
However, if I check friend and don't fill out the e-mail address, it still
passes validation. Based on the error m
Ah beautiful, I like the "in" better (the types are enums), maybe I should
finally look at the OGNL documentation :)
musachy
On 7/18/07, cilquirm <[EMAIL PROTECTED]> wrote:
That's a mouthful.
OGNL does have an 'in' operator
customer.creditCards[0].type in [ 'AMERICAN_EXPRESS', 'VISA', 'DIS
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, y
Ding!
musachy
On 7/18/07, Eric Rank <[EMAIL PROTECTED]> wrote:
At risk of pointing out the obvious, I notice is that your expression
validates when:
1. reason is "friend"
2. and when friendEmail is null
I'm guessing that you want it to successfully validate when
1. reason equals "friend"
2.
At risk of pointing out the obvious, I notice is that your expression
validates when:
1. reason is "friend"
2. and when friendEmail is null
I'm guessing that you want it to successfully validate when
1. reason equals "friend"
2. And when friendEmail IS NOT null
Could that be the problem?
I
Looks ok, here is one that I have:
'AMERICAN_EXPRESS'.equals(customer.creditCards
[0].type.toString())
|| 'VISA'.equals(customer.creditCards[0].type.toString())
|| 'DISCOVER'.equals(customer.creditCards
[0].type.toString())
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:
>
>
>
> true
> Reason is required.
>
>
>
>
>
> frien
Looks like Nabble was escaping my HTML - let's try again with HTML Format
checked:
true
Reason is required.
friendEmail
reason.equals('friend') and friendEmail == null
Please provide your friend's email
Hi Matt,
I've used the fieldexpression validator with some success. I use the
element. I would have written the validator
as follows:
Please provide your friend's email
It's unrelated to your probblem directly, but I DO wish that the
validation framework would a
I've read this like 10 times just to make sure I'm not missing something,
but:
friendEmail
reason.equals('friend') and friendEmail == null
Please provide your friend's email
why is "friendEmail" in the expression?(should be " reason.equals('friend')
and friendEmail == null
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.
Howe
17 matches
Mail list logo