cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <jer...@media.demon.co.uk>
Subject Re: JXTemplate: nested forEach problem
Date Tue, 10 Feb 2004 18:20:02 GMT

My sincere appologies .... I sent the wrong script !!!



On 10 Feb 2004, at 18:16, Jeremy Quinn wrote:

>
> On 10 Feb 2004, at 15:39, Christopher Oliver wrote:
>
>> What does your flowscript look like? Just a guess, but is it possible  
>> you are catching the exception from  
>> sendPage*("pipeline-containing-your-template") in  your script? That  
>> could explain the "generator already set" error (which occurs when  
>> you incorrectly call sendPage*() more than once in the same  
>> flowscript invocation - i.e. after catching the exception your script  
>> "falls through" to the next sendPage*()).
>>
>> HTH,
>
> Many thanks for your response.
> Thing is .... the page works fine without the :
>
> 	<t:forEach items="#{images}"> ... </t:forEach>
>
> At the moment, I get this error for any problem I have with JXTemplate  
> syntax.
>
> But anyway, here is the flowscript :

function album () {
   var factory = cocoon.getComponent (PersistanceFactory.ROLE);
   var session = factory.createSession ();
   try {
     var approot = cocoon.parameters["approot"];
     var album = AlbumPeer.load (session, new java.lang.Long  
(cocoon.parameters["albumid"]), null);
     var page = parseInt (cocoon.parameters["page"]);
     var size = parseInt (cocoon.parameters["size"]);
     if (album != null && !album.isPrivate) {
       var nav = pagerNavigation (album.resources.size(), page, size);
       if (page > -1 && size > 0 && album.resources.size() > 0) {
         var start = page*size;
         var end = (page*size) + size;
         if (end > album.resources.size()) end = album.resources.size ();
         album.resources = album.resources.subList (start, end);
       }
       cocoon.request.setAttribute ("sitemapURI",  
cocoon.parameters["sitemapURI"])
       cocoon.sendPage (cocoon.parameters["screen"], { album: album,  
nav: nav, approot: approot });
       catch (return) { session.close(); } // the page has finished  
rendering
     } else {
       cocoon.sendPage("screen/error", {message:  
"albums.album.notavailable"});
     }
   } catch (e) {
     cocoon.log.error (e);
     cocoon.sendPage("screen/error", {message:  
"albums.album.notavailable"});
     session.close();
   } finally {
     cocoon.releaseComponent(factory);
   }
}




>
> regards Jeremy
>
>> Chris
>>
>> Jeremy Quinn wrote:
>>
>>> I have a set of nested Beans, from with I am trying to extract  
>>> values  using JXTemplate.
>>>
>>> album - an Album Bean
>>>     title - String
>>>     text - String
>>>     . . .
>>>     resources - ArrayList of Resource Beans
>>>         artefact - String
>>>         text - String
>>>         images - ArrayList of Image Beans
>>>             image - String
>>>         . . .
>>>
>>> Here is part of the Template :
>>>
>>> <t:forEach items="#{album/resources}">
>>>   <section>
>>>     <title>
>>>     <a href="../artefacts/work(#{artefact}).html" title="view the  
>>> full  artefact">
>>>          <!-- snip -->
>>>     </a>
>>>     </title>
>>>     <p>IMAGES: #{count(images)}</p>  <!-- this reports 2 images
-->
>>>     <t:forEach items="#{images}">      <!-- this throws an exception
 
>>> -->
>>>       <a href="../artefacts/image(#{image}).html" title="view   
>>> information about this image">
>>>         <img alt="image: #{image}"   
>>> src="../images/thumbnail/artefacts/#{image}.jpg"/>
>>>       </a><xsl:text>&#160;</xsl:text>
>>>     </t:forEach>
>>>     <p title="albums.album.commentary" i18n:attr="title">#{text}</p>
>>>   </section>
>>> </t:forEach>
>>>
>>> This all works fine if I take out the inner 'forEach'.
>>> When I leave it in I get the far from helpful (currently in  
>>> 2.1.4-dev,  generic) Exception:
>>>
>>> org.apache.cocoon.ProcessingException: Generator already set. Cannot  
>>>  set generator 'jx' at   
>>> file:/Users/jerm/Development/Checkouts/someproject/webapp/ 
>>> album.xmap: 37:62
>>>         at   
>>> org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.setG 
>>> ene rator(AbstractProcessingPipeline.java:243)
>>>         at   
>>> org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingP 
>>> ipe line.setGenerator(AbstractCachingProcessingPipeline.java:158)
>>>
>>> etc.
>>>
>>> What I do not understand is that this works :
>>>     #{count(images)}
>>> But this throws exceptions :
>>>     <t:forEach items="#{images}">
>>>
>>> Any suggestions?
>>> I have tried all of the variations in the documentation and User's  
>>> List  that I could find.
>>>
>>> thanks
>>>
>>> regards Jeremy
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>

Mime
View raw message