Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java forum!
  • 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
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

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
 
Bartender
Posts: 20149
104
Android Eclipse IDE Linux
  • 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
 
And when my army is complete, I will rule the world! But, for now, I'm going to be happy with this tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!