problem with data exporter

UI Components for JSF
Post Reply
stefano82
Posts: 3
Joined: 21 Sep 2010, 12:01

08 Oct 2010, 12:46

hello,
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>
and this the lazy data model inside my bean:

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);
any soggestion? :)

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

08 Oct 2010, 13:45

Can you try pageOnly="true" dataExporter? DataExporter does not support recent p:dataTable enhancements like lazy loading yet.

stefano82
Posts: 3
Joined: 21 Sep 2010, 12:01

11 Oct 2010, 10:18

no it give the same error even with PageOnly=true
thanks anyway for the suggestion

ezeecloud
Posts: 1
Joined: 23 Dec 2010, 12:43

23 Dec 2010, 12:51

Hai Please help me...can i export data using datamodel..?

luisalves00
Posts: 71
Joined: 21 Feb 2011, 18:37

04 Jul 2011, 10:03

I'm using a 3.0M1 snapshot...and it works with lazy=true...

BUT only export the first page. i.e. if you got a page size of 15 and 30 result...you get 30 results on the export file but with the first page being repeated 1 time..

thinks its reported here: http://code.google.com/p/primefaces/iss ... ail?id=668 with status fixed...so I'll do some more testing...

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 13 guests