File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes (JSTL) iterate - foreach eqivilant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "(JSTL) iterate - foreach eqivilant" Watch "(JSTL) iterate - foreach eqivilant" New topic

(JSTL) iterate - foreach eqivilant

Phil Folkestone

Joined: Dec 03, 2005
Posts: 1
Hi All,

I have some nice code in Jstl that makes everything look reeeal 'purdy... it's just a <c:forEach> loop (as below) and it means I can display my data any dang way I want. I'm sure we are all comfortable with this idea, even in cowboy parlance.

however, i may switch to JSF but I can only get my data in a dataTable, with its grey and white lines looks like some city slicker is coming down to repo the farm, in all its uinformed grey and white, boxed in fandangeled layout.

on the sun site , looky here , it says:

The forEach tag does not work with JavaServer Faces tags due to an incompatibility between the strategies used by JSTL and and JavaServer Faces technology. Instead, you could use a renderer, such as the Table renderer used by the dataTable tag, that performs its own iteration. The if, choose and when tags work, but the JavaServer Faces tags nested within these tags must have explicit identifiers.

i sure ain't had much book learn'n but mabe the answer is in here, do i use a "Table Renderer", will it give me the same control as the <c:forEach>(as below).

I'd be mighty obliged if you could point this lost cowboy to the nearest saloon.

Cowboy Phil

<c:forEach var="events" items="${ requestScope.eventDetail }" varStatus="status">

<img src="../images/inc/spacer.gif" width="360" height="8">
<c ut value="${events.eventTitle}"/><fmt:formatDate value="${events.eventStartDate}" dateStyle="full" />
<img src="../images/newstory.gif" border="0" width="170" height="129" align="right"><c ut value="${events.eventDescription}"/>
<img src="../images/inc/spacer.gif" width="360" height="3">
<img src="../images/inc/horizontaldots360.gif">

Stefan Evans

Joined: Jul 06, 2005
Posts: 1580
Howdy pardner!

Well lookee here we got ourself a real teaser here.
Myself, I reckon you need to mix a dataTable with a panelGrid, and maybe a smatterin' of panelGroups chucked in for good measure.
It might need a bit of work to get it done, but it should be doable.

BTW you haven't included your table tag in your code. But most attributes you can put on a table you can include on the dataTable tag, so you should be able to duplicate it.
If you want multiple things in one table cell group them together with a panelGroup tag.

That should be more than enough to get you started.
[ December 04, 2005: Message edited by: Stefan Evans ]
I agree. Here's the link:
subject: (JSTL) iterate - foreach eqivilant
It's not a secret anymore!