You know, the more I think about this, the more I think we've all  
been barking up the wrong tree.  When you have lists in your action  
bean (or domain model) the validations are applied individually to  
each element of the list as it gets bound.  So the expression would  
be evaluated against each item being put into the list.  And  
expression validation is only run /if/ there is a value to run it on.

So in short, I don't think this can be done with expression  
validation.  You'll have to resort to a validation method I think.

-t

On Apr 2, 2008, at 8:38 AM, Mathieu Avoine wrote:

> Thanks everyone for your answers.
>
> I think the problem may not be specifically with the expression I  
> use; whatever I put in there, it always passes. I
> simplified the @Validate annotation to frame the issue and even  
> with this it passes:
>
> @Validate(expression="1 == 0")
>
> Until recently, at least, 1 is not equal to 0 ;-)
>
> Any idea what I could be doing wrong?
>
> Thanks,
> Math
>
> Mathieu Avoine wrote:
>> Hi,
>>
>> I want to use annotation driven validation to validate that a  
>> property
>> of type List contains at least 1 item (i.e. mylist.size() > 0).
>>
>> I tried using required=true, because I would have expected the  
>> behavior
>> for a List object to check for the size, but it looks like it only
>> validates if the property is not null (am I right?). So I turned to
>> expressions, and put up this one:
>>
>> @ValidateNestedProperties({
>> @Validate(field="selectedIds", required=true,
>> on={"goToSelectVehicles","activate"}, expression="this != null &&
>> this.size > 0")
>> })
>> private PickList keys = null;
>>
>> Unfortunately, it doesn't work. So, my questions:
>>
>> 1) What am I doing wrong?
>> 2) Is there an attribute for the @Validate annotation to validate the
>> size of a List?
>>
>> Thanks!
>> Math
>>
>>
>> --------------------------------------------------------------------- 
>> ----
>> Check out the new SourceForge.net Marketplace.
>> It's the best place to buy or sell services for
>> just about anything Open Source.
>> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/ 
>> marketplace
>
>
> ---------------------------------------------------------------------- 
> ---
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/ 
> marketplace
> _______________________________________________
> Stripes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/stripes-users


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to