Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2007

Tip: Looking for answers? Try searching our database.

JSTL - number of elements in list

Thread view: 
Christine Mayer - 11 Oct 2007 13:10 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 -

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/>



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.