Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question about c:forEach  RSS feed

 
Steve Vittoria
Ranch Hand
Posts: 35
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

I'm using a c:forEach to loop through a List.



What I'm noticing is that my method microResultProc.microList is being called several times. Why is that?
 
Tim Holloway
Bartender
Posts: 18709
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is wrong in many ways.

First, and most critically, JSF no longer supports "JSP" View Templates as of JSF 2.0. So you shouldn't expect it to work at all. The JSF2 View Template Language is based on Facelets, not JSP.

Secondly, by putting logic in a View Definition - which is supposed to be a template, not an executable, you are potentially violating the Separation of Concerns concept that is at the heart of the MVC paradigm (and JSF, since JSF is an MVC architecture).

Thirdly, despite some questionable docs on the Oracle website, JSTL and JSF really don't play well together.

Fourth, there are JSF-native alternatives to the forEach construct. The h:dataTable is recommended for cases where the data is to be displayed in a 2-dimensional row/column form. The ui:repeat tag can be used for more general purposes, such as when you have a list of items that you want to display horizontally instead of vertically. Use one of these options and JSF will like you a lot more.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!