richface4 tags' value metod inside non-rendered h:panelGround always get excuted

StackOverflow https://stackoverflow.com/questions/23192450

  •  06-07-2023
  •  | 
  •  

سؤال

like code shown below, function "handler.getXXX()" still get executed even outside panelGround's rendered value is false

    <h:panelGroup id="group" rendered="#{expression.xx}">
      <rich:list value="#{handler.getXXX()}" >
          xx
       </rich:list>
    </h:panelGroup>

but below code is working: handler.getXXX() won't be executed

<h:panelGroup id="group" rendered="#{expression.xx}">
  <h:outputText value="#{handler.getXXX()}" />
</h:panelGroup>

Do we have a solution for it?

هل كانت مفيدة؟

المحلول

Your getter methods should not perform any data retrieval, just return the data that have been retrieved previously; so that it doesn't matter if the getter was called (even multiple times) or not. If you have to have some business logic in the getter method you need to do a check that the data really have to be retrieved.

نصائح أخرى

In fact this is a bug in RichFaces: https://issues.jboss.org/browse/RF-13111

Note, this is reproducible only when partial state saving is off. If you can, turning on partial state saving should help with the issue (also with application performance overall, etc.):

<context-param>
    <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
    <param-value>true</param-value>
</context-param>

Another note: till RichFaces 4.3.0 it was reproducible with partial state on also: https://issues.jboss.org/browse/RF-11382

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top