velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Assia Aouat" <as...@canada.sirsi.com>
Subject RE: Indirect access to a variable
Date Tue, 24 Aug 2004 13:10:28 GMT
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


Mime
View raw message