[ 
https://issues.apache.org/jira/browse/TOMAHAWK-1411?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12695889#action_12695889
 ] 

Chris Watts edited comment on TOMAHAWK-1411 at 4/5/09 12:08 PM:
----------------------------------------------------------------

After a bit more digging around this COULD be related to a defect in the spec 
and/or implementation.
Alot of bugs point back to this bug:
https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=73

Additionally:
https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=153

I have also attached a HACK to HtmlDataTableHack that works around the problem 
and doesn't seem to break any of the update functionality (although its not a 
thorough check).
This has sections copied across from the SUN RI to get around the dataModel 
being cleared.

No doubt this is the incorrect way to do it but it works for the interim.

      was (Author: watts.chris):
    HACK to HtmlDataTableHack that works around the problem and doesn't seem to 
break any of the update functionality (although its not a thorough check).
This has sections copied across from the SUN RI to get around the dataModel 
being cleared.

No doubt this is the incorrect way to do it but it works for the interim.
  
> 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
>         Attachments: HtmlDataTableHack.java
>
>
> 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