• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

JSTL List count

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I can get the list count using <c:forEach> as follows,
<c:forEach items="${mylist}" var="km" varStatus="cnt">
List Count = ${cnt.count}
</c:forEach>
Is it possible that i can get this list count directly in the <c:if> test condition without iterating thru <c:forEach>

something like <c:if test="${mylist.count gt 0}"> No data found.. </c:if>

Appreciate your response on this.

Thanks & Regards,
Atul Samnerkar
 
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use the JSTL 'empty' operator to see if the collection is empty
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I think:

Will work just fine.

On second thought, this doesnt work its not getSize();

[ September 09, 2008: Message edited by: Anton Gerdessen ]
 
Author
Posts: 836
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The 'empty' operator is your best bet for comparing to 0. If you really want to get the size however, the JSTL EL function fn:length is your friend (e.g. see JSTL Functions).
reply
    Bookmark Topic Watch Topic
  • New Topic