This has been discussed numerous times on this list.

The EL can reference javabean properties, and elements of collections
and maps.  That's it.  The length of a collection is not a javabean
property.

It's straightforward to implement a simple class called "CollectionBean"
(and "MapBean") that is constructed with a collection (or map), which
has two javabean properties, being "collection" and "size".  You would
do this setup outside of your JSP page, in your "prepare" servlets or
actions.

> -----Original Message-----
> From: Sgarlata Matt [mailto:[EMAIL PROTECTED]
> 
> Does anyone know how to get the length of a collection using the EL?
I am
> trying to do one of the tests below.  Note that "children" is a List.
> 
> <c:if test="${component.parentDao.children.length > 1}">
> <!-- stuff here -->
> </c:if>
> 
> or
> 
> <c:if test="${component.parentDao.children.size > 1}">
> <!-- stuff here -->
> </c:if>
> 
> And get this error:
> 
> javax.servlet.jsp.JspException: An error occurred while evaluating
custom
> action attribute "test" with value
"${component.parentDao.children.length
> > 1}": The "." operator was supplied with an index value of type
> "java.lang.String" to be applied to a List or array, but that value
cannot
> be converted to an integer.
> 
> Thanks!
> 
> Matt

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

Reply via email to