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 Thu, 19 Jul 2007 19:33:18 GMT
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. After that, it triggered the field error as desired. This is  
what worked for me.

<validators>
   <field name="friendEmail">
         <field-validator type="fieldexpression">
             <param name="expression">reason == 'friend' and  
friendEmail != null and friendEmail.trim().size() > 0</param>
             <message>Please provide your friend's email</message>
         </field-validator>
     </field>
</validators>


Eric.


On Jul 19, 2007, at 10:40 AM, mraible wrote:

> 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 message I'm getting in my  
> logs (see
> below), I'm guessing that I need to do some sort of "friendEmail !=  
> null"
> check, but I'm already doing that.


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


Mime
View raw message