cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michel Erard" <cocoon.er...@besonet.ch>
Subject Re: counter in jx:foreach
Date Mon, 08 Oct 2007 13:48:09 GMT
Thank you Felix, 

I didn't know this 'varStatus'. Now it's working correctly.

Cheers, 

Mike


---------- Original Message ----------------------------------
From: Felix Knecht <felixk@apache.org>
Reply-To: users@cocoon.apache.org
Date:  Mon, 08 Oct 2007 15:09:06 +0200

>Ciao Michel
>
>
>Something like should do the job to get the actual index:
>
><jx:forEach var="item" items="${items}" varStatus="rowStat">
>  ${item} : ${rowStat.index}
></jx:forEach>
>
>Where rowStat contains e.g. the actual index of the iteration.
>
>See also http://cocoon.apache.org/2.1/userdocs/flow/jxtemplate.html
>
>Felix
>
>> Hello, 
>>
>> I'm implemented this loop with jx:
>>
>> <page xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
>>               <jx:set var="counter" value="#{-1}"/> 
>>               <jx:forEach var="item" items="${list}">
>>                 <jx:set var="counter" value="#{1 + $counter}"/>
>>                 ${item} : ${counter}<br/>
>>               </jx:forEach>
>> </page>
>>
>> function home() {
>> 	var list = new ArrayList();
>> 	list.add("test 1");
>> 	list.add("test 2");
>> 	list.add("test 3");
>> 	list.add("test 4");
>> 	list.add("test 5");
>>     cocoon.sendPage("home.page", {list:list});
>> }
>>
>> the output is: 
>>
>> test 1 : 0.0
>> test 2 : 0.0
>> test 3 : 0.0
>> test 4 : 0.0
>> test 5 : 0.0
>>
>> the increment of the counter is only performed once. In older versions of cocoon
this did work, now with version 2.2 I've this problem.
>>
>> Doe's somesing change? Is there another way to do this?
>>
>> Tanks for any hints.
>>
>> Mike 
>>
>>
>> ____________________________________________
>> QuickLine WebMail - http://www.QuickLine.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>   
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
 


____________________________________________
QuickLine WebMail - http://www.QuickLine.com

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


Mime
View raw message