On Tue, Jan 26, 2016 at 8:20 PM, Mark Sack <[email protected]> wrote:
In 7.4, I've created an app within minutes. One of the properties in the app is a computed field that returns a list of users that meet some specific criteria. If I leave the custom display field for the property blank, the contents are displayed as follows:
[XWiki.john_smith, XWiki.mark_sack]
This must be the result / output of rendering the "script" meta property of your computed field.
What I would really like to do is display them as hyperlinks to the corresponding user page. I thought that I could use a script in the custom display field to accomplish this. Reading the following note
http://www.xwiki.org/xwiki/bin/view/FAQ/Which+variables+I+can+use+in+%22Cust... there are some variables available. It looks like the $value variable should contain the computed list of users. But if I put a script like the following into the custom display field:
{{velocity}} $name $prefix $object $type $value {{/velocity}}
the result is as follows
Usuarios Secti.Admin.Setores.Code.SetoresClass_0_ com.xpn.xwiki.api.Object@543f3466 view $value
The first four values are correct as far as I can tell. But the $value variable does not appear to be populated. Does anyone have a suggestion as to how I can achieve my desired result with the hyperlinks?
$value is null because computed fields don't have a value stored in the database. Their "value" is dynamic, computed by rendering the "script" meta property. You have two options: (1) Render the "script" meta property in the custom displayer and use the data that has been put in the Velocity context (assuming you're using Velocity in the "script" value) {{velocity}} #set ($script = $object.getxWikiClass().get($name).getValue('script')) #set ($classSyntax = $xwiki.getDocument($object.documentReference).syntax) #set ($discard = $doc.getRenderedContent($script, $classSyntax)) ## Assuming $users is set in the "script" meta property $users {{/velocity}} (2) Most of the time you don't need to access the "raw" value of a computed field. If you're only interested in displaying it then it's easier to generate the hyperlinks directly in the "script" meta property. Which is equivalent with leaving the "script" meta property empty and putting all the code in the custom displayer. Hope this helps, Marius
-- View this message in context: http://xwiki.475771.n2.nabble.com/Custom-display-for-computed-field-which-is... Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users