Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » Last time thru iterate?
Last time thru iterate? [message #16046] Wed, 16 May 2007 14:11 Go to next message
Eclipse UserFriend
We're trying to create a template which generates a JSP that conforms to our
JSP syntax (tags etc..). We're iterating over the fields we want in a table
and outputing the approriate tags for our table tag. But we want the last
time through to add one additonal piece of output. (ie:
class="lastChild"). Does anyone know a way to do this with the iterate tag
(short of putting "last='true'" in my meta-data)???

Thanks!
Gary
Re: Last time thru iterate? [message #16095 is a reply to message #16046] Thu, 17 May 2007 08:34 Go to previous message
Eclipse UserFriend
Gary:

This would be a great enhancement. I've created bug 187524
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=187524) to track it.

In the meantime,

You could do something like the following. Let's assume this is your current
iterate tag:

<c:iterate select="yourXPathExpr" var="...">
</c:iterate>

The, do the following:

<c:setVariable var="iterateCount" select="count(yourXPathExpr)"/>
<c:setVariable var="iterateIndex" select=" 0 "/>
<c:iterate select="yourXPathExpr" var="...">
<c:setVariable var="iterateIndex" select = "$iterateIndex + 1"/>
... body of your iterate...
<c:if test="$iterateIndex = $iterateCount">
... special content for the last iteration...
</c:if>
</c:iterate>


Paul
Previous Topic:JET - Only possible to use xpath?
Next Topic:Antlr and jet2 integration
Goto Forum:
  


Current Time: Sat Jun 07 01:59:41 EDT 2025

Powered by FUDForum. Page generated in 0.03496 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top