title: JSF command button not working within included JSF page
body: <p>I'm try to build application with Primefaces 4.0 and JSF 2.2.5. I need to load content dynamically in accordance with choosen menu item.
  Here is my main page:</p>
  
  
  
  <pre class="lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:ui="http://java.sun.com/jsf/facelets"&gt;
  &lt;h:head&gt;
  &lt;title&gt;Hello, world!&lt;/title&gt;
  &lt;/h:head&gt;
  &lt;h:body&gt;
  &lt;p:layout fullPage="true"&gt;
      &lt;p:layoutUnit position="west" size="15%"&gt;
          &lt;h:form&gt;
              &lt;p:commandButton value="List1" action="#{backingBean.setCurrentPage('included.xhtml')}"
                               update=":mypanel_id" process="@this"/&gt;&lt;br/&gt;
              &lt;p:commandButton value="List2"/&gt;
          &lt;/h:form&gt;
      &lt;/p:layoutUnit&gt;
      &lt;p:layoutUnit position="center"&gt;
          &lt;p:panel id="mypanel_id"&gt;
              &lt;ui:include src="#{backingBean.page}"/&gt;
          &lt;/p:panel&gt;
          &lt;p:messages autoUpdate="true" showDetail="true" showSummary="true"/&gt;
      &lt;/p:layoutUnit&gt;
  &lt;/p:layout&gt;
  &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And this is included page:</p>
  
  
  
  <pre class="lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:p="http://primefaces.org/ui"&gt;
  &lt;h:head&gt;
  &lt;title&gt;Hello,world&lt;/title&gt;
  &lt;/h:head&gt;
  &lt;h:body&gt;
      &lt;h:outputText value="Included page"/&gt;
      &lt;h:form&gt;
          &lt;ui:repeat value="#{backingBean.items}" var="item"&gt;
              &lt;p:fieldset legend="item" toggleable="true"&gt;
                  &lt;h:outputText value="#{item}"/&gt;
                  &lt;ui:param name="it" value="#{item}"/&gt;
                  &lt;p:commandButton value="Click" style="margin-left: 50px;"
                                   actionListener="#{backingBean.actionListener}"/&gt;
              &lt;/p:fieldset&gt;
          &lt;/ui:repeat&gt;
          &lt;p:commandButton value="Test" action="#{backingBean.actionListener}"/&gt;
      &lt;/h:form&gt;
  &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Command buttons not work. Not with action nor with actionListener. What i'm doing wrong? How to build page with conditionally rendered elements, such as command buttons and fieldsets?</p>
  
  <p>P.S. Forget to say, that my bean have request scope.</p>
  
  <p>Updated:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class BackingBean {
  private List&lt;String&gt; items;
  private String currentItem;
  private String page;
  
  public BackingBean() {
      items = new ArrayList&lt;String&gt;();
  }
  
  public List&lt;String&gt; getItems() {
      if (items.size() == 0) {
          this.fillAndUpdate();
      }
      return items;
  }
  
  public void setItems(List&lt;String&gt; items) {
      this.items = items;
  }
  
  public void fillAndUpdate() {
      for (int i = 0; i &lt; 5; i++) {
          items.add("Item " + String.valueOf(i));
      }
  }
  
  public String getPage() {
      return page;
  }
  
  public void setPage(String page) {
      this.page = page;
  }
  
  public void setCurrentPage(String page) {
      this.page = page;
  }
  
  public void actionListener() {
      FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Test"));
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>UPDATED</strong></p>
  
  <p>Ok. I found the error (if someone interested). Because my bean has request scope, when i click the button in right panel my view was updated, but list of items was updated too and became empty (request scope). Now i keep selected menu in the session bean, and return that number when view rendered.</p>