Hi, using a tag library (preferably JSTL), I would like to print of
something, in case my list has a certain amount of elements -
I tried <c:if test="{myList.size > 10 }">, however this doesn't work,
as this results in myList.getSize() but the method's name is just
size().
Any idea how this can be done?
Thanks,
Christine
Tobi - 11 Oct 2007 20:29 GMT
> Hi, using a tag library (preferably JSTL), I would like to print of
> something, in case my list has a certain amount of elements -
[quoted text clipped - 8 lines]
>
> Christine
at http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSTL8.html I found:
Although the java.util.Collection interface defines a size method, it
does not conform to the JavaBeans component design pattern for
properties and so cannot be accessed via the JSP expression language.
The length function can be applied to any collection supported by the
c:forEach and returns the length of the collection. When applied to a
String, it returns the number of characters in the string.
HTH!
Tobi
Tobi - 11 Oct 2007 20:31 GMT
> > Hi, using a tag library (preferably JSTL), I would like to print of
> > something, in case my list has a certain amount of elements -
[quoted text clipped - 21 lines]
>
> Tobi
Also found:
<c:if test="${fn:length(myList) > 0}">
http://forum.java.sun.com/thread.jspa?threadID=511513&messageID=2431122
Daniel Pitts - 13 Oct 2007 18:26 GMT
> Hi, using a tag library (preferably JSTL), I would like to print of
> something, in case my list has a certain amount of elements -
[quoted text clipped - 4 lines]
>
> Any idea how this can be done?
<c:if test="${fn:length(myList) > 10}">
You'll need to import the function taglib, but it is part of the JSTL.

Signature
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>