Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Last time thru iterate?
Last time thru iterate? [message #16046] Wed, 16 May 2007 18:11 Go to next message
Gary Pinkham is currently offline Gary PinkhamFriend
Messages: 8
Registered: July 2009
Junior Member
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 12:34 Go to previous message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
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: Fri Nov 28 07:14:03 GMT 2014

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

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