This seems to be a limitation of JXPath. I'll try to look into it. As a workaround you can set your own loop index variable:

<t:set var="position" value="#{1}"/>
<t:forEach items="#{pageNames}">
<a href="#" onmousedown="doAction('#{$PAGEACTION}','#{$position}')">#{.}</a><br/>
<t:set var="position" value="#{$position + 1}"/>
</t:forEach>


Jeremy Quinn wrote:

(I think I sent this just as the mailing lists were being changed over, my apologies if two copies arrive)



Hi All,

Anyone got an idea what I am doing wrong here?

I have a java.util.ArrayList called "pageNames", populated with Strings, that I want to output (along with their index) using JX Template.

<t:forEach items="#{pageNames}">
<a href="#" onmousedown="doAction('#{$PAGEACTION}','#{position()}')">#{.}</a><br/>
</t:forEach>


The output I get looks like this:

<a href="#" onmousedown="doAction('PAGE_THUS','0')">Abdu'Allah</a><br/>
<a href="#" onmousedown="doAction('PAGE_THUS','0')">Budgett</a><br/>
<a href="#" onmousedown="doAction('PAGE_THUS','0')">Evans</a><br/>
...... ^


ie. 'position()' is not working as I would expect it to do, (from my experience with XSLT).

Should I expect it to work the same way?
Is there an alternative way of doing this?


Thanks for any help


regards Jeremy






Reply via email to