Category: Jakarta Velocity

  • Velocimacro – Generate a HTML Select box and its Options

    A quick and simple Velocimacro to generate HTML Select boxes and its Options; automatically selects the correct option based on the value given. You can place this #macro anywhere in your Velocity templates but I used my global VM_global_library.vm file. Code [code] #macro( generateSelectBox $name $options $value ) #foreach ( $option in $options ) #set(…

  • Velocity if statement is type sensitive…

    Problem I discovered that comparisons in Velocity if statements are type-sensitive the hard way. For example, I am trying to display the ‘selected’ option in a html <SELECT> object. The list of possible values is $list, each is a simple ‘NameValuePair’ value object { String name, String value }. The object I am editing in…

  • Velocity Templates and Newlines

    If you’re reading this article you’ve probably encounted the same problem as I have. I was trying to put a newline ‘\n’ character in the value of a variable in a Velocity template. Attempt 1: I assumed \n would work… [code] #if ( !$foo ) #set ( $foo = “There was no foo set in…