cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robby Pelssers" <>
Subject how-to iterate over attributes of javascript object within template block
Date Tue, 15 Dec 2009 11:21:41 GMT
Hi all,


I know i'm kinda pushing it by what I'm trying to accomplish here but it would be cool if
it would work.


Suppose I have following objects defined in my flowscript:


var topics = [


      "title": "Product profile", 

      "id": "product_profile"



      "title": "Pinning information", 

      "id": "pinning_information",




      "title": "Limiting values", 

      "id": "limiting_values",

      "type": "parametric",




What I would like to generate is something like:


  <Topic id="product_profile" title="Product profile"/>

  <Topic id="pinning_information" title="Pinning information"/>

  <Topic id="limiting_values" title="Limiting values" type="parametric"/>




So written in pseudo-code:

Iterate over all topics and generate a <topic> with it's corresponding attributes. 
The only thing I don't know is if the forEach iterator also can handle something like we can
do to iterate over all keys of an object and then retrieving the value.


for (var key in object) {

    someFunction(key, object[key]);




      <jx:forEach var="topic" items="${data.topics}">



          <jx:forEach var="attribute" items="${topic}">

            <jx:attribute name="${attribute}" value="${topic[attribute]}"/>    à  this
does not work because the @items does not seem to be able to handle the wanted behaviour in
case we don't pass on a collection but a javascript object.  In that case default behaviour
should be in my opinion to iterate over the keys of the object.







What do you guys think?


Kind regards,


View raw message