• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

Iterate arraylist with c:forEach  RSS feed

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi dears
I use <c:foreach for an arraylist, but it does not work,like when list is empty.But I check being empty and know it's not.this is what I wrote:

<c:foreach var="result" items="${list}">
<c:out value="${result}"/>
</c:forEach>

list is an ArryList which is fulled from database.
Thanking you in anticipation
Arona
 
Saloon Keeper
Posts: 20657
122
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
c:forEach is part of the JSTL, not part of JSF. Specifically, it can cause you serious problems when used in conjunction with JSF.

As you get more familiar with JSF, you'll discover that JSF pages don't have logic on them - they declare views, instead. For example, instead of iterating through a data array as c:forEach does, the JSF equivalent is a datatable, which simply specifies a window into the data array without actually defining the data retrieval in terms of a logic operation.
 
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Definitely JSF 1.1 does not work fine with JSTL.

However, isn't JSF 1.2 supposed to support JSTL transparently ?
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have had success combining JSTL with JSF in the past prior to discovering the h:dataTable tag. In your case, you need to specify which managed-bean the list is in, i.e. ${MyListBean.list}. And make sure you have a setter and a getter for 'list' implemented in MyListBean.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,
I would like to print the dynamic coulmn value using the t: dataTable . Is there any way by using var of dataTable we can display the collection value on screen. I dont want to display the text using var.name and var.address kind. I want to dynamically itereate over the row to get the values. Is there any simple way? Please let me know. Thanks. Pradip
 
Beauty is in the eye of the tiny ad.
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!