Wiki source code of Best Practices
Version 3.2 by Silvia Macovei on 2010/02/26
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{toc/}} | ||
2 | |||
3 | = XWiki Application Organization = | ||
4 | |||
5 | This [[Best Practices document>>Best Practices XWiki Application Organization]] explains how to best organize an XWiki Application. | ||
6 | |||
7 | = Check for Object existence in Class Sheets documents = | ||
8 | |||
9 | Class sheet documents should be written using the following construct (this is an example for displaying documents containing XWiki.XWikiUsers objects): | ||
10 | |||
11 | {{code}} | ||
12 | #set($obj = $doc.getObject("XWiki.XWikiUsers")) | ||
13 | #if(!$obj) | ||
14 | 1 User Sheet | ||
15 | This stylesheet must be applied on a document containing a XWiki.XWikiUsers object. | ||
16 | #else | ||
17 | 1 $msg.get("userProfile", [$xwiki.getUserName($doc.fullName, false)]) | ||
18 | ... | ||
19 | #end | ||
20 | {{/code}} | ||
21 | |||
22 | {{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.{{/info}} |