Rather than use the validation framework, I'd probably go with a
Validate method (by implementing Validatable).

Then, instead of using an OGNL expression, you can loop through the
list using Java, and call addFieldError if there's a problem.

Alternatively, a custom type converter that turned the nulls into
false booleans might work, or there might be another way to form the
OGNL expression. But given the choice between OGNL and Java, I'll take
Java. :)

HTH, Ted
<http://www.StrutsMentor.com/>

On Jan 8, 2008 8:08 AM, Martin Braure de Calignon <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I'm currently using struts2 for a project.
> I want to validate all elements of a list (each elements should have a
> non-empty value, or the list should be empty).
>
> what I have done in my validator is :
> <!-- correct doctype above and some field-validator-->
>
> <validator type="expression">
>         <param name="expression">
>                 <![CDATA[
>
>                 ((myList.isEmpty) || (myList{? #this.value != null}.size ==
> myList.size))
>                 ]]>
>         </param>
>         <message>error ${myList.size}</message>
> </validator>
> <!-- correct end of file below this line -->
>
> Then in console I have a warning, and the validator does not do what I
> want.
>         WARN - Got result of null when trying to get Boolean
> I don't know if it is related to my validator but it seems to be.
>
> Any idea on how writing validator on all elements of the list ?
>
> Thanks :-)
> --
> Martin Braure de Calignon

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

Reply via email to