• Post Reply Bookmark Topic Watch Topic
  • New Topic

Iterate arraylist with c:forEach  RSS feed

 
arona kosari
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}">
<cut value="${result}"/>
</c:forEach>

list is an ArryList which is fulled from database.
Thanking you in anticipation
Arona
 
Tim Holloway
Bartender
Posts: 18781
74
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.
 
Edisandro Bessa
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 ?
 
XiaoPeng
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.
 
pradip p sardar
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!