title: Getting ui:param value in Managed bean
body: <p>I have the following <code>p:tabView</code>:</p>
  
  <pre><code>&lt;p:tabView id="tabView" dynamic="true" cache="false" activeIndex="#{navigationController.activeTabIndex}"
      onTabChange="tabChangeCommand([{name:'index', value:index}])"&gt;
      &lt;p:tab title="#{adbBundle['nav.manageUser']}" id="manageUserTab"&gt;
          &lt;h:panelGroup layout="block"&gt;
              &lt;h:form id="manageUserListForm"&gt;
                  &lt;ui:include src="/WEB-INF/includes/userList.xhtml"&gt;
                      &lt;ui:param name="showOnlyActiveUsers" value="#{true}" /&gt;
                  &lt;/ui:include&gt;
              &lt;/h:form&gt;
          &lt;/h:panelGroup&gt;
      &lt;/p:tab&gt;
      &lt;p:tab title="#{adbBundle['nav.manageRole']}" id="manageRoleTab"&gt;
          &lt;h:panelGroup layout="block"&gt;
              &lt;h:form id="manageRoleListForm"&gt;
                  &lt;ui:include src="/WEB-INF/includes/userList.xhtml"&gt;
                      &lt;ui:param name="manageRole" value="manageRole" /&gt;
                      &lt;ui:param name="showOnlyActiveUsers" value="#{false}" /&gt;
                  &lt;/ui:include&gt;
              &lt;/h:form&gt;
          &lt;/h:panelGroup&gt;
      &lt;/p:tab&gt;
  &lt;/p:tabView&gt;
  </code></pre>
  
  <p>The two tabs both of them have same include, i.e., <code>userList.xhtml</code>. Inside this <code>userList.xhtml</code> I have placed a <code>h:outputText</code> to see the value of <code>ui:param</code> <code>showOnlyActiveUsers</code> for testing purpose:</p>
  
  <pre><code>&lt;h:outputText id="showOnlyActiveUsers" value="#{showOnlyActiveUsers}" /&gt;
  </code></pre>
  
  <p>The value of this <code>h:outputText</code> changes from <code>true</code> to <code>false</code> on tab change and vice versa. </p>
  
  <p>The managed bean <code>UserListController</code> which is in view scope is the back bone for <code>userList.xhtml</code>. Since it is in view scope it is instantiating once for all these two tabs.</p>
  
  <p>I have a class <code>UserDataModel</code> which extends <code>LazyDataModel</code> of Primefaces. An instance of this class is present in <code>UserListController</code>. I am trying to set a value to a field of <code>UserDataModel</code> from the getter method of a <code>h:inputHidden</code>:</p>
  
  <pre><code>&lt;h:inputHidden value="#{userListController.showActiveOnly}" /&gt;
  </code></pre>
  
  <p>which is in <code>userList.xhtml</code> from <code>UserListController</code> as:</p>
  
  <pre><code>public String getShowActiveOnly() {
      ValueExpression expression = getFacesContext().getApplication().getExpressionFactory().createValueExpression(getFaceletContext(), "#{showOnlyActiveUsers}", Boolean.class);
      userDataModel.setShowOnlyActiveUsers(expression.getValue(getFaceletContext());
      return "";
  }
  </code></pre>
  
  <p>BUT the value which is generated by <code>expression.getValue(getFaceletContext()</code> is always <code>false</code>. I was wondering why the value in the <code>h:outputText</code> changes from <code>true</code> to <code>false</code>, but the value generated by <code>ValueExpression</code> is always <code>false</code>?</p>
  
  <p>How can I solve this issue. Any pointer would be very helpful to me.</p>
  
  <h2>Edit</h2>
  
  <pre><code>protected final FaceletContext getFaceletContext() {
      return (FaceletContext) getFacesContext().getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
  }
  </code></pre>
  
  <p>What I want to achieve is to pass the <code>ui:param</code> value to the managed bean and from there to the data model.</p>
  
  <h2>Edit</h2>
  
  <p><code>userList.xhtml</code>:</p>
  
  <pre><code>&lt;ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui" xmlns:pe="http://primefaces.org/ui/extensions"&gt;
  
      &lt;h:form id="userListForm"&gt;
          &lt;p:panel id="userListPanel" header="#{adbBundle['userList.panel.header']}" toggleable="true"&gt;
              &lt;p:dataTable var="user" id="userTable" value="#{userListController.userDataModel}" lazy="true" paginator="true" rows="10"
                  paginatorPosition="bottom"
                  paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                  rowsPerPageTemplate="10,50,100" widgetVar="userDataTable" styleClass="userTable" selectionMode="single"&gt;
  
                  &lt;f:facet name="header"&gt;
                      &lt;p:outputPanel&gt;
                          &lt;h:panelGroup layout="block" id="resetFiter" styleClass="dataTableResetFilter"&gt;
                              &lt;p:outputLabel value="#{adbBundle['filter.resetText']}" /&gt;
                              &lt;p:spacer width="10" /&gt;
                              &lt;p:commandButton icon="ui-icon-circle-close" actionListener="#{userListController.resetUserTable}"/&gt;
                          &lt;/h:panelGroup&gt;
                      &lt;/p:outputPanel&gt;
                  &lt;/f:facet&gt;
  
                  &lt;p:column id="nameColumn" headerText="#{adbBundle['name']}" sortBy="#{user.fullName}" filterBy="#{user.fullName}" styleClass="name"&gt;
                      &lt;h:outputText value="#{user.fullName}" /&gt;
                  &lt;/p:column&gt;
  
                  &lt;p:column id="statusColumn" headerText="#{adbBundle['status']}" sortBy="#{user.active}" styleClass="center status" filterBy="#{user.statusText}"
                      filterMatchMode="exact" filterOptions="#{userListController.statusOptions}"&gt;
                      &lt;h:outputText value="#{user.statusText}" /&gt;
                  &lt;/p:column&gt;
  
                  &lt;p:column id="manageRoleColumn" headerText="#{adbBundle['role']}" sortBy="#{user.role}" styleClass="center manageRole" filterBy="#{user.role}"
                      filterOptions="#{userListController.roleOptions}" rendered="#{manageRole != null and manageRole != ''}"&gt;
                      &lt;h:panelGroup layout="block"&gt;
                          &lt;p:selectOneRadio id="roleRadio" value="#{user.role}" styleClass="roleRadio"&gt;
                              &lt;f:selectItem itemValue="user" itemLabel="User" /&gt;
                              &lt;f:selectItem itemValue="manager" itemLabel="Manager" /&gt;
  
                              &lt;p:ajax listener="#{userListController.changeRole}" /&gt;
                              &lt;f:attribute name="user" value="#{user}" /&gt;
                          &lt;/p:selectOneRadio&gt;
                      &lt;/h:panelGroup&gt;
                  &lt;/p:column&gt;
              &lt;/p:dataTable&gt;
          &lt;/p:panel&gt;
  
      &lt;/h:form&gt;
  &lt;/ui:composition&gt;
  </code></pre>
  
  <p>What I want is to get the current value of that <code>ui:param</code> from the <code>userList.xhtml</code> and pass it to the managed bean by some event and set it to the <code>datamodel</code>. It is also true that the <code>datamodel</code> is instantiating only once when the managed bean is created as it is in view scope.</p>