How to access properties of an object with dynamic macros in Velocity templates

villols

New Member
I have a velocity template defined as follows:\[code\]#macro(aMacro $par1) $par1 $par1.id#end##dynamic macro call====================#set($macroName = "aMacro") #set( $call = "#$macroName('$p1')" )#evaluate($call)## static macro call ====================#aMacro($p1)\[/code\]When I merge the template with the data:\[code\]dataClass d = new dataClass();d.setId(1234);context.put("p1", d);\[/code\]the result is: \[code\]velocity.dataClass@133f6dd$par1.idvelocity.dataClass@133f6dd1234\[/code\]I have also tried $par1.getId(), but result is same. Why does the the dynamic call fails to access the properties/getters? How to make the dynamic call to work similar to static call?ThanksKrish.
 
Top