0 Replies Latest reply on Mar 16, 2012 10:39 AM by peter.boivin

    a4j commandlink no action inside rich:extendedDataTable

    peter.boivin

      I am using Richfaces 4 for our company project.  I am fairly new at JSF and Richfaces.  I need to perfrom a sort on the columns of the extendedDataTable.  I followed the Richfaces demo example, but the action is not being fired.  I tried a simple helloworld example to see if the method from the bean would be called, and it is not.  So I don't think the problem lies in the sorting aspect.  When I am debug mode, the breakpoint inside the sort method is never called.  Below is my code.  Could you please look at it and see where I might be going wrong. 

       

      Other troubleshooting I have tried: getting rid of all forms in the page, changing all forms to a4j:region, calling the sort method outside of the datatable.  When this is done the sort method is called but the variables needed to do the sort are inside the table.

       

       

      <ui:composition xmlns="http://www.w3.org/1999/xhtml"

          xmlns:ui="http://java.sun.com/jsf/facelets"

          xmlns:a4j="http://richfaces.org/a4j"

          xmlns:h="http://java.sun.com/jsf/html"

          xmlns:f="http://java.sun.com/jsf/core"

          xmlns:c="http://java.sun.com/jsp/jstl/core"

          xmlns:rich="http://richfaces.org/rich"

          xmlns:fn="http://java.sun.com/jsp/jstl/functions">

          <h:head>

              <h:outputStylesheet library="css" name="ocs.css" />

          </h:head>

          <rich:panel headerClass="outpanelHeader">

          <a4j:log popup="false" />

              <h:panelGrid columnClasses="ocs_panel,ocs_panel_right" columns="2">

                  <h:column>

                      <h:panelGroup>

                          <rich:panel header="#{ocsMsgs.txt_registries}">

                              <h:form>

                                  <c:forEach items="#{patientRegistry.registryNameList}"

                                      var="registryName">

                                      <a4j:commandLink immediate="true"

                                          action="#{patientRegistry.setParameters}"

                                          value="#{registryName}" execute="@form"

                                          render="selectedGender,registryTable,registryPanel,selectedPayer,regFilterPopup,payerPanel,genderPanel,a1chtml,a1cSelect,a1cPanel,alcCheck,alcText,resetall,filterSelected">

                                          <f:param name="selectedRegistryName" value="#{registryName}" />

                                      </a4j:commandLink>

                                      <p />

                                  </c:forEach>

                              </h:form>

                          </rich:panel>

                          <rich:panel header="#{ocsMsgs.txt_filters}" id="fil">

                              <h:form>

                                  <h:panelGrid>

                                      <a4j:commandLink id="filterSelected"

                                          value="#{ocsMsgs.txt_filters_applied}" execute="@form"

                                          disabled="#{!patientRegistry.filterChanged}"

                                          onclick="#{rich:component('regFilterPopup')}.show();">

                                      </a4j:commandLink>

                                  </h:panelGrid>

                                  <h:commandLink id="resetall"

                                      value="#{ocsMsgs.txt_reset_all_filters}"

                                      action="#{patientRegistry.resetAllFilters}"

                                      style="#{patientRegistry.panelStyleVisible}" />

                              </h:form>

                              <ui:include src="FillInWithData.xhtml"></ui:include>

                              <ui:include src="MultiSelectCheckboxes.xhtml"></ui:include>

                          </rich:panel>

                      </h:panelGroup>

                  </h:column>

                  <h:column>

                      <h:panelGroup>

                          <h:form>

                              <rich:panel id="registryPanel" style="border:0px">

                                  <h:panelGrid rendered="#{patientRegistry.filterChanged}"

                                      columns="3" columnClasses="550px,50px,50px">

                                      <h:column>

                                      </h:column>

                                      <h:column>

                                          <h:outputText

                                              value="#{ocsMsgs['txt_export_filtered_registry_to']}"

                                              style="font-weight:bold" />

                                      </h:column>

                                      <h:column>

                                          <h:commandButton id="exportButton"

                                              image="/iCollabImages/excel.png" value="Export"

                                              action="#{patientRegistry.openExport(true)}" />

                                      </h:column>

                                  </h:panelGrid>

                                  <h:panelGrid rendered="#{patientRegistry.patientListLength > 0}"

                                      columns="3" columnClasses="550px,50px,50px">

                                      <h:column>

                                      </h:column>

                                      <h:column>

                                          <h:outputText value="#{ocsMsgs['txt_export_full_registry_to']}"

                                              style="font-weight:bold" />

                                      </h:column>

                                      <h:column>

                                          <h:commandButton id="exportFullButton"

                                              image="/iCollabImages/excel.png" value="Export"

                                              action="#{patientRegistry.openExport(false)}" />

                                      </h:column>

                                  </h:panelGrid>

                                  <rich:panel header="#{patientRegistry.selectedRegistryName}">

       

                                              <rich:extendedDataTable id="registryTable"

                                                  rowClasses="tableEvenRow, tableOddRow" var="patient"

                                                  value="#{patientRegistry.patientList}"

                                                  iterationStatusVar="index"

                                                  rendered="#{(patientRegistry.patientListLength>=0) and (patientRegistry.selectedRegistryName != null)}"

                                                  selectionMode="single"

                                                  selection="#{patientRegistry.selection}"

                                                  sortPriority="#{patientRegistry.sortPriorities}">

       

                                                  <a4j:ajax execute="@form" event="selectionchange"

                                                      listener="#{patientRegistry.selectionListener}" render="res"

                                                      oncomplete="#{rich:component('res')}.show();" />

       

                                                  <c:forEach items="#{patientRegistry.attributesMap}"

                                                      var="entry">

                                                      <c:set var="columnWidth" value="80px" />

                                                      <c:if

                                                          test='#{patientRegistry.metadataAttributesMap["registry_grid"].containsKey(entry.key)}'>

                                                          <c:set var="columnWidth"

                                                              value='#{patientRegistry.metadataAttributesMap["registry_grid"].get(entry.key).displayWidth}px' />

                                                      </c:if>

                                                      <c:set var="columnRendered" value="false" />

                                                      <c:if

                                                          test='#{patientRegistry.metadataAttributesMap["registry_grid"].containsKey(entry.key)}'>

                                                          <c:set var="columnRendered" value="true" />

                                                      </c:if>

                                                      <rich:column width="#{columnWidth}"

                                                          sortIconAscending="dataTableAscIcon"

                                                          sortIconDescending="dataTableDescIcon"

                                                          rendered="#{columnRendered}"

                                                          sortBy="#{entry.value[patient.id]}"

                                                           index="index">

                                                          <c:choose>

                                                              <c:when test="#{entry.key=='txt_bp'}">

                                                                  <f:facet name="header">

                                                                      <h:panelGrid columns="2">

                                                                          <a4j:commandLink execute="@this"

                                                                              value="#{ocsMsgs[entry.key]}" render="registryTable"

                                                                              action="#{patientRegistry.sort}">

                                                                              <f:param name="sortProperty"

                                                                                  value="#{entry.value[patient.id]}" />

                                                                          </a4j:commandLink>

                                                                          <h:graphicImage

                                                                              value="/WebContent/images/down_icon.gif"

                                                                              rendered="#{patientRegistry.sortsOrders['#{entry.value[patient.id]}']=='descending'}" />

                                                                          <h:graphicImage

                                                                              value="/WebContent/images/up_icon.gif.gif"

                                                                              rendered="#{patientRegistry.sortsOrders['#{entry.value[patient.id]}']=='ascending'}" />

                                                                      </h:panelGrid>

                                                                  </f:facet>

                                                              </c:when>

                                                              <c:otherwise>

                                                                  <f:facet name="header">

                                                                      <h:panelGrid columns="2">

                                                                          <a4j:commandLink execute="@this"

                                                                              value="#{ocsMsgs[entry.key]}"

                                                                              render="registryPanel, registryTable"

                                                                              action="#{patientRegistry.sort}">

                                                                              <f:param name="sortProperty"

                                                                                  value="#{entry.value[patient.id]}" />

                                                                          </a4j:commandLink>

                                                                          <h:graphicImage

                                                                              value="/WebContent/images/down_icon.gif"

                                                                              rendered="#{patientRegistry.sortsOrders['#{entry.value[patient.id]}']=='descending'}" />

                                                                          <h:graphicImage

                                                                              value="/WebContent/images/up_icon.gif.gif"

                                                                              rendered="#{patientRegistry.sortsOrders['#{entry.value[patient.id]}']=='ascending'}" />

                                                                      </h:panelGrid>

                                                                  </f:facet>

                                                              </c:otherwise>

                                                          </c:choose>

                                                          <h:outputText value="#{entry.value[patient.id]}"

                                                              rendered="#{patientRegistry.patientListLength>0}">

                                                              <c:if

                                                                  test='#{patientRegistry.metadataAttributesMap["registry_grid"].get(entry.key).dataType.equals("date")}'>

                                                                  <f:convertDateTime dateStyle="medium" />

                                                              </c:if>

                                                          </h:outputText>

                                                      </rich:column>

                                                  </c:forEach>

                                              </rich:extendedDataTable>

                                      <c:if

                                          test="#{(patientRegistry.patientListLength == 0) and (patientRegistry.selectedRegistryName != null) }">

                                          <br />

                                          <h:outputText value="#{ocsMsgs['txt_patient_not_found']}"

                                              styleClass="ocs_aligncenter" />

                                          <br />

                                          <br />

                                      </c:if>

                                  </rich:panel>

                              </rich:panel>

                          </h:form>

                      </h:panelGroup>

                  </h:column>

              </h:panelGrid>

          </rich:panel>

          <ui:include src="RegistryPopup.xhtml"></ui:include>

          <ui:include src="RegistryFilterPopup.xhtml"></ui:include>

          <a4j:status onstart="#{rich:component('loadingpage')}.show()"

              onstop="#{rich:component('loadingpage')}.hide()" />

          <rich:popupPanel id="loadingpage" autosized="true">

              <h:outputText value="#{ocsMsgs['txt_loading_page']}" />

          </rich:popupPanel>

      </ui:composition>

       


      Code from managed bean:

       

      public void sort() {

       

          String property = FacesContext.getCurrentInstance()

                  .getExternalContext().getRequestParameterMap()

                  .get(SORT_PROPERTY_PARAMETER);

          if (property != null) {

              SortOrder currentPropertySortOrder = sortsOrders.get(property);

              if (multipleSorting) {

                  if (!sortPriorities.contains(property)) {

                  sortPriorities.add(property);

                  }

              } else {

                  sortsOrders.clear();

              }

              if (currentPropertySortOrder == null

                      || currentPropertySortOrder.equals(SortOrder.descending)) {

                  sortsOrders.put(property, SortOrder.ascending);

              } else {

                  sortsOrders.put(property, SortOrder.descending);

              }

          }

      }