What is the best way to cache the result of a getter in the EL to not get too
many getter invocations? Some are called up to 80.000 times on a page(all
phases together). Please see the screenshot at:
http://docs.google.com/document/pub?id=1HEYAzXmZ6GBLimk8tNAdvGt48m53Mwq8gGEVUiFg6GI
(Showing CPU View for two page loads) Each getter is cached in the
Backingbean, and therefore only needs microseconds to execute, but when it all
gets summed up, it is a lot of time. 3/4 of the time for getters and 1/4 of the
time for the actual application logic. This happens in our application in
tr:table and tr:treeTable where we have context menus on each row. This
specific example can have up to 600 rows.
Short example (Details omitted):
<tr:treeTable value="#{Bean.model}" var="node" >
<f:facet name="nodeStamp">
<tr:column>
<tr:panelGroupLayout
rendered="#{node.kontextMenue.showContextMenue}">
<tr:panelPopup triggerType="click"
text="#{node.label}"
styleClass="panelPopupMenueMarker #{node.icon} #{node.changedStyleClass}
#{node.markiertSpezialStyle}"
rendered="#{ (node.kontextMenue.showContextMenue and
!Bean.nodeInZwischenablage) }" >
<tr:panelGroupLayout
rendered="#{node.kontextMenue.showContextMenue}">
<tr:commandLink
shortDesc="#{node.kontextMenue.zustaendigkeitAendern.tooltip}"
action="#{Bean.akZustaendigkeitAendern}"
partialSubmit="true"
rendered="#{node.kontextMenue.zustaendigkeitAendern.menueVorhanden and
node.kontextMenue.zustaendigkeitAendern.menueAktiviert and
Bean.zustaendigkeitIstAenderbar}"
useWindow="true"
returnListener="#{Bean.akZustaendigkeitAendernDialogReturned}"
onclick="closePanelPopupAK()"
>
<!-- Linktext -->
</tr:commandLink>
<!-- 15 more links, all rendered depending on node.kontextMenue.xxx rules -->
</tr:panelGroupLayout>
</tr:panelPopup>
</tr:panelGroupLayout>
</tr:column>
<!-- 7 more colums which mostly output text or icons from node -->
</f:facet>
</tr:treeTable >
Or am I doing something totally wrong? I thought to request as many properties
from the model, for example for the css classes and if things are rendered.
Only when you loop through it seems to create so many invocations.
Use case is:
Show a Tree Table which has different icons and different actions depending on
the specific row, if an action is rendered in general, or grayed out if not
applicable at this moment or in this case.
Screenshot of the GUI:
http://docs.google.com/document/pub?id=1F9ZlU2221zu07xthsG0FjYPJUm0Is4MA6GLTdrjkYQ0
What can I do different? Is there a different way to archive what I want to
show without using so many getters?
Thank you.