You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Assia Aouat <as...@canada.sirsi.com> on 2004/08/24 15:10:28 UTC
RE: Indirect access to a variable
Hi,
Try
#set ( $foo = "some value" )
#set ( $bar = $foo )
$bar
-----Original Message-----
From: Gaetan Sheridan [mailto:gsheridan@vds.ca]
Sent: Tuesday, August 24, 2004 9:11 AM
To: velocity-user@jakarta.apache.org
Subject: Indirect access to a variable
Importance: Low
Hi,
I am looking for a way to access the value of an Object put in the
Velocity context using a String containing its name:
#set ( $foo = "some value" )
#set ( $bar = "foo" )
How can I use $bar to display "some value"
I tried things like:
$$bar
$"$bar"
and so on... without success.
The idea is to have a macro where both the name of a parameter and its
value can be outputted:
#macro ( m $paramName )
<input type=text name="$paramName" value="???">
#end
using:
#m ("foo")
would result in:
<input type=text name="foo" value="some value">
Thanks for any help.
Gaetan Sheridan
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org