cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brent Johnson <bljohn...@gmail.com>
Subject Jxtemplate forEach Variables
Date Wed, 04 Aug 2004 15:21:54 GMT
When looping in a JXTemplate using jx:forEach I can refer to the
current item as the variable specified in the var attribute.  Are
there any other variables I can access in this loop related to the
loop itself?  I'd like to be able to test an expression to find out if
I'm at the last item in the loop.  Here's an example:

----
List of items:
<jx:forEach items="${location.getContainer()}" var="item">
    ${item.getName()}, 
</jx:forEach>
----

The problem with this is trivial I know - but doing this will result
in a string that ends with a comma.  I'd like to be able to test if
I'm at the end - so I can append a comma only when I'm not on the last
item.

In XSLT you can achieve something similar by doing <xsl:if
test="position() != last()">...</xsl:if>

Thanks,

- Brent

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message