How do I go about defining an object that possesses several properties,
so that the object may later be added to a list as follows:
#set ($roster = [])
#set ($personnelRecord.name = "...")
#set ($personnelRecord.rank = "...")
#set ($personnelRecord.serialNumber = "...")
#set ($n = $roster.add(
If you don't need a specific object type and are using Velocity 1.5,
you can just use the new map syntax to create a map that you can add
properties to.
#set( $personnelRecord = { 'name' : "...", 'rank' : "...",
'serialNumber' : "..." } )
if you need to create a specific object, i'd recommend c
Thank you Nathan.
I do not need a specific object type, but also am not using Velocity
1.5. Is there an equivalent syntax available in 1.4 to allow me to
create the map?
gmc
Nathan Bubna wrote:
If you don't need a specific object type and are using Velocity 1.5,
you can just use the new ma
No, the map literal syntax is new to 1.5. however, there are ugly,
dangerous hacks like this:
#set( $object = 0 )
#set( $personnelRecord =
$object.class.forName('java.util.HashMap').newInstance() )
but i can't in good conscience recommend that. i think you should
just create a tool that return
Thank you again Nathan. We have already addressed the "ugly hack", and
plugged up that potential hole. We won't be trying anything in that area.
We are installing 1.5 at this time, and will be applying your first
solution.
gmc
Nathan Bubna wrote:
No, the map literal syntax is new to 1.5. h