title: JSF disable button when table row is selected and row selection listener is called
body: <p>The case is simple: i want to disable a button when a table row is selected and the row selection listener decides to hide it (sets a boolean value to false in the bean). Here is a portion of my view:</p>
  
  <pre><code>&lt;h:form id="report-configurator"&gt;   
  
      &lt;p:panel&gt;
          &lt;p:outputPanel styleClass="normalText paragraph"&gt;
              Configure the Templates, the Collections and the Variables (aka Form fields) for the reports. 
              Define and associate the core elements which are used in the reports.&lt;br/&gt;
              [View, edit, add and associate] 
          &lt;/p:outputPanel&gt;
  
          &lt;p:accordionPanel dynamic="true" cache="true" style="width:96%;margin:0 auto;" &gt;
          &lt;p:tab title="Templates" titleStyleClass="accordionHeader"&gt;
              &lt;p:panelGrid columns="2" cellpadding="10" columnClasses="twoEqualColumns top-align, twoEqualColumns top-align"&gt;
                  &lt;p:panel header="Registered Templates"&gt;
                      &lt;p:dataTable id="imagetypes" var="cRImageType" 
                                  value="#{reportConfiguratorBean.getCRImageTypes()}" 
                                  rowKey="#{cRImageType.imTypeId}" 
                                  paginator="true"
                                  paginatorAlwaysVisible="false"
                                  paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                  rowsPerPageTemplate="10,20,50"
                                  sortMode="multiple" 
                                  rows="10" 
                                  filteredValue="#{reportConfiguratorBean.filteredCRImageTypes}" 
                                  selection="#{reportConfiguratorBean.selectedCRImageType}" 
                                  selectionMode="single" &gt;    
                      &lt;p:ajax event="rowSelect" listener="#{reportConfiguratorBean.setSelectedRow}" update="deleteCommand1" /&gt;
                      &lt;p:ajax event="rowUnselect" listener="#{reportConfiguratorBean.unsetSelectedRow}"/&gt;
  
                      ...
  
                      &lt;f:facet name="footer"&gt;
  
                      &lt;p:commandButton id="deleteCommand1" onclick="dlg5.show()" 
                                              value="Delete"
                                              disabled="#{reportConfiguratorBean.renderedDeleteProtocol}"
                                              update=":report-configurator:deleteSingleImageType" /&gt;
  </code></pre>
  
  <p>and here is the code in my bean for the row selector:</p>
  
  <pre><code>public void setSelectedRow(SelectEvent event) {
      Long imVirtualId = selectedCRImageType.getImTypeId();
      virtualId = selectedCRImageType.getImTypeId().toString();
      System.out.println("&gt;&gt;&gt;ROW SELECTION LISTENER 2: Selected row for virtualId value: " + virtualId);
      this.selectedCRImageType.setImTypeId(imVirtualId);
      this.setSelectedCRImageType(selectedCRImageType);
      System.out.println("&gt;&gt;&gt; CRImageType object selected: " + selectedCRImageType);
      getAssocImTypesOnLoad();
      renderedDeleteProtocol = false;
      System.out.println("&gt;&gt;&gt;&gt; RENDER DELETE BUTTON: " + renderedDeleteProtocol);
  }
  </code></pre>
  
  <p>The row selection listener works, since i can press the button and delete the selected row and so on. I can also see that it sets the variable 'renderedDeleteProtocol' to false. The problem is that the button in the 'disabled' attribute at button declaration does not get beans response.</p>
  
  <p>Any ideas? </p>