Extended DataTable loses data when preserveDataModel=true after validation error
--------------------------------------------------------------------------------

                 Key: TOMAHAWK-1411
                 URL: https://issues.apache.org/jira/browse/TOMAHAWK-1411
             Project: MyFaces Tomahawk
          Issue Type: Bug
          Components: Extended Datatable
    Affects Versions: 1.1.8
         Environment: Tomcat 6, JSF RI 1.2_12
            Reporter: Chris Watts


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();
    }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to