Uploaded image for project: 'MyFaces Tomahawk'
  1. MyFaces Tomahawk
  2. TOMAHAWK-1411

Extended DataTable loses data when preserveDataModel=true after validation error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 1.1.8
    • None
    • Extended Datatable
    • None
    • Tomcat 6, JSF RI 1.2_12

    Description

      If a page containing a data table with preserved data model has a validation error on submit, the preserved data is lost and no rows are rendered. (e.g. if a required field is empty)

      Simple replication:

      <h:inputText id="Name" value="#

      {bean.name}

      " required="true" />
      <t:dataTable
      value="#

      {bean.dataModel}

      "
      preserveDataModel="true"
      var="obj">
      ......

      bean:
      public class Bean
      {
      private DataModel dataModel;
      private String name = null;

      public String edit()

      { dataModel = new ListDataModel(values); return "edit"; }

      ......

      The page is view by an action calling edit() then the page above is submitted with name being blank causing a validation error.

      I have done some probing but am confused by the way the data is preserved so can't hack a solution...
      In the SUN RI UIData the following is called:

      public void encodeBegin(FacesContext context) throws IOException {
      setDataModel(null); // re-evaluate even with server-side state saving
      if (!keepSaved(context))

      { //noinspection CollectionWithoutInitialCapacity saved = new HashMap<String, SavedState>(); }

      super.encodeBegin(context);
      }

      And the saved model is reset by an earlier call to AbstractHtmlDataTable

      protected DataModel getDataModel()
      {
      if (_preservedDataModel != null)

      { setDataModel(_preservedDataModel); _preservedDataModel = null; }

      return super.getDataModel();
      }

      Attachments

        1. HtmlDataTableHack.java
          22 kB
          Chris Watts

        Issue Links

          Activity

            People

              lu4242 Leonardo Uribe
              watts.chris Chris Watts
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: