You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Graham <dg...@hotmail.com> on 2002/10/30 17:13:49 UTC

[OT] Getting a Collection's size in JSTL

Sorry for the OT post but the java forum was unresponsive.  How do you get 
the size of a collection class in the JSTL EL?

You can do it with jsp expressions like:
<%= collection.size() %>

but I want to do something like

<c:if test="${collection.size > 0}">

I've tried every variation on that syntax that I could think of.

Thanks,
David





_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [OT] Getting a Collection's size in JSTL

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 30 Oct 2002, David Graham wrote:

> Date: Wed, 30 Oct 2002 09:13:49 -0700
> From: David Graham <dg...@hotmail.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: struts-user@jakarta.apache.org
> Subject: [OT] Getting a Collection's size in JSTL
>
> Sorry for the OT post but the java forum was unresponsive.  How do you get
> the size of a collection class in the JSTL EL?
>
> You can do it with jsp expressions like:
> <%= collection.size() %>
>
> but I want to do something like
>
> <c:if test="${collection.size > 0}">
>

This does not work because the size() method does not follow the naming
pattern required for JavaBean properties (where it would be getSize()).

One option would be to make yourself a subclass of things like ArrayList
that simply delegated everything, but added a getSize() method that calls
size() under the covers.

> I've tried every variation on that syntax that I could think of.
>
> Thanks,
> David
>

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>