javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-2229

Stange behaviour with the evaluation of the rendered-attribute

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Incomplete
    • Affects Version/s: 2.1.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Windows 7
      Glassfish 3.1
      Netbeans IDE
      Enterprise Application

      Description

      I have observed a strange behaviour with the evaluation of the rendered-attribute of components and it's child components.

      I have the following xhtml page:

      index.xhtml
      <?xml version='1.0' encoding='UTF-8' ?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:f="http://java.sun.com/jsf/core">
          <h:head>
              <title>Facelet Title</title>
          </h:head>
          <h:body>
              <h:form>
                  <h:panelGrid columns="2">
                      <h:panelGroup >
                          <h:panelGroup rendered="#{testBeanOne.rendered}">
                              <h:dataTable value="#{testBeanOne.customer}" var="customer">
                                  <h:column>
                                      <f:facet name="header">
                                          <h:outputText value="Customer"/>
                                      </f:facet>
                                      <h:outputText value="#{customer.name}"/>
                                  </h:column>
                              </h:dataTable>                        
                          </h:panelGroup>
                          <h:commandButton value="Render" actionListener="#{testBeanOne.buttonListener}"/>
                      </h:panelGroup>
      
                      <h:panelGroup>
                          <h:panelGroup rendered="#{testBeanTwo.rendered}">
                              <h:outputText value="#{testBeanTwo.text}"/>
                          </h:panelGroup>
                          <h:commandButton value="Render" actionListener="#{testBeanTwo.buttonListener}"/>
                      </h:panelGroup>
                  </h:panelGrid>
              </h:form>
          </h:body>
      </html>
      

      and the associated ManagedBeans

      TestBeanOne.java
      @ManagedBean
      @SessionScoped
      public class TestBeanOne {
      
          @EJB
          private CustomerFacadeLocal customerFacadeLocal = null;
          private boolean rendered = false;
      
          /** Creates a new instance of TestBeanOne */
          public TestBeanOne() {
          }
      
          public boolean isRendered() {
              return rendered;
          }
      
          public void setRendered(boolean rendered) {
              this.rendered = rendered;
          }
      
          public List<Customer> getCustomer() {
              return customerFacadeLocal.findAll();
          }
      
          public void buttonListener(ActionEvent event) {
              rendered = !rendered;
          }
      }
      

      and

      TestBeanTwo.java
      @ManagedBean
      @SessionScoped
      public class TestBeanTwo {
      
          private boolean rendered = false;
          private String text = "example text";
      
          /** Creates a new instance of TestBeanTwo */
          public TestBeanTwo() {
          }
      
          public String getText() {
              return text;
          }
      
          public boolean isRendered() {
              return rendered;
          }
      
          public void setRendered(boolean rendered) {
              this.rendered = rendered;
          }
      
          public void buttonListener(ActionEvent event) {
              rendered = !rendered;
          }
      }
      

      Now the problem is, the method TestBeanOne.getCustomer() gets called even TestBeanOne.rendered is set to false. So when the second "render"-button that is associated with TestBeanTwo gets pressed, TestBeanOne.getCustomer() gets called while TestBeanOne.rendered is false.

      In return if TestBeanTwo.rendered is set to false and the first "render"-button that is associated with TestBeanOne gets pressed, TestBeanTwo.getText() doesn't get called. So there is an inconsistence behaviour while creating the DOM.

      Methods get called while there respective xhtml component's or parent component's "rendered"-attribute is set to false. This behaviour causes unwanted effects and breaks the whole application.

      For me occurs because I'm attempting to migrate a project from JSF 1.2/Glassfish 2.1 project to JSF 2.0/Glassfish 3.1 and this bug causes that the application doesn't work how it is supposed anymore.

        Activity

        Hide
        Manfred Riem added a comment -

        Can you please verify if it is still an issue on the latest 2.1 release?

        Show
        Manfred Riem added a comment - Can you please verify if it is still an issue on the latest 2.1 release?
        Hide
        Manfred Riem added a comment -

        Lowering priority because of no response

        Show
        Manfred Riem added a comment - Lowering priority because of no response
        Hide
        Manfred Riem added a comment -

        Lowering priority because of no response

        Show
        Manfred Riem added a comment - Lowering priority because of no response
        Hide
        Manfred Riem added a comment -

        Closing because of inactivity

        Show
        Manfred Riem added a comment - Closing because of inactivity

          People

          • Assignee:
            Unassigned
            Reporter:
            serdartosun
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: