[Anti Pattern] Do not use $obj.propertyName
17 Apr
2007
17 Apr
'07
11:59 a.m.
Hi, I'm proposing a new category: Anti Patterns! Here's one: Instead of writing: #set($obj = $doc.getObject("XWiki.XWikiUsers")) #if ($obj.avatar == "...") ... Write: #set($obj = $doc.getObject("XWiki.XWikiUsers")) #if ($obj.getProperty("avatar") && $obj.getProperty("avatar").getValue () == "...") ... Reason: $obj.avatar actually is equivalent to: $doc.display("avatar", $obj) And the display() method renders differently when in view mode, in inline mode, etc. For example in inline mode it generates an HTML form INPUT element... WDYT? Thanks -Vincent
7016
Age (days ago)
7016
Last active (days ago)
0 comments
1 participants
participants (1)
-
Vincent Massol