Ard Schrijvers wrote:
Hello Alberto,

I need to convert a string (words delimited with commas) in something that "jx:forEach" can iterates. I found a nice example in documentation (http://cocoon.apache.org/2.1/userdocs/flow/jxtemplate.html).

<jx:macro name="forTokens">
  <jx:parameter name="var"/>
  <jx:parameter name="items"/>
  <jx:parameter name="delims"/>
<jx:forEach var="${var}" items="${java.util.StringTokenizer(items, delims)}">
    <jx:evalBody/>
  </jx:forEach>
</jx:macro>

<forTokens var="letter" items="a,b,c,d,e,f,g" delims=",">
  letter = ${letter} <br/>
</forTokens>

I also have had this problem. See this thread 
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=113835963721689&w=2 about your 
problem. It used to work, but not in cocoon-2.1.8 in this way anymore. I am not sure 
about other versions: which one do you use?
cocoon 2.1.9, jdk 1.5.0, Debian sarge
Anyway, I solved it by going through flow. Are you familiar with flow? Do the 
java.util.StringTokenizer part in flow, and pass the variable from flow to your 
jxtemplate. Then you can use the jx:forEach on this object.
I tried and it works using java.util.StringTokenizer in jx file too.
I will wait 2.2 for a more elegant solution.

Many thanks

Alberto
Regards Ard

I try it and something simpler:

<jx:forEach var="field" items="${java.util.StringTokenizer('name,lastname',',')}" varStatus="status">
   <rfc:row id="${status.count}">
        <rfc:field name="FIELDNAME">${field}</rfc:field>
   </rfc:row>
</jx:forEach>


Both doesn't work; field variable has never a value.

What's wrong? Is there another way?

Alberto

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to