I used a macro for this purpose ## ------------------------------------------------------------------------ ## convenience directive to invoke a method and ignore the return value ## ------------------------------------------------------------------------ #macro( call $foo )#if($foo)#**##end#end ## the comment in the if-statement avoids an empty if-body parser error ... #call( $elem.setText( $sometext ) )
Beware... some people may argue that putting such code in templates is "not the right place"(TM), if you desire to follow the MVC paradigm. The newlines and whitespaces is something that needs adressing in velocity, see the proposed solutions in the wiki: http://wiki.apache.org/jakarta-velocity/VelocityWhitespaceGobbling Cheers, Christoph Anagha wrote:
Hi, I'm building the XML in the VTL. At some point I retrieve the value of an element and set its text as $elem.setText( $sometext ) #foreach($elem in $rootelem.getChildren()) #set ($elemname = $elem.getName()) #set( $sometext = $userprops.get($elemname) ) $elem.setText( $sometext ) #end In the output I get each element printed as --- "[Element: <serviceName/>]" where serviceName is the the element name. This happens for all the elements in the for loop. I want to disable this output on the console/file which comes from "setText" I tried : VelocityEngine ve = new VelocityEngine(); ve.setProperty(VelocityEngine.VM_MESSAGES_ON, "false"); But still the elements are printed which is not desired. Also I get a lot of new lines in the output which I want to disable. Any pointers? -- Thanks & Regards, Anagha
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]