title: PrimeFaces dataTable: ajax catches filter event but not sort event
body: <p>I am able to catch the filter event and call a function in the backing bean but using similar code I can not catch the sort event. The strange thing is that I have several pages where I do "exactly" the same and work just fine. The dataTable simply does not react to the mouse click when I try to sort by any column. The backing bean sort listener does not get called but the filter listener does.</p>
  
  <p>Thanks in advance for any help.</p>
  
  <p>in the code below, TemplateBasic.xhtml simply inserts "content" in an h:form</p>
  
  <p>This is the xhtml: (the ajax commands are about the middle, just before the end of the dataTable)</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8' ?&gt;
  &lt;!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;ui:composition xmlns="http://www.w3.org/1999/xhtml"
                  xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                  template="/TemplateBasic.xhtml"
                  xmlns:h="http://xmlns.jcp.org/jsf/html"
                  xmlns:f="http://xmlns.jcp.org/jsf/core"
                  xmlns:p="http://primefaces.org/ui"&gt;
  
    &lt;ui:define name="content"&gt;
  
      &lt;table&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;p:graphicImage url="#{resource['images/goldCup3small.jpg']}" height="30" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;h2&gt;#{listStandingsBean.getChampionshipsStandingsTitle()}&lt;/h2&gt;&lt;/td&gt;
          &lt;td&gt;&lt;p:graphicImage url="#{resource['images/goldCup3small.jpg']}" height="30" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
  
      &lt;p:dataTable id="standingsList"
                   var="item" 
                   value="#{listStandingsBean.standings}" 
                   widgetVar="standingsTable"
                   emptyMessage="#{mainBean.getListEmptyMsg()}" 
                   filteredValue="#{listStandingsBean.filteredStandings}"
                   style="white-space: pre-line; font-stretch: condensed; width: 100%; padding: 0px" 
                   scrollable="true"
                   scrollRows="20"
                   scrollHeight="250"
                   scrollWidth="90%"
                   liveScroll="false"
                   resizableColumns="true"
                   rowIndexVar="rowIndex"
                   &gt;
  
        &lt;f:facet name="header"&gt;
          &lt;p:outputPanel&gt;
            &lt;h:outputText value="#{mainBean.getSearchAllFieldsLabel()}" /&gt;
            &lt;p:inputText id="globalFilter" 
                         onkeyup="PF( 'standingsTable' ).filter()" 
                         style="width:150px" 
                         placeholder="#{mainBean.getEnterKeywordPlaceholder()}"/&gt;
  
            &lt;p:commandButton actionListener="#{listStandingsBean.clickReturn()}"
                             icon="fa fa-fw fa-arrow-left"
                             title="#{mainBean.getReturnButtonTitle()}"
                             onclick="PF('dlgWait').show();"
                             ajax="true"
                             style="float: left"/&gt;
  
          &lt;/p:outputPanel&gt;
        &lt;/f:facet&gt;
  
        &lt;p:column headerText="#{listStandingsBean.getRowTxt()}" 
                  footerText="#{listStandingsBean.getRowTxt()}" 
                  width="10" style="text-align: center"&gt;
          &lt;h:outputText value="#{rowIndex+1}" /&gt;
        &lt;/p:column&gt;
  
        &lt;p:column filterBy="#{item.id.year}" 
                  sortBy="#{item.id.year}" 
                  headerText="#{listStandingsBean.getYearTxt()}" 
                  footerText="#{listStandingsBean.getYearTxt()}" 
                  filterMatchMode="exact" width="70" style="text-align: center; padding: 1px"&gt;
          &lt;f:facet name="filter"&gt;
            &lt;p:spinner size="3" value="#{listStandingsBean.currYear}"
                       onchange="PF( 'standingsTable' ).filter()"
                       styleClass="year-spinner" &gt;
              &lt;f:converter converterId="javax.faces.Integer" /&gt;
            &lt;/p:spinner&gt;
          &lt;/f:facet&gt;
          &lt;h:outputText value="#{item.id.year}"/&gt;
        &lt;/p:column&gt;
  
        &lt;p:column filterBy="#{listStandingsBean.getUserName( item.id.user )}"
                  sortBy="#{listStandingsBean.getUserName( item.id.user )}"
                  headerText="#{listStandingsBean.getUserTxt()}" 
                  footerText="#{listStandingsBean.getUserTxt()}" 
                  filterMatchMode="contains" width="120" style="white-space: pre-line; padding: 2px"&gt;
          &lt;f:facet name="filter"&gt;  
            &lt;p:inputText size="10" onkeyup="PF( 'standingsTable' ).filter()" /&gt; 
          &lt;/f:facet&gt;
          &lt;h:outputText value="#{listStandingsBean.getUserName( item.id.user )}" /&gt;
        &lt;/p:column&gt;
  
        &lt;p:column filterBy="#{item.id.level}" 
                  sortBy="#{item.id.level}" 
                  headerText="#{listStandingsBean.getLevelTxt()}" 
                  footerText="#{listStandingsBean.getLevelTxt()}" 
                  filterMatchMode="contains" width="70" style="padding: 2px"&gt;
          &lt;f:facet name="filter" &gt;
            &lt;p:selectOneMenu onchange="PF( 'standingsTable' ).filter()"&gt;
              &lt;f:selectItem noSelectionOption="true"  /&gt;
              &lt;f:selectItems value="#{listStandingsBean.levels}"  /&gt;
            &lt;/p:selectOneMenu&gt;
          &lt;/f:facet&gt;
          &lt;h:outputText value="#{listStandingsBean.getLevelName( item.id.level )}" /&gt;
        &lt;/p:column&gt;
  
        &lt;p:column filterBy="#{listStandingsBean.getChampionshipName( item )}" 
                  sortBy="#{listStandingsBean.getChampionshipName( item )}" 
                  headerText="#{listStandingsBean.getChampionshipTxt()}" 
                  footerText="#{listStandingsBean.getChampionshipTxt()}" 
                  filterMatchMode="contains" width="130" style="white-space: pre-line; padding: 2px"&gt;
          &lt;h:outputText value="#{listStandingsBean.getChampionshipName( item )}" /&gt;
        &lt;/p:column&gt;
  
        &lt;p:column sortBy="#{item.pointsSd+item.pointsRd}" 
                  style="white-space: pre-line; text-align: right" 
                  headerText="#{listStandingsBean.getSR_DriverPointsTxt()}" 
                  footerText="#{listStandingsBean.getSR_DriverPointsTxt()}" width="60"&gt;
          &lt;h:outputText value="#{item.pointsSd+item.pointsRd}"/&gt;
        &lt;/p:column&gt;
  
        &lt;p:column sortBy="#{item.pointsSd}" style="white-space: pre-line; text-align: right" 
                  headerText="#{listStandingsBean.getS_DriverPointsTxt()}" 
                  footerText="#{listStandingsBean.getS_DriverPointsTxt()}" width="60"&gt;
          &lt;h:outputText value="#{item.pointsSd}" /&gt;
        &lt;/p:column&gt;
  
        &lt;p:column sortBy="#{item.pointsRd}" style="white-space: pre-line; text-align: right" 
                  headerText="#{listStandingsBean.getR_DriverPointsTxt()}" 
                  footerText="#{listStandingsBean.getR_DriverPointsTxt()}" width="60"&gt;
          &lt;h:outputText value="#{item.pointsRd}"/&gt;
        &lt;/p:column&gt;
  
        &lt;p:column sortBy="#{item.pointsEd}" style="white-space: pre-line; text-align: right" 
                  headerText="#{listStandingsBean.getE_DriverPointsTxt()}" 
                  footerText="#{listStandingsBean.getE_DriverPointsTxt()}" width="60"&gt;
          &lt;h:outputText value="#{item.pointsEd}"/&gt;
        &lt;/p:column&gt;
  
        &lt;p:column sortBy="#{item.pointsSo}" style="white-space: pre-line; text-align: right" 
                  headerText="#{listStandingsBean.getS_OwnerPointsTxt()}" 
                  footerText="#{listStandingsBean.getS_OwnerPointsTxt()}" width="60"&gt;
          &lt;h:outputText value="#{item.pointsSo}" /&gt;
        &lt;/p:column&gt;
  
        &lt;p:column sortBy="#{item.pointsRo}" style="white-space: pre-line; text-align: right" 
                  headerText="#{listStandingsBean.getR_OwnerPointsTxt()}" 
                  footerText="#{listStandingsBean.getR_OwnerPointsTxt()}" width="60"&gt;
          &lt;h:outputText value="#{item.pointsRo}"/&gt;
        &lt;/p:column&gt;
  
        &lt;p:column sortBy="#{item.pointsEo}" style="white-space: pre-line; text-align: right" 
                  headerText="#{listStandingsBean.getE_OwnerPointsTxt()}" 
                  footerText="#{listStandingsBean.getE_OwnerPointsTxt()}" width="60"&gt;
          &lt;h:outputText value="#{item.pointsEo}"/&gt;
        &lt;/p:column&gt;
        &lt;p:ajax event="filter" update="contentForm:graphsAccordion"
                listener="#{listStandingsBean.filterEvent}"/&gt;
        &lt;p:ajax event="sort" update="contentForm:graphsAccordion"
                listener="#{listStandingsBean.sortEvent}" /&gt;
      &lt;/p:dataTable&gt;
  
      &lt;p:remoteCommand name="onCompleteAuto" oncomplete="PF('standingsTable').filter()" autoRun="true" /&gt;
  
      &lt;p:accordionPanel id="graphsAccordion" 
                        widgetVar="graphsAccordion"
                        multiple="true"
                        activeIndex="-1"
                        style="width:90%" &gt;
        &lt;p:tab title="#{listStandingsBean.getSR_DriverPointsTxt()}"&gt;
          &lt;div align="left"&gt;
            &lt;p:chart id="standingsChartSRD"
                     type="bar" 
                     model="#{listStandingsBean.getChartModel(0)}" 
                     responsive="true"
                     style="height:#{listStandingsBean.chartHeight}px; width:80%; "
                     /&gt;
          &lt;/div&gt;
        &lt;/p:tab&gt;
  
        &lt;p:tab title="#{listStandingsBean.getS_DriverPointsTxt()}"&gt;
          &lt;div align="left"&gt;
            &lt;p:chart id="standingsChartSD"
                     type="bar" 
                     model="#{listStandingsBean.getChartModel(1)}" 
                     responsive="true"
                     style="height:#{listStandingsBean.chartHeight}px; width:80%; "
                     /&gt;
          &lt;/div&gt;
        &lt;/p:tab&gt;
  
        &lt;p:tab title="#{listStandingsBean.getR_DriverPointsTxt()}"&gt;
          &lt;div align="left"&gt;
            &lt;p:chart id="standingsChartRD"
                     type="bar" 
                     model="#{listStandingsBean.getChartModel(2)}" 
                     responsive="true"
                     style="height:#{listStandingsBean.chartHeight}px; width:80%; "
                     /&gt;
          &lt;/div&gt;
        &lt;/p:tab&gt;
  
        &lt;p:tab title="#{listStandingsBean.getE_DriverPointsTxt()}"&gt;
          &lt;div align="left"&gt;
            &lt;p:chart id="standingsChartED"
                     type="bar" 
                     model="#{listStandingsBean.getChartModel(3)}" 
                     responsive="true"
                     style="height:#{listStandingsBean.chartHeight}px; width:80%; "
                     /&gt;
          &lt;/div&gt;
        &lt;/p:tab&gt;
  
        &lt;p:tab title="#{listStandingsBean.getS_OwnerPointsTxt()}"&gt;
          &lt;div align="left"&gt;
            &lt;p:chart id="standingsChartSO"
                     type="bar" 
                     model="#{listStandingsBean.getChartModel(4)}" 
                     responsive="true"
                     style="height:#{listStandingsBean.chartHeight}px; width:80%; "
                     /&gt;
          &lt;/div&gt;
        &lt;/p:tab&gt;
  
        &lt;p:tab title="#{listStandingsBean.getR_OwnerPointsTxt()}"&gt;
          &lt;div align="left"&gt;
            &lt;p:chart id="standingsChartRO"
                     type="bar" 
                     model="#{listStandingsBean.getChartModel(5)}" 
                     responsive="true"
                     style="height:#{listStandingsBean.chartHeight}px; width:80%; "
                     /&gt;
          &lt;/div&gt;
        &lt;/p:tab&gt;
  
        &lt;p:tab title="#{listStandingsBean.getE_OwnerPointsTxt()}"&gt;
          &lt;div align="left"&gt;
            &lt;p:chart id="standingsChartEO"
                     type="bar" 
                     model="#{listStandingsBean.getChartModel(6)}" 
                     responsive="true"
                     style="height:#{listStandingsBean.chartHeight}px; width:80%; "
                     /&gt;
          &lt;/div&gt;
        &lt;/p:tab&gt;
      &lt;/p:accordionPanel&gt;
  
  
    &lt;/ui:define&gt;
  
  
  &lt;/ui:composition&gt;
  </code></pre>
  
  <p>and the backing Bean:</p>
  
  <pre><code>@ManagedBean( name = "listStandingsBean" )
  @ViewScoped
  public class ListStandingsBean {
  
    @ManagedProperty( value = "#{mainBean}" )
    private MainBean mainBean;
  
    private ModelForView theModel;
    private Controller theController;
  
    private List&lt;Standings&gt; standings;
    private List&lt;Standings&gt; filteredStandings;
    private Long index = 0L;
    private HorizontalBarChartModel horizontalBarModel[];
  
    /**
     * Creates a new instance of StandingsBean
     */
    public ListStandingsBean() {
      horizontalBarModel = new HorizontalBarChartModel[ 7 ];
    }
  
    public MainBean getMainBean() {
      return mainBean;
    }
  
    public void setMainBean( MainBean mainBean ) {
      this.mainBean = mainBean;
    }
  
    @PostConstruct
    public void init() {
      theModel = mainBean.getModel();
      theController = mainBean.getController();
      index = 0L;
      standings = theModel.getStandings();
    }
  
    //
    // queries
    //
    public Integer getCurrYear() {
      Calendar c = new GregorianCalendar();
      return c.get( Calendar.YEAR );
    }
  
    public void setCurrYear( Integer y ) {
    }
  
    public void setStandings( List&lt;Standings&gt; standings ) {
      this.standings = standings;
    }
  
    public List&lt;Standings&gt; getStandings() {
      return standings;
    }
  
    public Long getIndex() {
      return ++index;
    }
  
    public List&lt;Byte&gt; getLevels() {
      Byte levels[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
      return Arrays.asList( levels );
    }
  
    public List&lt;Standings&gt; getFilteredStandings() {
      index = 0L;
      return filteredStandings;
    }
  
    public void setFilteredStandings( List&lt;Standings&gt; filteredStandings ) {
      this.filteredStandings = filteredStandings;
  
      this.updateCharts();
    }
  
    /*
     * user actions
     */
    public void clickReturn() {
      theController.clickReturn( UI.LIST_STANDINGS );
    }
  
    public void updateCharts() {
      for( int chMode = 0; chMode &lt; 7; chMode++ ) {
  
        HorizontalBarChartModel model = new HorizontalBarChartModel();
        model.setShadow( false );
        model.setZoom( false );
        model.setMouseoverHighlight( false );
  //    model.setLegendCols( 4 );
        model.setAnimate( false );
        model.setMouseoverHighlight( true );
        model.setBarMargin( 0 );
        model.setBarPadding( 1 );
  //    model.setLegendPlacement( LegendPlacement.OUTSIDE );
  //    model.setExtender( "standingsChartExtender" );
  //    model.setLegendPosition( "ne" );
        model.setShowPointLabels( true );
        model.setShowDatatip( false );
        model.getAxes()
          .put( AxisType.Y, new CategoryAxis( "Driver Level_Championship" ) );
        Axis xAxis = model.getAxis( AxisType.X );
        xAxis.setLabel( "Points" );
        xAxis.setTickAngle( 0 );
  
        if( filteredStandings == null || filteredStandings.size() &lt;= 0 ){
          horizontalBarModel[chMode] = new HorizontalBarChartModel();
          continue;
        }
        Collections.reverse( filteredStandings );
        ChartSeries series = new ChartSeries();
        //series.setLabel(  );
        for( Standings s : filteredStandings ) {
          String dataLabel
                 = theModel.getUserFullName(
              s.getId().getUser() )
                   + " L" + s.getId().getLevel()
                   + "_C" + s.getId().getChampionship();
          switch( chMode ) {
            case ChMode.SRD:series.set( dataLabel, (int)( s.getPointsSd() + s.getPointsRd() ) );
              break;
            case ChMode.SD: series.set( dataLabel, (int)( s.getPointsSd() ) );
              break;
            case ChMode.RD: series.set( dataLabel, (int)( s.getPointsRd() ) );
              break;
            case ChMode.ED: series.set( dataLabel, (int)( s.getPointsEd() ) );
              break;
            case ChMode.SO: series.set( dataLabel, (int)( s.getPointsSo() ) );
              break;
            case ChMode.RO: series.set( dataLabel, (int)( s.getPointsRo() ) );
              break;
            case ChMode.EO: series.set( dataLabel, (int)( s.getPointsEo() ) );
              break;
          }
        }
        model.addSeries( series );
        Collections.reverse( filteredStandings );
  
        horizontalBarModel[chMode] = model;
      }
    }
  
    public int getChartHeight() {
      return 60 + 15 * ( filteredStandings == null ? standings.size() : filteredStandings.size() );
    }
  
    public HorizontalBarChartModel getChartModel( int chMode ) {
      return horizontalBarModel[chMode];
    }
  
    ////////////////////////////////////////////////////////
    // Functionality Methods
    ////////////////////////////////////////////////////////
    public String getUserName( long userNumber ) {
      return theModel.getUserFullName( userNumber );
    }
  
    public String getChampionshipName( Standings item ) {
      return item == null ? "Unknown"
             : theModel
          .getChampionshipName(
            item.getId()
              .getLevel(),
            item.getId()
              .getChampionship()
          );
    }
  
    public String getLevelName( int level ) {
      String[] levelName = {
        "Planet",
        "Intl. Region",
        "Country",
        "Nat. Region",
        "State",
        "Municipality",
        "Venue",
        "Variant"
      };
      return level + " " + levelName[ level ];
  
    }
  
    private static class ChMode {
  
      public static final int SRD = 0;
      public static final int SD = 1;
      public static final int RD = 2;
      public static final int ED = 3;
      public static final int SO = 4;
      public static final int RO = 5;
      public static final int EO = 6;
  
      public ChMode() {
      }
    }
  
    public String getChampionshipsStandingsTitle() {
      return java.util.ResourceBundle.getBundle( "View/BundleViewSpanish" )
        .getString( "CHAMPIONSHIPS STANDINGS" );
    }
  
    public String getRowTxt() {
      return java.util.ResourceBundle.getBundle( "View/BundleViewSpanish" )
        .getString( "ROW" );
    }
  
    public String getYearTxt() {
      return java.util.ResourceBundle.getBundle( "View/BundleViewSpanish" )
        .getString( "YEAR" );
    }
  
    public String getUserTxt() {
      return java.util.ResourceBundle.getBundle( "View/BundleViewSpanish" )
        .getString( "USER" );
    }
  
    public String getLevelTxt() {
      return java.util.ResourceBundle.getBundle( "View/BundleViewSpanish" )
        .getString( "LEVEL" );
    }
  
    public String getChampionshipTxt() {
      return java.util.ResourceBundle.getBundle( "View/BundleViewSpanish" )
        .getString( "CHAMPIONSHIP" );
    }
  
    public String getSR_DriverPointsTxt() {
      return java.util.ResourceBundle.getBundle( "View/BundleViewSpanish" )
        .getString( "SR DRIVER POINTS" );
    }
  
    public String getS_DriverPointsTxt() {
      return java.util.ResourceBundle.getBundle( "View/BundleViewSpanish" )
        .getString( "S DRIVER POINTS" );
    }
  
    public String getR_DriverPointsTxt() {
      return java.util.ResourceBundle.getBundle( "View/BundleViewSpanish" )
        .getString( "R DRIVER POINTS" );
    }
  
    public String getE_DriverPointsTxt() {
      return java.util.ResourceBundle.getBundle( "View/BundleViewSpanish" )
        .getString( "E DRIVER POINTS" );
    }
  
    public String getS_OwnerPointsTxt() {
      return java.util.ResourceBundle.getBundle( "View/BundleViewSpanish" )
        .getString( "S OWNER POINTS" );
    }
  
    public String getR_OwnerPointsTxt() {
      return java.util.ResourceBundle.getBundle( "View/BundleViewSpanish" )
        .getString( "R OWNER POINTS" );
    }
  
    public String getE_OwnerPointsTxt() {
      return java.util.ResourceBundle.getBundle( "View/BundleViewSpanish" )
        .getString( "E OWNER POINTS" );
    }
  
    public void sortEvent( SortEvent e ){
      e.getSortColumn();
    }
  
    public void filterEvent( FilterEvent e ){
      e.toString();
    }
  }
  </code></pre>