aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "(JSTL) iterate - foreach eqivilant" Watch "(JSTL) iterate - foreach eqivilant" New topic
Author

(JSTL) iterate - foreach eqivilant

Phil Folkestone
Greenhorn

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">

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

</c:forEach>
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
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: http://aspose.com/file-tools
 
subject: (JSTL) iterate - foreach eqivilant