im currently loosing my mind for at least two to three hours.
I simply want to get the pretty name of a property via velocity. However I can’t find a function for that.
#foreach ($property in $xclass.properties)
$property.Name
$property.PrettyName
#end
I get both the Name (XWP_NAME) and the PrettyName (XWP_PRETTYNAME) of every property that the class have.
What I need however is a function to get the PrettyName of a Property. And where I start to loose my mind is this example: $xobject.getProperty('a_Name').Name works and responds as expected with:
What I need it for:
I have a larger script and inside I have an array of the property names (without references!!! It is just “coincidentally” exactly the property names) and with foreach through that Array I want to get the Pretty Names of the corresponding property in the xclass.
As the term / description “pretty name” is used so often inside XWiki, using google will throw like every result, but not once have I found something that was helping yet.
I really don’t want to build something and check each individual non referenced property name for its matching property name within #foreach ($property in $xclass.properties) as this don’t seem like an “clean” solution to me.
Is there any function, something like $xclass.getPrettyName(“insert Property Name here”) ?
#set ($xdoc=$xwiki.getDocument('XWiki.MyOwnTemplate'))
#set ($xobject = $xdoc.getObject('XWiki.MyOwnClass'))
#set ($xclass = $xobject.xWikiClass)
#set ($discard = $doc.use($xobject))
$xobject.getProperty('a_Name')
##WORKS AND GIVES OUT THE REFERENCE (something like "com.xpn.xwiki.api.Property@4a98b986")
$xobject.getProperty('a_Name').name
##WORKS AND GIVES OUT THE PROPERTY NAME "a_Name"
#set ($property=$xobject.getProperty('a_Name'))
$property.getName()
##WORKS AND GIVES OUT THE PROPERTY NAME "a_Name"
$xobject.getProperty('a_Name').prettyName
##DOESN'T WORK AND GIVES OUT IT EXACT TEXT "$xobject.getProperty('a_Name').prettyName"
#set ($property=$xobject.getProperty('a_Name'))
$property.getPrettyName()
##DOESN'T WORK AND GIVES OUT IT EXACT TEXT "$property.getPrettyName()"
#set ($property=$xobject.getProperty('a_Name'))
$property.prettyName
##DOESN'T WORK AND GIVES OUT IT EXACT TEXT "$property.prettyName"