BestPractices

Version 1.3 by Vincent Massol on 2007/04/17
Warning: For security reasons, the document is displayed in restricted mode as it is not the current version. There may be differences and errors due to this.

Best Practices

Invalid macro parameters used for the [toc] macro. Cause: [Failed to validate bean: [must be greater than or equal to 1]]. Click on this message for details.

Check for Object existence in Class Sheets documents

Class sheet documents should be written using the following construct (this is an example for displaying documents containing XWiki.XWikiUsers objects):

\#set($obj = \$doc.getObject("XWiki.XWikiUsers"))
\#if(!$obj)
  \1 User Sheet
 This stylesheet must be applied on a document containing a XWiki.XWikiUsers object.
\#else
  \1 \$msg.get("userProfile", [\$xwiki.getUserName($doc.fullName, false)])
  ...
\#end

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.

Tags:
Created by Vincent Massol on 2017/09/05
   

Get Connected