You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Jeremy Quinn <je...@media.demon.co.uk> on 2003/07/02 13:54:26 UTC
JX Template help
(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
Re: JX Template help
Posted by Ugo Cei <u....@cbim.it>.
Jeremy Quinn wrote:
>
> On Wednesday, July 2, 2003, at 07:23 PM, Christopher Oliver wrote:
>> This seems to be a limitation of JXPath.
> OK
This might help: http://www.jsurfer.org/article.php?sid=647
Ugo
--
Ugo Cei - http://www.beblogging.com/blog/
Re: JX Template help
Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On Wednesday, July 2, 2003, at 07:23 PM, Christopher Oliver wrote:
Many thanks for your reply.
> This seems to be a limitation of JXPath.
OK
> I'll try to look into it.
That would be great.
> 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>
I tried to do something similar to the above yesterday, could not get
it to work (struggling with the syntax), so output {index,data} from my
Bean instead, which is a bit of a hack ..... so I'll try your
workaround.
regards Jeremy
> 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
>>
>>
>
>
Re: JX Template help
Posted by Christopher Oliver <re...@verizon.net>.
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
>
>