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