commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dion Gillard <dion.gill...@gmail.com>
Subject Re: [jelly] Dynamic variable interpolation
Date Wed, 08 Jun 2005 23:45:33 GMT
On 6/9/05, Grant Ingersoll <GSIngers@syr.edu> wrote:
> Hi,
> 
> Am a fairly new user of Jelly and am wondering if there is a way to use
> the value of a variable as the name of a new variable which I can then
> dereference in my script.
> 
> Something like:
> 
> <j:set var="foo" value="a,b,c"/>
> <j:set var="a.name" value="A"/>
> <j:set var="b.name" value="B"/>
> <j:set var="c.name" value="C"/>
> 
> 
> 
> <util:tokenize var="vars" delim=",">
>          ${foo}
> </util:tokenize>
> <j:forEach var="var" varStatus="status" items="${vars.iterator()}">
>      echo  ${  ${var}.name   }
>                 <--------------------   what is the syntax for this???

        echo ${context.getVariable(var + '.name')}

should do it.
> 
> </j:forEach>
> 
> 
> Output would be:
> A
> B
> C
> 
> Do I use a dynabean?
> 
> Thanks,
> Grant
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


-- 
http://www.multitask.com.au/people/dion/
"You are going to let the fear of poverty govern your life and your
reward will be that you will eat, but you will not live." - George
Bernard Shaw

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message