5 Replies Latest reply on Jun 3, 2009 10:29 AM by jaand96

    ExtendedDataTable rerender and action ordering

      Hi,

      I'm using the ExtendedDataTable. It initally displays my list ok.

      In a modal dialog I have an commandButton with an action that adds a row to the list and a rerender with the extended table id. It also closes the dialog

      The table rerenders (the spinner shows), however the new row does not appear. If I then add a new row, the first row appears after the rerender.

      It is like the rerender is done before the the action!

      Any suggestions as to how to get the table rerender with the new list data?

      hopefully you can understand this...!

        • 1. Re: ExtendedDataTable rerender and action ordering
          ilya_shaikovsky

          reRender could not happens before the action :) because action called on 5-th phase and rendering on 6-th.

          show the code please.

          • 2. Re: ExtendedDataTable rerender and action ordering

            Hi, no, you're right. Something else is wrong but that is what it looks like. First insert shows when the second is done etc... very odd!

            This is the table (well the important part).
            The value (ProductionPointController.productionPoint.stopTimes) is a List.

            <rich:extendedDataTable id="functionTable"
             value="#{ProductionPointController.productionPoint.stopTimes}"
             var="stopTime" height="200px" width="600px"
             selection="#{ProductionPointController.stopTimeTable.selection}"
             binding="#{ProductionPointController.stopTimeTable.table}"
             selectionMode="single">
            
             <rich:column sortable="true" sortBy="#{stopTime.function.name}">
             <f:facet name="header">Function</f:facet>
             <h:outputText value="#{stopTime.function.name}" />
             </rich:column>
            
             ... etc ...
            </rich:extendedDataTable>
            


            This is the button in the modalPanel that rerenders and fires action,

            <a4j:commandButton value="Save" reRender="functionTable" action="#{ProductionPointController.updateStopTime}"
             oncomplete="#{facesContext.maximumSeverity == null ? 'Richfaces.hideModalPanel(\'panelid\');' : ''}" />
            


            The action inserts the new stoptime, and then updates all data from database:

            public void updateStopTime(){
             productionPointFacade.mergeStopTime(stopTime);
             productionPoint = productionPointFacade.getById(productionPoint.getId());
            }
            



            The table's binding and selection is done to this class:

            
            @SuppressWarnings("unchecked")
            @Name(value="TableController")
            @Scope(ScopeType.EVENT)
            public class TableController<T> {
            
             //Extended data table support
             private UIExtendedDataTable table;
             private SimpleSelection selection = new SimpleSelection();
            
            
             public Set<T> getSelectedRecords() {
             Set<T> selected = new HashSet<T>();
             Iterator<Object> iterator = selection.getKeys();
             while (iterator.hasNext()) {
             Object key = iterator.next();
             table.setRowKey(key);
             selected.add((T) table.getRowData());
             }
             return selected;
             }
            
             public T getSingleSelectedRecord(){
             if(getSelectedRecords().iterator().hasNext())
             return getSelectedRecords().iterator().next();
             else return null;
            
             }
            
            
             public UIExtendedDataTable getTable() {
             return table;
             }
            
             public void setTable(UIExtendedDataTable table) {
             this.table = table;
             }
            
             public SimpleSelection getSelection() {
             return selection;
             }
            
             public void setSelection(SimpleSelection selection) {
             this.selection = selection;
             }
            }
            
            


            • 3. Re: ExtendedDataTable rerender and action ordering
              ilya_shaikovsky

              could you please create a sample for us? because you code looks just fine.. and not sure where the problem could lie.. Or at list simplify the code to be able to post it without cutting "unnesessary" parts..

              B.t.w. If something changed if you will remove binding from the table?

              • 4. Re: ExtendedDataTable rerender and action ordering

                thanks Ill try to create an isolated test case.

                One thing I forgot to mention is that if I change an exiting object in the table the change shows after the rerender.

                Added/removed objects does not show up.

                Oh and if I remove the table binding, I don't know how to get the selected record...

                • 5. Re: ExtendedDataTable rerender and action ordering

                  My mistake. This problem had nothing to do with richfaces, it was a sideeffect of bad transaction management.