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 only point it out because the backwards logic involved with validators has bitten me in the past. I always have to remind myself that my validators test for things that I want, not for things that will cause failure.

Eric Rank




On Jul 18, 2007, at 3:08 PM, mraible 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]



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

Reply via email to