MyFaces Tomahawk
  1. MyFaces Tomahawk
  2. TOMAHAWK-1568

UIInputs in DataTable (UIData) lose submitted values when UICommands are set to immediate=true

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.1, 1.1.2, 1.1.3
    • Fix Version/s: 1.1.11
    • Component/s: Extended Datatable
    • Labels:
      None

      Description

      Similar to MYFACES-335, DataTable values do not reflect a form submission is an action is performed with immediate=true

      Perform the following actions:

      Failure Scenario:
      1. load the page in your browser Test.jsp
      2. Press the "Add" button once to add a row to the data table.
      3. Enter some data in the text field in the added row.
      4. Press "Add" again to add a second row to the data table.
      5. Notice that the rendered page now has two rows in the data table, however text entered into the text field in the first row is now lost.

      Success Scenario:
      1. Repeat steps 1 to 4 of the failure scenario (above).
      2. Now press "Delete" on the second row in the data table.
      3. Notice that the rendered page now has only one row and it is containing text entered in step 3 as expected.

      This test confirms that data tables work as expected when immediate=true is not used, but that data tables fail to work as expected when immediate=true is used.

      1. TestExampleByDavidGreen.zip
        7 kB
        Mike Kienenberger
      2. FaceletsTestExampleByMikeKienenberger.zip
        2 kB
        Mike Kienenberger

        Issue Links

          Activity

          Hide
          David Green added a comment -

          JSP used in the test

          Show
          David Green added a comment - JSP used in the test
          Hide
          David Green added a comment -

          helper class for the backing bean

          Show
          David Green added a comment - helper class for the backing bean
          Hide
          David Green added a comment -

          backing bean model

          Show
          David Green added a comment - backing bean model
          Hide
          David Green added a comment -

          backing bean model (row)

          Show
          David Green added a comment - backing bean model (row)
          Hide
          David Green added a comment -

          backing bean used by the Test.jsp

          Show
          David Green added a comment - backing bean used by the Test.jsp
          Hide
          Mike Kienenberger added a comment -

          Updating subject.

          Show
          Mike Kienenberger added a comment - Updating subject.
          Hide
          Mike Kienenberger added a comment -

          Repackaging David's example. Note that the original attachments weren't licensed for inclusion, so neither is this repackaging.

          Show
          Mike Kienenberger added a comment - Repackaging David's example. Note that the original attachments weren't licensed for inclusion, so neither is this repackaging.
          Show
          Mike Kienenberger added a comment - For some history on the issue in JSF RI, see these bugs: https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=140 https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=73 See this spec issue: https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=153
          Hide
          Mike Kienenberger added a comment -

          Example showing inconsistent behavior with immediate and example showing workaround using preserveRowStates.

          Show
          Mike Kienenberger added a comment - Example showing inconsistent behavior with immediate and example showing workaround using preserveRowStates.
          Hide
          Mike Kienenberger added a comment -

          Note that we can't fix this issue for JSF 1.1's h:dataTable (although we can fix it for t:dataTable). We can fix it for JSF 1.2 provided it makes it into the JSF 1.2 MR.

          Show
          Mike Kienenberger added a comment - Note that we can't fix this issue for JSF 1.1's h:dataTable (although we can fix it for t:dataTable). We can fix it for JSF 1.2 provided it makes it into the JSF 1.2 MR.
          Hide
          Mathias Broekelmann added a comment -

          I can't see how we can fix this in h:datatable for jsf 1.1 or 1.2. The spec clearly states what should happen if a UIData component encodeBegin method is called:

          In addition to the default behavior, ensure that any saved per-row state for our child input components is discarded unless it is needed to rerender the current page with errors.

          see Javadoc for 1.1: http://java.sun.com/javaee/javaserverfaces/1.1_01/docs/api/javax/faces/component/UIData.html#encodeBegin(javax.faces.context.FacesContext)
          see Javadoc for 1.2: http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/javax/faces/component/UIData.html#encodeBegin(javax.faces.context.FacesContext)

          There is an important reason why this must be handled in this way . The invoked action could modify the datamodel source in a way which is not compatible to the saved state. For instance if an action removes a row in the dataset and the per- row state is not discarded restoring the state will either produce currupt rendering or will result in an exception. There is no link between a row in the datamodel and it's saved state but the row index.

          But I think it should be able to add that support to t:datatable.

          Show
          Mathias Broekelmann added a comment - I can't see how we can fix this in h:datatable for jsf 1.1 or 1.2. The spec clearly states what should happen if a UIData component encodeBegin method is called: In addition to the default behavior, ensure that any saved per-row state for our child input components is discarded unless it is needed to rerender the current page with errors. see Javadoc for 1.1: http://java.sun.com/javaee/javaserverfaces/1.1_01/docs/api/javax/faces/component/UIData.html#encodeBegin(javax.faces.context.FacesContext ) see Javadoc for 1.2: http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/javax/faces/component/UIData.html#encodeBegin(javax.faces.context.FacesContext ) There is an important reason why this must be handled in this way . The invoked action could modify the datamodel source in a way which is not compatible to the saved state. For instance if an action removes a row in the dataset and the per- row state is not discarded restoring the state will either produce currupt rendering or will result in an exception. There is no link between a row in the datamodel and it's saved state but the row index. But I think it should be able to add that support to t:datatable.
          Hide
          Mike Kienenberger added a comment -

          I no longer remember the details of this issue.

          However, as a workaround, someone (who cares) could try replacing the "immediate=true" components with a sandbox:subForm and see if that works any better.

          Show
          Mike Kienenberger added a comment - I no longer remember the details of this issue. However, as a workaround, someone (who cares) could try replacing the "immediate=true" components with a sandbox:subForm and see if that works any better.
          Hide
          Mike Kienenberger added a comment -

          I just tested this with subForm and t:dataTable. I wasn't able to get it to work. subForms still cause the data to be lost.

          Show
          Mike Kienenberger added a comment - I just tested this with subForm and t:dataTable. I wasn't able to get it to work. subForms still cause the data to be lost.
          Hide
          Mike Kienenberger added a comment -

          Creating Tomahawk enhancement to provide manipulator methods for preserved row states. For example, delete row state at index when model row is deleted.

          Show
          Mike Kienenberger added a comment - Creating Tomahawk enhancement to provide manipulator methods for preserved row states. For example, delete row state at index when model row is deleted.
          Hide
          Leonardo Uribe added a comment -

          I tried the example an now with the modifications on TOMAHAWK-961 and TOMAHAWK-1567 this can be closed as fixed. To make it work, it is just necessary to use <t:dataTable preserveRowComponentState="true" ....>. Use rowKey property is optional, and it allows define the association between the row and the component state.

          Show
          Leonardo Uribe added a comment - I tried the example an now with the modifications on TOMAHAWK-961 and TOMAHAWK-1567 this can be closed as fixed. To make it work, it is just necessary to use <t:dataTable preserveRowComponentState="true" ....>. Use rowKey property is optional, and it allows define the association between the row and the component state.

            People

            • Assignee:
              Leonardo Uribe
              Reporter:
              David Green
            • Votes:
              3 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development