I am having a velocity script problem with a class sheet when I try to
display an empty list on an object.
My goal is for the class sheet to render class properties that start
with a "_" as hot-links, and those that don't to just be rendered as text.
The class sheet is for "PersonClass", and looks like this:
{{velocity}}
#set ($obj = $doc.getObject('XWiki.PersonClass'))
#set($class = $obj.xWikiClass)
#foreach($prop in $class.properties)
; $prop.prettyName
#set ($propName = $prop.getName())
#set ($propVal = $obj.get($propName) )
#if ($propName.startsWith("_"))
: $propVal (why does this one not show?)
: [[$propVal>>$propVal]] (but this one does show?)
#else
: $doc.display($prop.getName())
#end
#end
{{/velocity}}
The PersonClass has two properties:
(1) name (a string)
(2) _knows (a DatabaseList with multiple select and XWiki Class Name of
XWiki.PersonClass)
I create an object using this class, with "name" set to "C S Lewis"
and
with no selection for the _knows field (empty list).
The problem is, the velocity line:
: $propVal (why does this one not show?)
works properly... not displaying anything for property _knows (empty
list), but the line:
: [[$propVal>>$propVal]] (but this one does show?)
which is the line I really want to use in the class sheet, because it
creates the hot links, shows the value from the previous property as a
hot link. I.e. it looks like this:
name
C S Lewis
_knows
(why does this one not show?)
C S Lewis (but this one does show?)
Not what I wanted. Why does it do this? How can I get empty lists to
show no page links, but lists with one or more items to display them as
a bunch of hot links?
Thanks,
-Mark