Hi all,
I am trying MyFaces and have a problem with DataTable that is not
preserving the data model. I made
a dataScroller for that table also, and everything render fine. The
problem is that i access a database
in the backend method, and that method is called all the time i move in
the dataScroller, from page to page.
I tried to use the tag preserveDataModel="true" and thought that this
will fix the problem, but not, the backend method is
still accessing the DB (why ?). Later i have added a radio button to
each row of the dataTable, and i saw that
when i select a radio button from the form and try to navigate to
another page with dataScroller, first the same page just refreshes
and when i click to navigate again the backend method is not called
anymore, this even if the preserveDataModel="false".
I probably missed something but i can not fix it, and did not find
anything about that on the forums.
My code :
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
....
<f:view>
<h:form>
<t:dataTable id="data"
preserveDataModel="false"
var="sat"
value="#{satelliteService.all}"
rows="7"
styleClass="standardTable"
rowClasses="standardTable_Row1,
standardTable_Row2"
headerClass="standardTable_Header"
footerClass="standardTable_Header"
rowOnMouseOver="oldValue=this.style.backgroundColor;
this.style.backgroundColor='#A5CBFF'"
rowOnMouseOut="this.style.backgroundColor=oldValue"
preserveSort="true">
<t:column>
<h:selectOneRadio onselect="radio(this)">
<f:selectItem itemValue="#{sat.satId}"/>
</h:selectOneRadio>
</t:column>
<t:column>
<f:facet name="header">
<h:outputText value="ID"/>
</f:facet>
<h:outputText value="#{sat.satId}" />
</t:column>
<t:column>
<f:facet name="header">
<h:outputText value="Name"/>
</f:facet>
<h:outputText value="#{sat.satName}" />
</t:column>
<t:column>
<f:facet name="header">
<h:outputText value="Simulated"/>
</f:facet>
<h:outputText value="#{sat.satSimulated}" />
</t:column>
</t:dataTable>
<h:panelGrid columns="1" styleClass="scrollerTable"
columnClasses="standardTable_ColumnCentered" >
<t:dataScroller id="scroll_1"
for="data"
fastStep="10"
pageCountVar="pageCount"
pageIndexVar="pageIndex"
styleClass="scroller"
paginator="true"
paginatorMaxPages="9"
paginatorTableClass="paginator"
paginatorActiveColumnStyle="font-weight:bold;"
immediate="false">
<f:facet name="previous">
<t:graphicImage url="/images/arrow-previous.gif"
border="1" />
</f:facet>
<f:facet name="next">
<t:graphicImage url="/images/arrow-next.gif"
border="1" />
</f:facet>
</t:dataScroller>
</h:panelGrid>
</h:form>
</f:view>