You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Christian Rosenberger <pi...@gmx.de> on 2004/11/13 16:37:33 UTC

ForEach and JXTemplateGenerator

Hi,

have a strange problem in accessing a list via JXTemplateGenerator and 
forEach.

In flowscript I create the array like in an example from the wiki:

var yearslist = ["2000","2001","2002"];

Tried also an LinkedList:

var list = new java.util.LinkedList();
list.addLast("2000");
...

My JXTemplate looks like this:

<?xml version="1.0" encoding="ISO-8859-1"?>

 <html xmlns:jx="http://apache.org/cocoon/jxtemplate/1.0">

  <div class="mainmenu-item"><a href="years.html">Years</a></div>
   <p> Heading: <b> ${heading} </b> </p>

   <jx:forEach var="year" items="${yearlist}">
     Year: $year
   </jx:forEach>
 </html>


The $heading variable is correctly substituted , but the JXTemplateGenerator 
doesn't generate a iterated list.

The output in HTML is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:jx="http://apache.org/cocoon/jxtemplate/1.0">
<div class="mainmenu-item"><a href="years.html">Years</a></div>
<p> Heading: <b> GREAT</b> </p>

			<jx:forEach var="year" items="org.mozilla.javascript.NativeArray@66db4e">
				$year
 </jx:forEach>


Any ideas, why the jx:forEach isn't translated?!?

In an other application at the same cocoon installation, JXTemplateGenerator 
works fine with objects in an arraylist.

It's quite strange, that the above code doesn't work.

Thanks in advance.

Regards,
Christian 


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


Re: ForEach and JXTemplateGenerator

Posted by Upayavira <uv...@upaya.co.uk>.
Have you declared the jx namespace at the top of your JXTemplate file? 
Starting the file with something like:

<page xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">

Does that sort it?

Regards, Upayavira

Christian Rosenberger wrote:

> Hi,
>
> have a strange problem in accessing a list via JXTemplateGenerator and 
> forEach.
>
> In flowscript I create the array like in an example from the wiki:
>
> var yearslist = ["2000","2001","2002"];
>
> Tried also an LinkedList:
>
> var list = new java.util.LinkedList();
> list.addLast("2000");
> ...
>
> My JXTemplate looks like this:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <html xmlns:jx="http://apache.org/cocoon/jxtemplate/1.0">
>
>  <div class="mainmenu-item"><a href="years.html">Years</a></div>
>   <p> Heading: <b> ${heading} </b> </p>
>
>   <jx:forEach var="year" items="${yearlist}">
>     Year: $year
>   </jx:forEach>
> </html>
>
>
> The $heading variable is correctly substituted , but the 
> JXTemplateGenerator doesn't generate a iterated list.
>
> The output in HTML is:
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
> "http://www.w3.org/TR/html4/loose.dtd">
> <html xmlns:jx="http://apache.org/cocoon/jxtemplate/1.0">
> <div class="mainmenu-item"><a href="years.html">Years</a></div>
> <p> Heading: <b> GREAT</b> </p>
>
>             <jx:forEach var="year" 
> items="org.mozilla.javascript.NativeArray@66db4e">
>                 $year
> </jx:forEach>
>
>
> Any ideas, why the jx:forEach isn't translated?!?
>
> In an other application at the same cocoon installation, 
> JXTemplateGenerator works fine with objects in an arraylist.
>
> It's quite strange, that the above code doesn't work.
>
> Thanks in advance.
>
> Regards,
> Christian
>
> ---------------------------------------------------------------------
> 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


Re: ForEach and JXTemplateGenerator

Posted by Brent Johnson <bl...@gmail.com>.
Are you using the attribute type="jx" in your sitemap for the
generator?  If so thats definitely weird that the jx tag actually gets
output to the browser.

- Brent

On Sat, 13 Nov 2004 16:37:33 +0100, Christian Rosenberger
<pi...@gmx.de> wrote:
> Hi,
> 
> have a strange problem in accessing a list via JXTemplateGenerator and
> forEach.
> 
> In flowscript I create the array like in an example from the wiki:
> 
> var yearslist = ["2000","2001","2002"];
> 
> Tried also an LinkedList:
> 
> var list = new java.util.LinkedList();
> list.addLast("2000");
> ...
> 
> My JXTemplate looks like this:
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> 
>  <html xmlns:jx="http://apache.org/cocoon/jxtemplate/1.0">
> 
>   <div class="mainmenu-item"><a href="years.html">Years</a></div>
>    <p> Heading: <b> ${heading} </b> </p>
> 
>    <jx:forEach var="year" items="${yearlist}">
>      Year: $year
>    </jx:forEach>
>  </html>
> 
> The $heading variable is correctly substituted , but the JXTemplateGenerator
> doesn't generate a iterated list.
> 
> The output in HTML is:
> 
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <html xmlns:jx="http://apache.org/cocoon/jxtemplate/1.0">
> <div class="mainmenu-item"><a href="years.html">Years</a></div>
> <p> Heading: <b> GREAT</b> </p>
> 
>                         <jx:forEach var="year" items="org.mozilla.javascript.NativeArray@66db4e">
>                                 $year
>  </jx:forEach>
> 
> Any ideas, why the jx:forEach isn't translated?!?
> 
> In an other application at the same cocoon installation, JXTemplateGenerator
> works fine with objects in an arraylist.
> 
> It's quite strange, that the above code doesn't work.
> 
> Thanks in advance.
> 
> Regards,
> Christian
> 
> ---------------------------------------------------------------------
> 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