Error when overridind PDFExporter

UI Components for JSF
Post Reply
vendra00
Posts: 10
Joined: 22 May 2013, 22:08
Location: Brazil

21 Jun 2013, 19:41

Hi.

I'm using the PDFExporter but in my xhtml I'm using p:cellEditor and I'm trying to override the PDFExporter method, and i'm getting this error:

"The type javax.el.MethodExpression cannot be resolved. It is indirectly referenced from required .class files"

And suggest to me do something in java build path.
Do I need some other lib to edit primefaces methods?

This is my class:

Code: Select all

package util;//here it accuse the error

import javax.faces.component.UIComponent;
import javax.faces.component.html.HtmlGraphicImage;
import javax.faces.context.FacesContext;

import org.primefaces.component.celleditor.CellEditor;
import org.primefaces.component.export.PDFExporter;

public class ExtendedPDFExporter extends PDFExporter {
	@Override
	protected String exportValue(FacesContext context, UIComponent component) {
		if (component instanceof CellEditor) {
			return exportValue(context,
					((CellEditor) component).getFacet("output"));
		} else if (component instanceof HtmlGraphicImage) {
			return (String) component.getAttributes().get("alt");
		} else {
			return super.exportValue(context, component);
		}
	}
}
"Everything should be made as simple as possible, but not simpler."

Albert Einstein

User avatar
sudheer
PrimeFaces Core Developer
Posts: 4345
Joined: 16 Oct 2011, 19:19
Location: Singapore

21 Jun 2013, 20:23

Primefaces extensions exporter will support cellEditor feature.Look at this link http://fractalsoft.net/primeext-showcas ... eTable.jsf
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/

___________________
Sudheer Jonna

vendra00
Posts: 10
Joined: 22 May 2013, 22:08
Location: Brazil

21 Jun 2013, 21:57

It will be another lib to export to my project, it can work, but I'm wondering if it will be possible to override this specific method from Primefaces. That can't be so hard.
"Everything should be made as simple as possible, but not simpler."

Albert Einstein

User avatar
sudheer
PrimeFaces Core Developer
Posts: 4345
Joined: 16 Oct 2011, 19:19
Location: Singapore

22 Jun 2013, 05:38

You cann't do that.May be zip,update the code and unzip will do that.However primefaces extensions is a lightweight library so it can't be a problem at all.Many users are using this lib.
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/

___________________
Sudheer Jonna

vendra00
Posts: 10
Joined: 22 May 2013, 22:08
Location: Brazil

24 Jun 2013, 20:31

Well i'm trying to use Primefaces Extensions, but got an error from pe:exporter:

Code: Select all

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: org/apache/xmlbeans/XmlException
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
root cause

java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException
	org.primefaces.extensions.component.exporter.ExcelExporter.export(ExcelExporter.java:94)
	org.primefaces.extensions.component.exporter.DataExporter.processAction(DataExporter.java:170)
	javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
	javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)
	javax.faces.component.UICommand.broadcast(UICommand.java:300)
	javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
	javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
	com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
	com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
	com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
root cause

java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlException from [Module "deployment.Teste_JSF.war:main" from Service Module Loader]
	org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
	org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
	org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
	org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
	org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
	org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
	java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
	org.primefaces.extensions.component.exporter.ExcelExporter.export(ExcelExporter.java:94)
	org.primefaces.extensions.component.exporter.DataExporter.processAction(DataExporter.java:170)
	javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
	javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)
	javax.faces.component.UICommand.broadcast(UICommand.java:300)
	javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
	javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
	com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
	com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
	com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
My xhtml:

Code: Select all

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:pe="http://primefaces.org/ui/extensions">

<h:head>

</h:head>
<h:body>

	<h:form id="form">

		<p:growl id="messages" showDetail="true" />

		<p:dataTable id="dataTable" var="produto" paginator="true"
			paginatorPosition="bottom" rows="10"
			value="#{tabelaProdutoBean.produtosSmall}" widgetVar="produtosTable"
			emptyMessage="No cars found with given criteria"
			filteredValue="#{tabelaProdutoBean.filteredProdutos}" editable="true">

			<f:facet name="header">
				<p:outputPanel>
					<h:outputText value="Pesquisa Geral:" />
					<p:inputText id="globalFilter" onkeyup="produtosTable.filter()"
						style="width:150px" />
				</p:outputPanel>
			</f:facet>

			<p:ajax event="rowEdit" listener="#{tabelaProdutoBean.onEdit}"
				update=":form:messages" />
			<p:ajax event="rowEditCancel"
				listener="#{tabelaProdutoBean.onCancel}" update=":form:messages" />

			<p:column id="cdProdutoColumn" filterBy="#{produto.cdProduto}"
				footerText="" filterMatchMode="contains"
				sortBy="#{produto.cdProduto}">
				<f:facet name="header">
					<h:outputText value="Código Produto" />
				</f:facet>
				<p:cellEditor>
					<f:facet name="output">
						<h:outputText value="#{produto.cdProduto}" />
					</f:facet>
					<f:facet name="input">
						<p:inputText id="cdProdutoInput" value="#{produto.cdProduto}"
							style="width:100%" />
					</f:facet>
				</p:cellEditor>
			</p:column>

			<p:column id="nmProdutoColumn" filterBy="#{produto.nmProduto}"
				footerText="" filterMatchMode="contains"
				sortBy="#{produto.nmProduto}">
				<f:facet name="header">
					<h:outputText value="Nome Produto" />
				</f:facet>
				<p:cellEditor>
					<f:facet name="output">
						<h:outputText value="#{produto.nmProduto}" />
					</f:facet>
					<f:facet name="input">
						<p:inputText id="nmProdutoInput" value="#{produto.nmProduto}"
							style="width:100%" />
					</f:facet>
				</p:cellEditor>
			</p:column>

			<p:column id="dt_iniVigenciaColumn"
				filterBy="#{produto.dt_iniVigencia}" footerText=""
				filterMatchMode="endsWith">
				<f:facet name="header">
					<h:outputText value="Data Inicial de Vigência" />
				</f:facet>
				<p:cellEditor>
					<f:facet name="output">
						<h:outputText value="#{produto.dt_iniVigencia}" />
					</f:facet>
					<f:facet name="input">
						<p:inputText id="dt_iniVigenciaInput"
							value="#{produto.dt_iniVigencia}" style="width:100%" />
					</f:facet>
				</p:cellEditor>
			</p:column>

			<p:column id="tipoProdutoColumn" filterBy="#{produto.tipoProduto}"
				footerText="" filterMatchMode="endsWith"
				sortBy="#{produto.tipoProduto}">
				<f:facet name="header">
					<h:outputText value="Tipo Produto" />
				</f:facet>
				<p:cellEditor>
					<f:facet name="output">
						<h:outputText value="#{produto.tipoProduto}" />
					</f:facet>
					<f:facet name="input">
						<p:inputText id="tipoProdutoInput" value="#{produto.tipoProduto}"
							style="width:100%" />
					</f:facet>
				</p:cellEditor>
			</p:column>

			<p:column id="estagioColumn" filterBy="#{produto.estagio}"
				footerText="" filterOptions="#{tabelaProdutoBean.estagioOptions}"
				filterMatchMode="exact">
				<f:facet name="header">
					<h:outputText value="Estágio" />
				</f:facet>
				<p:cellEditor>
					<f:facet name="output">
						<h:outputText value="#{produto.estagio}" />
					</f:facet>
					<f:facet name="input">
						<h:selectOneMenu id="estagiosInput" value="#{produto.estagio}">
							<f:selectItems value="#{tabelaProdutoBean.estagios}" var="est"
								itemLabel="#{est}" itemValue="#{est}" />
						</h:selectOneMenu>
					</f:facet>
				</p:cellEditor>
			</p:column>

			<p:column id="degrupoIdColumn" filterBy="#{produto.degrupoId}"
				footerText="" filterMatchMode="endsWith">
				<f:facet name="header">
					<h:outputText value="Grupo ID" />
				</f:facet>
				<p:cellEditor>
					<f:facet name="output">
						<h:outputText value="#{produto.degrupoId}" />
					</f:facet>
					<f:facet name="input">
						<p:inputText id="degrupoIdInput" value="#{produto.degrupoId}"
							style="width:100%" />
					</f:facet>
				</p:cellEditor>
			</p:column>

			<p:column id="deartifactIdColumn" filterBy="#{produto.deartifactId}"
				footerText="" filterMatchMode="endsWith">
				<f:facet name="header">
					<h:outputText value="Artifact ID" />
				</f:facet>
				<p:cellEditor>
					<f:facet name="output">
						<h:outputText value="#{produto.deartifactId}" />
					</f:facet>
					<f:facet name="input">
						<p:inputText id="deartifactIdInput"
							value="#{produto.deartifactId}" style="width:100%" />
					</f:facet>
				</p:cellEditor>
			</p:column>

			<p:column style="width:3%" exportable="false">
				<p:rowEditor />
			</p:column>
		</p:dataTable>

		<h:panelGrid columns="2">

			<p:panel header="Exportar Todos Os Dados">
				<h:commandLink id="xls1" ajax="false">
					<p:graphicImage value="/images/excel.png" />
					<pe:exporter type="xlsx" target="dataTable" fileName="produtos" />
				</h:commandLink>

				<h:commandLink id="pdf1" ajax="false">
					<p:graphicImage value="/images/pdf.png" />
					<pe:exporter type="pdf" target="dataTable" fileName="produtos" />
				</h:commandLink>
			</p:panel>

			<p:panel header="Exportar Dados Da Pagina Atual">
				<h:commandLink id="xls2" ajax="false">
					<p:graphicImage value="/images/excel.png" />
					<pe:exporter type="xlsx" target="dataTable" fileName="produtos"
						pageOnly="true" />
				</h:commandLink>

				<h:commandLink id="pdf2" ajax="false">
					<p:graphicImage value="/images/pdf.png" />
					<pe:exporter type="pdf" target="dataTable" fileName="produtos"
						pageOnly="true" />
				</h:commandLink>
			</p:panel>
		</h:panelGrid>
	</h:form>
</h:body>
</html>
With p:dataExporter it works fine, just don't bring the data onp:cellEditor.
"Everything should be made as simple as possible, but not simpler."

Albert Einstein

User avatar
sudheer
PrimeFaces Core Developer
Posts: 4345
Joined: 16 Oct 2011, 19:19
Location: Singapore

24 Jun 2013, 20:43

Extensions exporter supports .xlsx(2007 format) where as PF dataexporter supports .xls(2003 format).You need two depencies for extensions exporter.Check this link https://github.com/primefaces-extension ... ng-Started

Jars required

1.poi-3.9
2.poi-ooxml
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/

___________________
Sudheer Jonna

vendra00
Posts: 10
Joined: 22 May 2013, 22:08
Location: Brazil

26 Jun 2013, 20:20

many thanks for the help, now it works fine! :D
"Everything should be made as simple as possible, but not simpler."

Albert Einstein

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 61 guests