title: JSF Backing Bean constructor called multiple times
body: <p>I'm trying out JSF 2.0 (after using ICEfaces 1.8 for the past few months) and I'm trying to figure out why in JSF 2.0 my backing bean constructor gets called multiple times. </p>
  
  <p>The bean is supposed to be instantiated once upon creation, but the "Bean Initialized" text shows up whenever I click the commandButton, indicating a new Bean object being instansiated. </p>
  
  <p>The facelet page:</p>
  
  <pre><code>    &lt;?xml version='1.0' encoding='UTF-8' ?&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://java.sun.com/jsf/html"&gt;
  
      &lt;h:body&gt;
          &lt;div id="content"&gt;
              &lt;h:form id="form"&gt;
                  &lt;h:commandButton value="Toggle" action="#{bean.toggleShowMe}"/&gt;
              &lt;/h:form&gt;
  
  
              &lt;h:panelGrid rendered="#{bean.showMe}"&gt;
                  &lt;h:outputText value="Show me!"/&gt;
              &lt;/h:panelGrid&gt;
          &lt;/div&gt;
      &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The backing bean:</p>
  
  <pre><code>@ManagedBean
  @RequestScoped
  public class Bean {
      private boolean showMe = false;
  
      public boolean isShowMe() {
          return showMe;
      }
  
      public void setShowMe(boolean showMe) {
          this.showMe = showMe;
      }
  
      public void toggleShowMe(){
          System.out.println(showMe);
          if(showMe==true){
              showMe=false;
          }else{
              showMe=true;
          }
      }
      /** Creates a new instance of Bean */
      public Bean() {
          System.out.println("Bean Initialized");
      }
  
  }
  </code></pre>
  
  <p>Thats all it is. Just a simple test. The same behaviour shows itself if I use ICEfaces 2.0 and in place of the panelGrid I use: </p>
  
  <pre><code>&lt;ice:panelPopup visible="#{bean.showMe}"&gt;
  </code></pre>
  
  <p>I'd appreciate any help here. I'm at a loss to explain it.</p>
  
  <p><strong>Update</strong>: In response to Aba Dov, I @SessionScoped the bean, figuring it wouldn't be calling the constructor upon each request and ran into the same behavior. What am I missing? </p>