commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject [jelly] velocity->jelly mapping for #set
Date Fri, 06 Dec 2002 03:53:29 GMT
I'm trying to figure out how the #set velocity directive maps to a 
jelly expression.

In Velocity, we're accustomed to using in our templates

Example 1
#set ($foo = 1)
${foo} (formal notation)


Example 2
${foo.size()} ## $foo is a vector placed into the context

Looking at the core taglibs, I tried Ex 1 using 

<j:set var="foo" value="1"/>, <j:set var="foo" value="${1}"/> with no 
<j:set var="foo">1</j:set> 
worked for me. Looking at the taglib doc, it says that the value attr 
accepts an Expression. Is there any shorthand for this, other than 
wrapping them in tags every single time? It's a pretty big difference 

#set ($foo = 1) 
<j:set var="foo">1</j:set>

For Ex 2, I believe ${foo.size()} doesn't work coz it returns a 
primitive. Is there any easy workaround? 

For Ex 3, trying 
<j:set var="foo" value="${bar.class}"/> or <j:set var="foo" 
value="${bar.getClass()}"/> (aren't these Expressions?), and again 
encapsulating the ${bar.class} within the <j:set> tags worked.

Just trying to make sure I understand how stuff is supposed to be 



View raw message