0 Replies Latest reply on Jul 26, 2011 4:56 PM by vace117

    <rich:dataTable> does not refresh its data model on ajax postbacks on Mojarra 2.1.2

    vace117

      Hello.

       

      I came across a serious problem with the rich data table when running on Mojarra 2.1.2. I would like to discuss possible solutions, b/c it is not obvious to me.

       

      The problem can be recreated by having a data table with an ajax delete link on every row. The ajax re-renders the whole table. With Mojarra, you will find that even though the row is deleted in the data model, the table still shows the deleted row.

       

      This happens b/c UIDataAdapter.processEvent() listens for PreRenderComponentEvent, which triggers the data model reset. Mojarra appears to have a bug, which prevents this event from being processed by the data table on postbacks. You can find the details about this Mojarra bug in the JIRA item I created: http://java.net/jira/browse/JAVASERVERFACES-2152

       

      To summarize the problem, the PreRenderComponentEvent is delivered to the parent of the data table rather than the data table itself, b/c the system event restore mechanism relies on grabbing the top component on the EL stack. The data table is restored before it is pushed onto the EL stack, so the  PreRenderComponentEvent is never delivered to it on a postback and so the data model is not refreshed.

       

      As a workaround I extended UIDataTable like this:

       

       

      {code}

      public class FixedUIDataAdapter extends UIDataTable {

       

                 @Override

                public void restoreState(FacesContext context, Object stateObject) {

                          pushComponentToEL(context, null);

                          super.restoreState(context, stateObject);

                          popComponentFromEL(context);

                }

        }

      {code}

       

      This fixes the problem, but makes me worry about possible side effects. Can anyone comment on the possible repercussions of this fix?

       

      In any case, this problem will need to be addressed. Ideally, the fix would be done on the Mojarra side, but failing that Richfaces might need to do a workaround...

       

      Should I create a Richfaces jira to track this?

       

       

      Val