I have been puzzling over preserveDataModel attribute as well. Below is my current understanding:
If preserveDataModel="false" - Tomahawk will call getDataModel() during the APPLY_REQUEST_VALUES phase. This will create a fresh copy of the dataModel (assuming your bean is in request scope). - It will call getDataModel() again during the RENDER_RESPONSE phase. This will reuse the dataModel created above. If preserveDataModel="true" - Tomahawk will NOT call getDataModel() during the APPLY_REQUEST_VALUES phase. However it will NOT call setDataModel() as well. It seems to work with an internally saved copy of the dataModel. - Therefore your program code will NOT receive a 'saved' version of the dataModel. - Tomahawk will call getDataModel() during RENDER_RESPONSE phase. This will cause your program to generate a fresh copy of the dataModel. I have to say - I spend many hours on and off trying to understand this beast. Such is my understanding at present. I hope it will help you to track down your problem. Regards, Yee -----Original Message----- From: Randy Simon [mailto:[EMAIL PROTECTED] Sent: Wednesday, 8 March 2006 3:18 AM To: [email protected] Subject: Problem using preserveDataModel="true" I'm sure I am doing something wrong, but I can't figure out what it is. I have the following: <h:form> <h:commandButton action="#{dataSourceEditor.newProperty}" value="New Property" /> <p></p> <t:dataTable value="#{dataSourceEditor.dataModel}" preserveDataModel="true" var="property" border="1"> <h:column> <h:inputText value="#{property.name}" /> </h:column> <h:column> <h:outputText value="#{property.type}" /> <h:inputHidden value="#{property.type}" /> </h:column> </t:dataTable> </h:form> My dataSourceEditor bean is in request scope and has the following methods. public DataModel getDataModel() { if (dataModel == null) { dataModel = new ListDataModel(); } dataModel.setWrappedData(properties); return dataModel; } public void setDataModel(DataModel dm) { dataModel = dm; } public String newProperty() { DSProperty property = new DSProperty(); property.setName("new property"); property.setType(Property.LONG); if (dataModel != null) { properties = (List) dataModel.getWrappedData(); } if (properties == null) { properties = new ArrayList(); } properties.add(property); return null; } When I click the "new property" button I would expect my "setDataModel" method to be called then the "newProperty" method to be called where I add a new property to the list. However, when I click on the "new property" button I get the following class cast exception. java.lang.ClassCastException: javax.faces.model.ListDataModel at org.apache.myfaces.component.html.ext.HtmlDataTable.updateModelFromPreserved DataModel(HtmlDataTable.java:254) at org.apache.myfaces.component.html.ext.HtmlDataTable.processUpdates(HtmlDataT able.java:240) at javax.faces.component.UIForm.processUpdates(UIForm.java:196) at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:92 7) at javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:363) at com.sun.faces.lifecycle.UpdateModelValuesPhase.execute(UpdateModelValuesPhas e.java:81) at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSe curityHelper.java:225) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelpe r.java:127) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:272) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at org.apache.beehive.netui.pageflow.PageFlowPageFilter.runPage(PageFlowPageFil ter.java:299) at org.apache.beehive.netui.pageflow.PageFlowPageFilter.doFilter(PageFlowPageFi lter.java:214) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at org.apache.shale.faces.ShaleApplicationFilter.doFilter(ShaleApplicationFilte r.java:285) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at com.bea.p13n.servlets.PortalServletFilter.doFilter(PortalServletFilter.java: 329) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(W ebAppServletContext.java:3192) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubjec t.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletC ontext.java:1984) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext. java:1891) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:131 8) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209) at weblogic.work.ExecuteThread.run(ExecuteThread.java:181) I am completely stumped about why this happens. Thanks in advance for your help. Randy

