Velocity: How to make a global array?

69 Views Asked by At

I have 3 vm files: f1.vm, f2.vm and f3.vm in f1.vm I make the array with name PROTOCOL_VERSIONS:

#set($PROTOCOL_VERSIONS = []) 

I want to add elements in PROTOCOL_VERSIONS from f2.vm file:

#set($success = $PROTOCOL_VERSIONS.add('{"major":1, "minor":0}'))

and use the PROTOCOL_VERSIONS array in the f3.vm

[
#foreach( $protocolVersion in PROTOCOL_VERSIONS )
{
"header": {
           "upv": $protocolVersion,
          },
}  #if(!$foreach.last) 
, 
#end
#end
]

I tried it but unfortunately it does not initialization. Is it possible ?

0

There are 0 best solutions below