2 Replies Latest reply on Nov 3, 2011 2:12 PM by Aaron Wilson

    extendedDataTableModel update

    Larbi Aboussoror Newbie



        I'm facing some problems when trying to update an ExtendedTableDataModel. In fact I'm trying to refresh a list of flights after adding a new one.

      When I save the new flight, it is added in the database but the extendedDataTable is not refreshed.



      So the code in my jsp for refreshing an extendedDataTable is:

                   <a4j:commandButton action="#{flightsController.save}" value="Save"


      And the 'save' method in my controller :


      public String save() {
              for (Company c : companies) {
                          company = c;
              return null;


      The extendedDataTable is declared as follows :


      <h:form binding="#{flightsController.formTableFlight}"
                          value="#{flightsController.extendedTableDataModel}" var="flight"
                          selection="#{flightsController.selectionFlight}" id="tableFlight"
                          sortMode="single" selectionMode="single" width="500px"
                          <f:facet name="header">
                              <h:outputText value="Flight" />
                          <rich:column sortable="false" label="Code" id="col_code">
                              <f:facet name="header">
                                  <h:outputText value="Code" id="code" />
                              <h:outputText value="#{flight.id}" id="flight_id" />
                          <rich:column sortable="true" label="Departure" id="col_departure">
                              <f:facet name="header">
                                  <h:outputText value="Departure" id="departure" />
                              <h:outputText value="#{flight.departure}" />
                          <rich:column sortable="true" label="Departure" id="col_destination">
                              <f:facet name="header">
                                  <h:outputText value="Destination" id="destination" />
                              <h:outputText value="#{flight.destination}" />
                          <rich:column sortable="false" label="actions" id="col_actions">
                              <f:facet name="header">
                                  <h:outputText value="Actions" id="actions" />
                              <h:panelGrid columns="1">
                                  <h:commandLink value="delete"
                                          target="#{flightsController.flight}" value="#{flight}" />
                          <a4j:support reRender="tableStep"
                              event="onselectionchange" id="table_takeSelection" />



      The extendedDataTableModel is initialized by this code :


      private List<Flight> flights = flightsService.getFlights();
      public ExtendedTableDataModel<Flight> getExtendedTableDataModel() {
              if(extendedTableDataModel == null) {
                  extendedTableDataModel = new ExtendedTableDataModel<Flight>(new DataProvider<Flight>() {
                      private static final long serialVersionUID = -776297803803735490L;
                      public Flight getItemByKey(Object key) {
                          for(Flight c : flights){
                              if (key.equals(getKey(c))){
                                  return c;
                          return null;
                      public List<Flight> getItemsByRange(int firstRow, int endRow) {
                          return flights.subList(firstRow, endRow);
                      public Object getKey(Flight item) {
                          return item.getId();
                      public int getRowCount() {
                          return flights.size();
              return extendedTableDataModel;


      Thanks for help

        • 1. Re: extendedDataTableModel update
          Aaron Wilson Newbie

          I'm having a similar issue where I modify the underlying data in the ExtendedTableDataModel and it doesn't refresh when it is rerendered.  I put some logging in the DataProvider and the getRowCount is returning the correct number of items, but the getItemsByRange is called with both the first and end row indices as 0.  Is there some way to notify the extendedDataTable that it's table model has been update?  Or notify the ExtendedDataTableModel that it's DataProvider has been updated?


          Thanks in advance.

          • 2. Re: extendedDataTableModel update
            Aaron Wilson Newbie

            Fixed it... Just need to call the ExtendedTableDataModel.reset() method after the underlying data is altered.