Re: JXTemplate forEach assigns entire list to current

2011-02-21 Thread Peter Molnar



On 02/19/2011 06:52 PM, Robby Pelssers wrote:

For all I know you're using the forEach incorrect.

jx:forEach select=#{$cocoon/parameters/initSources} varStatus=status
   jx:out value=#{$status/current}/
/jx:forEach


This is perfectly correct, straight from the documentation, but in 
JXPath syntax, which is slightly different than Jexl. I guess it has 
only worked because of the different semantics of the expression.


varStatus contains the status variable, which can be used to access 
various iteration parameters regardless of which syntax you use.


http://cocoon.apache.org/2.2/blocks/template/1.0/1391_1_1.html

See forEach.

--
Peter

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



Re: JXTemplate forEach assigns entire list to current

2011-02-19 Thread Peter Molnar

On 02/19/2011 03:52 PM, Peter Molnar wrote:

I have realized, that through the sitemap, I cannot pass a variable as a 
list, because it is cast to a String, thus my list only had one element.


I have built a string from the elements, and used a Jexl expression to 
re-split the string into a list. Ugly, but works.



I have a forEach tag in my template, which behaves oddly. The variable
comes from an InputModule, which returns a ListString, then it is
referenced as a parameter in the sitemap, which is passed to the
jxtemplate transformer. I would like to print each string as a line on
the output.

However, when I print #{.}, it prints the entire list, and the loop
quits after one iteration, regardless of the size of the list. When I
try Jexl syntax, it doesn't print anything. I am clueless.

Output is like this:

[value1, value2, ... ]

Here's the sitemap:

map:match pattern=report.html
map:generate type=jx src=.../templates/report.xhtml
map:parameter name=initSources value={skarabExt:initSources}/
/map:generate
map:serialize type=html/
/map:match

Here is the template:

jx:forEach select=#{$cocoon/parameters/initSources} varStatus=status
jx:out value=#{$status/current}/
/jx:forEach


I am using cocoon 2.2.0 and cocoon-template-impl 1.1.0 from Maven.


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



RE: JXTemplate forEach assigns entire list to current

2011-02-19 Thread Robby Pelssers
For all I know you're using the forEach incorrect.

jx:forEach select=#{$cocoon/parameters/initSources} varStatus=status
  jx:out value=#{$status/current}/
/jx:forEach

should be

jx:forEach items=${cocoon/parameters/initSources} var=element
  jx:out value=${element}/
/jx:forEach

Unless you really intended to show the varStatus?!

Kind regards,
Robby Pelssers

-Oorspronkelijk bericht-
Van: Peter Molnar [mailto:mp...@nanasoft.hu]
Verzonden: za 19-2-2011 16:42
Aan: users@cocoon.apache.org
Onderwerp: Re: JXTemplate forEach assigns entire list to current
 
On 02/19/2011 03:52 PM, Peter Molnar wrote:

I have realized, that through the sitemap, I cannot pass a variable as a 
list, because it is cast to a String, thus my list only had one element.

I have built a string from the elements, and used a Jexl expression to 
re-split the string into a list. Ugly, but works.

 I have a forEach tag in my template, which behaves oddly. The variable
 comes from an InputModule, which returns a ListString, then it is
 referenced as a parameter in the sitemap, which is passed to the
 jxtemplate transformer. I would like to print each string as a line on
 the output.

 However, when I print #{.}, it prints the entire list, and the loop
 quits after one iteration, regardless of the size of the list. When I
 try Jexl syntax, it doesn't print anything. I am clueless.

 Output is like this:

 [value1, value2, ... ]

 Here's the sitemap:

 map:match pattern=report.html
 map:generate type=jx src=.../templates/report.xhtml
 map:parameter name=initSources value={skarabExt:initSources}/
 /map:generate
 map:serialize type=html/
 /map:match

 Here is the template:

 jx:forEach select=#{$cocoon/parameters/initSources} varStatus=status
 jx:out value=#{$status/current}/
 /jx:forEach


 I am using cocoon 2.2.0 and cocoon-template-impl 1.1.0 from Maven.

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


winmail.dat
-
To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org
For additional commands, e-mail: users-h...@cocoon.apache.org