im using Primefaces 2.2M1 with jsf 2.0, and dataExporter component give me a problem if i use it with lazyDataModel.
i found on this forum some old discussion with the same problem and that it was solved with primefaces 2.
if i dont use lazy loading data exporter works fine and export in all file type but if i set lazy=true and use lazymodel it give me this error:
the scope of bean is "session" but i also try with "request" and "application" and give the same exception.
Code: Select all
exception
javax.servlet.ServletException: / by zero
javax.faces.webapp.FacesServlet.service(FacesServlet.java:321)
root cause
java.lang.ArithmeticException: / by zero
org.primefaces.model.LazyDataModel.setRowIndex(LazyDataModel.java:62)
javax.faces.component.UIData.setRowIndex(UIData.java:448)
javax.faces.component.UIData.iterate(UIData.java:1407)
javax.faces.component.UIData.processDecodes(UIData.java:980)
javax.faces.component.UIForm.processDecodes(UIForm.java:212)
javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1043)
javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1043)
org.primefaces.component.tabview.TabView.processDecodes(TabView.java:234)
javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1043)
javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1043)
org.primefaces.component.tabview.TabView.processDecodes(TabView.java:234)
javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1043)
javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1043)
javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:920)
com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:74)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
this is my code:
Code: Select all
<p:dataTable id="milanoR" var="f" value="#{asperaBean.lazyModelFileMilano}"
paginator="true" rows="20"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,20,50,100,1000"
selectionMode="single"
selection="#{asperaBean.selectedFile}"
dynamic="true"
lazy="true"
>
<p:column sortBy="#{f.id}">
<f:facet name="header">
<h:outputText value="ID" />
</f:facet>
<h:outputText value="#{f.id}" />
</p:column>
.
.
.
</p:dataTable>
h:panelGrid columns="1">
<p:panel header="Export All Data">
<h:commandLink>
<p:graphicImage value="/img/excel.png" />
<p:dataExporter type="xls" target="milanoR" fileName="Milano_Running" />
</h:commandLink>
<h:commandLink>
<p:graphicImage value="/img/pdf.png" />
<p:dataExporter type="pdf" target="milanoR" fileName="Milano_Running"/>
</h:commandLink>
<h:commandLink>
<p:graphicImage value="/img/csv.png" />
<p:dataExporter type="csv" target="milanoR" fileName="Milano_Running" />
</h:commandLink>
<h:commandLink>
<p:graphicImage value="/img/xml.png" />
<p:dataExporter type="xml" target="milanoR" fileName="Milano_Running" pageOnly="true" />
</h:commandLink>
</p:panel>
</h:panelGrid>
Code: Select all
//Milano
private LazyDataModel<FaspFile> lazyModelFileMilano;
lazyModelFileMilano = new LazyDataModel<FaspFile>() {
private static final long serialVersionUID = 4610792959942023644L;
@Override
public List<FaspFile> load(int first, int pagesize, String sortField, boolean sortOrder, Map<String, String> filters) {
String ordine = "Asc";
if(!sortOrder) {ordine="Desc";}
if(sortField!=null)
return daoM.getFaspFilesLazy(first, pagesize, "From FaspFile where loggedFrom='logger@10.72.101.78' order by " + sortField + " " + ordine );
else
return daoM.getFaspFilesLazy(first, pagesize, "From FaspFile where loggedFrom='logger@10.72.101.78'");
}
};
lazyModelFileMilano.setRowCount((int) count_M);