Wiki source code of BestPractices

Version 1.5 by Vincent Massol on 2007/10/25

Hide last authors
Vincent Massol 1.1 1 1 Best Practices
2
Vincent Massol 1.3 3 #toc("" "" "")
Vincent Massol 1.2 4
Vincent Massol 1.3 5 1.1 Check for Object existence in Class Sheets documents
Vincent Massol 1.1 6
Vincent Massol 1.3 7 Class sheet documents should be written using the following construct (this is an example for displaying documents containing XWiki.XWikiUsers objects):
Vincent Massol 1.1 8
Vincent Massol 1.3 9 {code}
Vincent Massol 1.5 10 #set($obj = $doc.getObject("XWiki.XWikiUsers"))
Vincent Massol 1.4 11 #if(!$obj)
12 1 User Sheet
Vincent Massol 1.3 13 This stylesheet must be applied on a document containing a XWiki.XWikiUsers object.
Vincent Massol 1.4 14 #else
15 1 $msg.get("userProfile", [$xwiki.getUserName($doc.fullName, false)])
Vincent Massol 1.3 16 ...
Vincent Massol 1.4 17 #end
Vincent Massol 1.3 18 {code}
Vincent Massol 1.1 19
Vincent Massol 1.3 20 #info("The 'if' tests first for the non existence. This is so that XWiki extract the title from the ~~1 User Sheet~~, which is a proper title to display when viewsing the sheet page, instead of the computed name which will usually display something wrong.")
Vincent Massol 1.1 21
22

Get Connected