{"id":1270,"date":"2011-03-22T20:35:28","date_gmt":"2011-03-22T20:35:28","guid":{"rendered":"http:\/\/salientsoft.co.uk\/?p=1270"},"modified":"2011-03-22T20:35:28","modified_gmt":"2011-03-22T20:35:28","slug":"jsf-rendered-attribute-calls-the-getter-multiple-times","status":"publish","type":"post","link":"https:\/\/salientsoft.co.uk\/?p=1270","title":{"rendered":"JSF rendered attribute calls the getter multiple times"},"content":{"rendered":"<p>Initially when I saw this I thought it was a strange bug \u2013 the getter for the value expression referenced in a <em>rendered<\/em> attribute on a JSF2.0 facelets page was called 7 (yes <em>seven)<\/em> times when I would have expected one call only!<\/p>\n<p>There are logical and historical reasons for this which are detailed in<strong> <\/strong><a href=\"http:\/\/stackoverflow.com\/questions\/4281261\/why-is-the-getter-called-so-many-times-by-the-rendered-attribute\"><strong>this post here<\/strong><\/a>.<\/p>\n<p>The moral of the tale would seem to be that you should not make any assumptions about how often getters for value expressions are called, nor when exactly they are called. If you are doing for example database access you should <em>never<\/em> do this in a getter, but should use system events (JSF2) or Phase events (JSF1) for the database access as these give fully predictable behaviour as to when the calls happen and give you full control.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Initially when I saw this I thought it was a strange bug \u2013 the getter for the value expression referenced in a rendered attribute on a JSF2.0 facelets page was called 7 (yes seven) times when I would have expected one call only! There are logical and historical reasons for this which are detailed in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[22],"tags":[13,76,40,184],"_links":{"self":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1270"}],"collection":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1270"}],"version-history":[{"count":0,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1270\/revisions"}],"wp:attachment":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}