4 Replies Latest reply on Apr 29, 2008 11:45 AM by Sergey Smirnov

    EL-code inside "rendered" always called

    Alexey Shakov Newbie

      Hi *,

      I use MyFaces+Facelets+RF 3.1.2GA and have the following code:

       <h:form>
      
       <h:selectBooleanCheckbox valueChangeListener="#{testBean.doSelect}">
       <a4j:support event="onclick" ajaxSingle="true"
       limitToList="true" reRender="myId" />
       </h:selectBooleanCheckbox>
      
       <h:outputText value="#{testBean.selected}" id="myId"></h:outputText>
      
       <h:outputLabel value="#{testBean.label}" rendered="#{testBean.rendered}"></h:outputLabel>
      
       </h:form>
      
      



      When I click the checkbox, method isRendered() in testBean is called, and even twice: during APPLY_REQUEST_VALUES and RENDER_RESPONSE phase.

      The question is: WHY?

      This code snippet is simplified. In reality i have thousands of components on the template, most of them have "rendered" attribute. The EL-code inside of this attribute is always evaluated (during AJAX-Requests), regardless of "reRender" attribute. This makes the AJAX-Requests very slow: even if I need to rerender a single component.

      How can I solve the problem?

      Thanks for any help!

        • 1. Re: EL-code inside
          Ariel Fernando Newbie

          Hi, I'm having same problem...and I don't found a solution yet.
          Did you?.

          • 2. Re: EL-code inside
            Sergey Smirnov Master

            It is possible to avoid invocations of getters (isXXX as well) on the earlier phase only using JSF 1.2 "InvokeOnComponent" feature. As soon as RichFaces 3.1.2GA (as any other 3.1.x) requires to support JSF 1.1, all the component tree nodes are decoded in order to find the elements for processing.

            Only RichFaces 3.2.0 that support only JSF 1.2 allows this.

            • 3. Re: EL-code inside
              Ariel Fernando Newbie

              Thanks Sergey!!!

              I'm using RF 3.2.0. I've not idea how to use "InvokeOnComponent", but now I'm reading about it.

              Ariel.

              • 4. Re: EL-code inside
                Sergey Smirnov Master

                Sorry, I was not clear enough.
                You do not have to use InvokeOnComponent by yourself. The framework (in our case - RichFaces) does it.
                RichFaces 3.1.x did not use it due to support JSF 1.1
                RichFaces 3.2.x uses it because does not support JSF 1.1

                So, because InvokeOnComponent is not used. RichFaces 3.1.x walks thru the component tree and decodes all nodes in order to fine needed components to process. This is why the getters are invoked on the second JSF lifecycle phase.

                RichFaces 3.2.0 does NOT walks thru the component tree, but invoke only required components using InvokeOnComponent feature. Therefore, the getters invoked only on the needed components

                This is a difference between 3.1.x and 3.2.0. If you still have to use 3.1.x you need to expect the getters invoked and manage this by yourself.