PrimeFaces dataTable:ajax捕获过滤器事件但不捕获排序事件

时间:2018-02-24 19:56:31

标签: ajax sorting events primefaces datatable

我能够捕获过滤器事件并在辅助bean中调用一个函数,但使用类似的代码我无法捕获sort事件。奇怪的是,我有几页我在做什么"确切地说"同样的,工作得很好。当我尝试按任何列排序时,dataTable对鼠标单击没有反应。不会调用辅助bean排序侦听器,但过滤器侦听器会调用。

提前感谢您的帮助。

在下面的代码中,TemplateBasic.xhtml只是插入"内容"在h:form

这是xhtml :( ajax命令大约是中间的,就在dataTable结束之前)

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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">

  <ui:define name="content">

    <table>
      <tr>
        <td><p:graphicImage url="#{resource['images/goldCup3small.jpg']}" height="30" /></td>
        <td><h2>#{listStandingsBean.getChampionshipsStandingsTitle()}</h2></td>
        <td><p:graphicImage url="#{resource['images/goldCup3small.jpg']}" height="30" /></td>
      </tr>
    </table>

    <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"
                 >

      <f:facet name="header">
        <p:outputPanel>
          <h:outputText value="#{mainBean.getSearchAllFieldsLabel()}" />
          <p:inputText id="globalFilter" 
                       onkeyup="PF( 'standingsTable' ).filter()" 
                       style="width:150px" 
                       placeholder="#{mainBean.getEnterKeywordPlaceholder()}"/>

          <p:commandButton actionListener="#{listStandingsBean.clickReturn()}"
                           icon="fa fa-fw fa-arrow-left"
                           title="#{mainBean.getReturnButtonTitle()}"
                           onclick="PF('dlgWait').show();"
                           ajax="true"
                           style="float: left"/>

        </p:outputPanel>
      </f:facet>

      <p:column headerText="#{listStandingsBean.getRowTxt()}" 
                footerText="#{listStandingsBean.getRowTxt()}" 
                width="10" style="text-align: center">
        <h:outputText value="#{rowIndex+1}" />
      </p:column>

      <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">
        <f:facet name="filter">
          <p:spinner size="3" value="#{listStandingsBean.currYear}"
                     onchange="PF( 'standingsTable' ).filter()"
                     styleClass="year-spinner" >
            <f:converter converterId="javax.faces.Integer" />
          </p:spinner>
        </f:facet>
        <h:outputText value="#{item.id.year}"/>
      </p:column>

      <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">
        <f:facet name="filter">  
          <p:inputText size="10" onkeyup="PF( 'standingsTable' ).filter()" /> 
        </f:facet>
        <h:outputText value="#{listStandingsBean.getUserName( item.id.user )}" />
      </p:column>

      <p:column filterBy="#{item.id.level}" 
                sortBy="#{item.id.level}" 
                headerText="#{listStandingsBean.getLevelTxt()}" 
                footerText="#{listStandingsBean.getLevelTxt()}" 
                filterMatchMode="contains" width="70" style="padding: 2px">
        <f:facet name="filter" >
          <p:selectOneMenu onchange="PF( 'standingsTable' ).filter()">
            <f:selectItem noSelectionOption="true"  />
            <f:selectItems value="#{listStandingsBean.levels}"  />
          </p:selectOneMenu>
        </f:facet>
        <h:outputText value="#{listStandingsBean.getLevelName( item.id.level )}" />
      </p:column>

      <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">
        <h:outputText value="#{listStandingsBean.getChampionshipName( item )}" />
      </p:column>

      <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">
        <h:outputText value="#{item.pointsSd+item.pointsRd}"/>
      </p:column>

      <p:column sortBy="#{item.pointsSd}" style="white-space: pre-line; text-align: right" 
                headerText="#{listStandingsBean.getS_DriverPointsTxt()}" 
                footerText="#{listStandingsBean.getS_DriverPointsTxt()}" width="60">
        <h:outputText value="#{item.pointsSd}" />
      </p:column>

      <p:column sortBy="#{item.pointsRd}" style="white-space: pre-line; text-align: right" 
                headerText="#{listStandingsBean.getR_DriverPointsTxt()}" 
                footerText="#{listStandingsBean.getR_DriverPointsTxt()}" width="60">
        <h:outputText value="#{item.pointsRd}"/>
      </p:column>

      <p:column sortBy="#{item.pointsEd}" style="white-space: pre-line; text-align: right" 
                headerText="#{listStandingsBean.getE_DriverPointsTxt()}" 
                footerText="#{listStandingsBean.getE_DriverPointsTxt()}" width="60">
        <h:outputText value="#{item.pointsEd}"/>
      </p:column>

      <p:column sortBy="#{item.pointsSo}" style="white-space: pre-line; text-align: right" 
                headerText="#{listStandingsBean.getS_OwnerPointsTxt()}" 
                footerText="#{listStandingsBean.getS_OwnerPointsTxt()}" width="60">
        <h:outputText value="#{item.pointsSo}" />
      </p:column>

      <p:column sortBy="#{item.pointsRo}" style="white-space: pre-line; text-align: right" 
                headerText="#{listStandingsBean.getR_OwnerPointsTxt()}" 
                footerText="#{listStandingsBean.getR_OwnerPointsTxt()}" width="60">
        <h:outputText value="#{item.pointsRo}"/>
      </p:column>

      <p:column sortBy="#{item.pointsEo}" style="white-space: pre-line; text-align: right" 
                headerText="#{listStandingsBean.getE_OwnerPointsTxt()}" 
                footerText="#{listStandingsBean.getE_OwnerPointsTxt()}" width="60">
        <h:outputText value="#{item.pointsEo}"/>
      </p:column>
      <p:ajax event="filter" update="contentForm:graphsAccordion"
              listener="#{listStandingsBean.filterEvent}"/>
      <p:ajax event="sort" update="contentForm:graphsAccordion"
              listener="#{listStandingsBean.sortEvent}" />
    </p:dataTable>

    <p:remoteCommand name="onCompleteAuto" oncomplete="PF('standingsTable').filter()" autoRun="true" />

    <p:accordionPanel id="graphsAccordion" 
                      widgetVar="graphsAccordion"
                      multiple="true"
                      activeIndex="-1"
                      style="width:90%" >
      <p:tab title="#{listStandingsBean.getSR_DriverPointsTxt()}">
        <div align="left">
          <p:chart id="standingsChartSRD"
                   type="bar" 
                   model="#{listStandingsBean.getChartModel(0)}" 
                   responsive="true"
                   style="height:#{listStandingsBean.chartHeight}px; width:80%; "
                   />
        </div>
      </p:tab>

      <p:tab title="#{listStandingsBean.getS_DriverPointsTxt()}">
        <div align="left">
          <p:chart id="standingsChartSD"
                   type="bar" 
                   model="#{listStandingsBean.getChartModel(1)}" 
                   responsive="true"
                   style="height:#{listStandingsBean.chartHeight}px; width:80%; "
                   />
        </div>
      </p:tab>

      <p:tab title="#{listStandingsBean.getR_DriverPointsTxt()}">
        <div align="left">
          <p:chart id="standingsChartRD"
                   type="bar" 
                   model="#{listStandingsBean.getChartModel(2)}" 
                   responsive="true"
                   style="height:#{listStandingsBean.chartHeight}px; width:80%; "
                   />
        </div>
      </p:tab>

      <p:tab title="#{listStandingsBean.getE_DriverPointsTxt()}">
        <div align="left">
          <p:chart id="standingsChartED"
                   type="bar" 
                   model="#{listStandingsBean.getChartModel(3)}" 
                   responsive="true"
                   style="height:#{listStandingsBean.chartHeight}px; width:80%; "
                   />
        </div>
      </p:tab>

      <p:tab title="#{listStandingsBean.getS_OwnerPointsTxt()}">
        <div align="left">
          <p:chart id="standingsChartSO"
                   type="bar" 
                   model="#{listStandingsBean.getChartModel(4)}" 
                   responsive="true"
                   style="height:#{listStandingsBean.chartHeight}px; width:80%; "
                   />
        </div>
      </p:tab>

      <p:tab title="#{listStandingsBean.getR_OwnerPointsTxt()}">
        <div align="left">
          <p:chart id="standingsChartRO"
                   type="bar" 
                   model="#{listStandingsBean.getChartModel(5)}" 
                   responsive="true"
                   style="height:#{listStandingsBean.chartHeight}px; width:80%; "
                   />
        </div>
      </p:tab>

      <p:tab title="#{listStandingsBean.getE_OwnerPointsTxt()}">
        <div align="left">
          <p:chart id="standingsChartEO"
                   type="bar" 
                   model="#{listStandingsBean.getChartModel(6)}" 
                   responsive="true"
                   style="height:#{listStandingsBean.chartHeight}px; width:80%; "
                   />
        </div>
      </p:tab>
    </p:accordionPanel>


  </ui:define>


</ui:composition>

和支持Bean:

@ManagedBean( name = "listStandingsBean" )
@ViewScoped
public class ListStandingsBean {

  @ManagedProperty( value = "#{mainBean}" )
  private MainBean mainBean;

  private ModelForView theModel;
  private Controller theController;

  private List<Standings> standings;
  private List<Standings> 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<Standings> standings ) {
    this.standings = standings;
  }

  public List<Standings> getStandings() {
    return standings;
  }

  public Long getIndex() {
    return ++index;
  }

  public List<Byte> getLevels() {
    Byte levels[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
    return Arrays.asList( levels );
  }

  public List<Standings> getFilteredStandings() {
    index = 0L;
    return filteredStandings;
  }

  public void setFilteredStandings( List<Standings> filteredStandings ) {
    this.filteredStandings = filteredStandings;

    this.updateCharts();
  }

  /*
   * user actions
   */
  public void clickReturn() {
    theController.clickReturn( UI.LIST_STANDINGS );
  }

  public void updateCharts() {
    for( int chMode = 0; chMode < 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() <= 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();
  }
}

1 个答案:

答案 0 :(得分:1)

我找到了导致这种奇怪行为的原因。

碰巧我正在使用filteredStandings列表更新Horizo​​ntalBarChartModel数组,但是当这个列表为空时,我在创建它之后就离开了模型。这似乎让模型在某处留下了空指针,因为它上面没有系列。这个空指针以某种方式损坏了其他东西,非常奇怪的是,没有发送sort事件。

对于那些好奇的人,我把这里的代码放在这里:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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">

  <ui:define name="content">

    <table>
      <tr>
        <td><p:graphicImage url="#{resource['images/goldCup3small.jpg']}" height="30" /></td>
        <td><h2>#{listStandingsBean.getChampionshipsStandingsTitle()}</h2></td>
        <td><p:graphicImage url="#{resource['images/goldCup3small.jpg']}" height="30" /></td>
      </tr>
    </table>

    <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"
                 >

      <f:facet name="header">
        <p:outputPanel>
          <h:outputText value="#{mainBean.getSearchAllFieldsLabel()}" />
          <p:inputText id="globalFilter" 
                       onkeyup="PF( 'standingsTable' ).filter()" 
                       style="width:150px" 
                       placeholder="#{mainBean.getEnterKeywordPlaceholder()}"/>

          <p:commandButton actionListener="#{listStandingsBean.clickReturn()}"
                           icon="fa fa-fw fa-arrow-left"
                           title="#{mainBean.getReturnButtonTitle()}"
                           onclick="PF('dlgWait').show();"
                           ajax="true"
                           style="float: left"/>

        </p:outputPanel>
      </f:facet>

      <p:column headerText="#{listStandingsBean.getRowTxt()}" 
                footerText="#{listStandingsBean.getRowTxt()}" 
                width="10" style="text-align: center">
        <h:outputText value="#{rowIndex+1}" />
      </p:column>

      <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">
        <f:facet name="filter">
          <p:spinner size="3" value="#{listStandingsBean.currYear}"
                     onchange="PF( 'standingsTable' ).filter()"
                     styleClass="year-spinner" >
            <f:converter converterId="javax.faces.Integer" />
          </p:spinner>
        </f:facet>
        <h:outputText value="#{item.id.year}"/>
      </p:column>

      <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">
        <f:facet name="filter">  
          <p:inputText size="10" onkeyup="PF( 'standingsTable' ).filter()" /> 
        </f:facet>
        <h:outputText value="#{listStandingsBean.getUserName( item.id.user )}" />
      </p:column>

      <p:column filterBy="#{item.id.level}" 
                sortBy="#{item.id.level}" 
                headerText="#{listStandingsBean.getLevelTxt()}" 
                footerText="#{listStandingsBean.getLevelTxt()}" 
                filterMatchMode="contains" width="70" style="padding: 2px">
        <f:facet name="filter" >
          <p:selectOneMenu onchange="PF( 'standingsTable' ).filter()">
            <f:selectItem noSelectionOption="true"  />
            <f:selectItems value="#{listStandingsBean.levels}"  />
          </p:selectOneMenu>
        </f:facet>
        <h:outputText value="#{listStandingsBean.getLevelName( item.id.level )}" />
      </p:column>

      <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">
        <h:outputText value="#{listStandingsBean.getChampionshipName( item )}" />
      </p:column>

      <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">
        <h:outputText value="#{item.pointsSd+item.pointsRd}"/>
      </p:column>

      <p:column sortBy="#{item.pointsSd}" style="white-space: pre-line; text-align: right" 
                headerText="#{listStandingsBean.getS_DriverPointsTxt()}" 
                footerText="#{listStandingsBean.getS_DriverPointsTxt()}" width="60">
        <h:outputText value="#{item.pointsSd}" />
      </p:column>

      <p:column sortBy="#{item.pointsRd}" style="white-space: pre-line; text-align: right" 
                headerText="#{listStandingsBean.getR_DriverPointsTxt()}" 
                footerText="#{listStandingsBean.getR_DriverPointsTxt()}" width="60">
        <h:outputText value="#{item.pointsRd}"/>
      </p:column>

      <p:column sortBy="#{item.pointsEd}" style="white-space: pre-line; text-align: right" 
                headerText="#{listStandingsBean.getE_DriverPointsTxt()}" 
                footerText="#{listStandingsBean.getE_DriverPointsTxt()}" width="60">
        <h:outputText value="#{item.pointsEd}"/>
      </p:column>

      <p:column sortBy="#{item.pointsSo}" style="white-space: pre-line; text-align: right" 
                headerText="#{listStandingsBean.getS_OwnerPointsTxt()}" 
                footerText="#{listStandingsBean.getS_OwnerPointsTxt()}" width="60">
        <h:outputText value="#{item.pointsSo}" />
      </p:column>

      <p:column sortBy="#{item.pointsRo}" style="white-space: pre-line; text-align: right" 
                headerText="#{listStandingsBean.getR_OwnerPointsTxt()}" 
                footerText="#{listStandingsBean.getR_OwnerPointsTxt()}" width="60">
        <h:outputText value="#{item.pointsRo}"/>
      </p:column>

      <p:column sortBy="#{item.pointsEo}" style="white-space: pre-line; text-align: right" 
                headerText="#{listStandingsBean.getE_OwnerPointsTxt()}" 
                footerText="#{listStandingsBean.getE_OwnerPointsTxt()}" width="60">
        <h:outputText value="#{item.pointsEo}"/>
      </p:column>

      <p:ajax event="filter" update="contentForm:graphsAccordion"
              listener="#{listStandingsBean.filterEvent}"/>
      <p:ajax event="sort" update="contentForm:graphsAccordion"
              listener="#{listStandingsBean.sortEvent}" />

    </p:dataTable>

    <p:remoteCommand name="onCompleteAuto" oncomplete="PF('standingsTable').filter()" autoRun="true" />

    <p:accordionPanel id="graphsAccordion" 
                      widgetVar="graphsAccordion"
                      multiple="true"
                      activeIndex="-1"
                      style="width:90%" >
      <p:tab title="#{listStandingsBean.getSR_DriverPointsTxt()}">
        <div align="left">
          <p:chart id="standingsChartSRD"
                   type="bar" 
                   model="#{listStandingsBean.getChartModel(0)}" 
                   responsive="true"
                   style="height:#{listStandingsBean.chartHeight}px; width:80%; "
                   />
        </div>
      </p:tab>

      <p:tab title="#{listStandingsBean.getS_DriverPointsTxt()}">
        <div align="left">
          <p:chart id="standingsChartSD"
                   type="bar" 
                   model="#{listStandingsBean.getChartModel(1)}" 
                   responsive="true"
                   style="height:#{listStandingsBean.chartHeight}px; width:80%; "
                   />
        </div>
      </p:tab>

      <p:tab title="#{listStandingsBean.getR_DriverPointsTxt()}">
        <div align="left">
          <p:chart id="standingsChartRD"
                   type="bar" 
                   model="#{listStandingsBean.getChartModel(2)}" 
                   responsive="true"
                   style="height:#{listStandingsBean.chartHeight}px; width:80%; "
                   />
        </div>
      </p:tab>

      <p:tab title="#{listStandingsBean.getE_DriverPointsTxt()}">
        <div align="left">
          <p:chart id="standingsChartED"
                   type="bar" 
                   model="#{listStandingsBean.getChartModel(3)}" 
                   responsive="true"
                   style="height:#{listStandingsBean.chartHeight}px; width:80%; "
                   />
        </div>
      </p:tab>

      <p:tab title="#{listStandingsBean.getS_OwnerPointsTxt()}">
        <div align="left">
          <p:chart id="standingsChartSO"
                   type="bar" 
                   model="#{listStandingsBean.getChartModel(4)}" 
                   responsive="true"
                   style="height:#{listStandingsBean.chartHeight}px; width:80%; "
                   />
        </div>
      </p:tab>

      <p:tab title="#{listStandingsBean.getR_OwnerPointsTxt()}">
        <div align="left">
          <p:chart id="standingsChartRO"
                   type="bar" 
                   model="#{listStandingsBean.getChartModel(5)}" 
                   responsive="true"
                   style="height:#{listStandingsBean.chartHeight}px; width:80%; "
                   />
        </div>
      </p:tab>

      <p:tab title="#{listStandingsBean.getE_OwnerPointsTxt()}">
        <div align="left">
          <p:chart id="standingsChartEO"
                   type="bar" 
                   model="#{listStandingsBean.getChartModel(6)}" 
                   responsive="true"
                   style="height:#{listStandingsBean.chartHeight}px; width:80%; "
                   />
        </div>
      </p:tab>
    </p:accordionPanel>


  </ui:define>


</ui:composition>

支持bean:

@ManagedBean( name = "listStandingsBean" )
@ViewScoped
public class ListStandingsBean {

  @ManagedProperty( value = "#{mainBean}" )
  private MainBean mainBean;

  private ModelForView theModel;
  private Controller theController;

  private List<Standings> standings;
  private List<Standings> 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();
    horizontalBarModel = new HorizontalBarChartModel[7];
    updateCharts( standings );
  }

  //
  // queries
  //
  public Integer getCurrYear() {
    Calendar c = new GregorianCalendar();
    return c.get( Calendar.YEAR );
  }

  public void setCurrYear( Integer y ) {
  }

  public void setStandings( List<Standings> standings ) {
    this.standings = standings;
  }

  public List<Standings> getStandings() {
    return standings;
  }

  public Long getIndex() {
    return ++index;
  }

  public List<Byte> getLevels() {
    Byte levels[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
    return Arrays.asList( levels );
  }

  public List<Standings> getFilteredStandings() {
    index = 0L;
    return filteredStandings;
  }

  public void setFilteredStandings( List<Standings> filteredStandings ) {
    this.filteredStandings = filteredStandings;
    if( filteredStandings != null )
      this.updateCharts( filteredStandings );
  }

  /*
   * user actions
   */
  public void clickReturn() {
    theController.clickReturn( UI.LIST_STANDINGS );
  }

  public void updateCharts( List<Standings> theList ) {
    for( int chMode = 0; chMode < 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 );

      Collections.reverse( theList );
      ChartSeries series = new ChartSeries();
      //series.setLabel(  );
      for( Standings s : theList ) {
        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;
        }
      }
      if( theList != null && theList.size() > 0 )
        model.addSeries( series );
      Collections.reverse( theList );

      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();
  }
}