{"id":6672,"date":"2014-04-21T12:51:06","date_gmt":"2014-04-21T12:51:06","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/21\/jsf-uifragment-rendered-performance-collection-of-common-programming-errors-2\/"},"modified":"2014-04-21T12:51:06","modified_gmt":"2014-04-21T12:51:06","slug":"jsf-uifragment-rendered-performance-collection-of-common-programming-errors-2","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/21\/jsf-uifragment-rendered-performance-collection-of-common-programming-errors-2\/","title":{"rendered":"JSF ui:fragment rendered performance-Collection of common programming errors"},"content":{"rendered":"<p>I have a set of jsf components that are statically generated from a set of excel files (they are updated by business people). Each generated file represents a business object that has slightly different data, and all of them belong to a same class.<\/p>\n<p>In order to render this dynamically, the only solution I found was to set up a bunch of <code>ui:fragment<\/code> and dispatch to the right component at runtime:<\/p>\n<pre><code>          \n \n    \n        \n    \n    \n        \n    \n    \n        \n    \n    \n        \n    \n   \n   \n   \n    \n        \n    \n<\/code><\/pre>\n<p>But I found out that the perfomance of this is terrible. I tought that JSF would only render a single component, but it seems that it is rendering <strong>all<\/strong> of them and &#8220;hiding&#8221; the others at runtime.<\/p>\n<p>Is there a more efficient way of achieving my goal? I want to render <strong>a single component<\/strong> based on runtime information about a business class (much like an if-then-else), but I can only determine what is the component to render at runtime.<\/p>\n<p><strong>Clarification:<\/strong> what happens is that each component referenced by <code>limites:limites*<\/code> is a huge complex page with lots of other components. At runtime, the parameter named <code>type' will decide what component to render. But my tests show that if I only render one component, but leave the other<\/code>ui:fragments` (even knowing that they will not be rendered), it will render <em>much<\/em> slower than if I remove the components.<\/p>\n<p>So if my page is exactly like this:<\/p>\n<pre><code>\n    \n    \n         \n \n    \n        \n    \n\n<\/code><\/pre>\n<p>it will render <em>much<\/em> (around 10x) faster than the initial version, even though the parameters are the same. I suspect that JSF will create the entire component tree and only at runtime it will decide (depending on the supplied parameter) if it will render each other or not.<\/p>\n<p><strong>Edit<\/strong><\/p>\n<p>Almost there. I just need to include my <strong>composite component<\/strong> <em>dynamically<\/em>. I tried evaluating an ELExpression but that didn&#8217;t work. What I need is a way of accessing the current scope within the component creation, and using that to generate the proper file name:<\/p>\n<pre><code>\/\/obviously, ELExpressions don't work here\nResource resource = application.getResourceHandler().createResource(\"file-#{varStatus.loop}.xhtml\", \"components\/dynamicfaces\");\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I have a set of jsf components that are statically generated from a set of excel files (they are updated by business people). Each generated file represents a business object that has slightly different data, and all of them belong to a same class. In order to render this dynamically, the only solution I found [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6672","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6672","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6672"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6672\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6672"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}