tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Karr, David" <David.K...@wamu.net>
Subject RE: Length of collection using EL?
Date Tue, 22 Jul 2003 16:47:36 GMT
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:sgarlata_matt@bah.com]
> 
> 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: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Mime
View raw message