You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Laurent Perez <ha...@gmail.com> on 2004/12/01 16:35:32 UTC

Concatenation of variables in JXTemplate

Hello

I have the following declarations in my jx template :

<jx:set var="b" value="bean"/>
<jx:set var="l" value="${lang}"/>

Now I would like to access a bean property using ${bean.l} (call it a
'dynamic property'). For example when l = "foo", I would like to
access ${bean.foo}, but I don't understand how to evaluate the ${}
part :(

I've tried :

<jx:set var="b" value="bean"/>
<jx:set var="l" value="${lang}"/>
<jx:set var="dot" value="."/>
<jx:set var="both" value="${b.concat(dot).concat(l)}"/>

but whenever I access ${both}, I just get a string
"bean.value_of_lang", because evaluation failed.

Can anyone help me with the trick ?

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


RE: Concatenation of variables in JXTemplate

Posted by Adam Ratcliffe <ad...@mrigitech.com>.
Hi Laurent

Your problem is likely due to ${lang} not referencing a string type.

Have a look at this post and see if it helps

http://www.mail-archive.com/users@cocoon.apache.org/msg21031.html

Cheers
Adam

-----Original Message-----
From: Laurent Perez [mailto:hakimm@gmail.com]
Sent: Thursday, 2 December 2004 4:36 a.m.
To: users@cocoon.apache.org
Subject: Concatenation of variables in JXTemplate


Hello

I have the following declarations in my jx template :

<jx:set var="b" value="bean"/>
<jx:set var="l" value="${lang}"/>

Now I would like to access a bean property using ${bean.l} (call it a
'dynamic property'). For example when l = "foo", I would like to
access ${bean.foo}, but I don't understand how to evaluate the ${}
part :(

I've tried :

<jx:set var="b" value="bean"/>
<jx:set var="l" value="${lang}"/>
<jx:set var="dot" value="."/>
<jx:set var="both" value="${b.concat(dot).concat(l)}"/>

but whenever I access ${both}, I just get a string
"bean.value_of_lang", because evaluation failed.

Can anyone help me with the trick ?


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