dataExporter inside composite component

UI Components for JSF
Post Reply
peter
Posts: 27
Joined: 10 Mar 2010, 16:18

16 Apr 2010, 11:09

Hi! I want to use p:dataExporter inside of composite component. Component shows fine in using page but when i click on commandLink to export the data it gives me error "Cannot find component "billsTable" in view.". dataExporter can not reach the dataTable component in using page. How to solve this? Below is my jsf code:
Composite Component

Code: Select all

 <cc:interface displayName="data Export table"
                expert="false"
                preferred="true"
                name="dataExportTable" >
      <cc:attribute name="dataTableId"
			displayName="Data table id"
			required="true"
			type="java.lang.String" />
      <cc:attribute name="pdfEncoding"
			displayName="Encoding of exported pdf file, for ex. Cp1250"
                       required="false"
                       default="UTF-8"
		       type="java.lang.String" />
  </cc:interface>

  <cc:implementation>
      <table cellpadding="2px;">
	 <tr>
            <td>
		<h:commandLink title="#{msg.export_to_excell}" >
			<p:dataExporter type="xls"
                                                 target="#{cc.attrs.dataTableId}"
						fileName="#{msg.bills_export_file_name}" />
			      <h:graphicImage value="#{resource['images:exportExcell.png']}"
							style="border-style: none;" />
		</h:commandLink>
	     </td>
          </tr>
    </table>
  </cc:implementation>
Using page

Code: Select all

<p:dataTable id="billsTable" ... >
...
</p:dataTable>
<ez:exportTable dataTableId="billsTable"
                         pdfEncoding="Cp1250"/>
I'm using mojarra 2.0 jsf implementation with tomcat 6.0.20 and latest primefaces snapshot 2.0.1 (downloaded on 16th april).

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

19 Apr 2010, 01:05

Hi,

What is the line in stack trace?

peter
Posts: 27
Joined: 10 Mar 2010, 16:18

19 Apr 2010, 08:41

Hi Cagatay! Here's the stack trace:

Code: Select all

javax.faces.FacesException: Cannot find component "billsTable" in view.
	at org.primefaces.component.export.DataExporter.processAction(DataExporter.java:88)
	at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
	at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:772)
	at javax.faces.component.UICommand.broadcast(UICommand.java:300)
	at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:775)
	at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1267)
	at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at pl.comfortel.dol.filters.ForcedLoginFilter.doFilter(ForcedLoginFilter.java:97)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
	at java.lang.Thread.run(Thread.java:619)

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

20 Apr 2010, 18:42

I'm not sure why it cant find it, can you try giving the client id of datatable, also please provide the full page source, maybe we are missing something.

FYI DataExporter is calling UIComponent.findComponent api. See;

http://java.sun.com/javaee/javaserverfa ... ng.String)

peter
Posts: 27
Joined: 10 Mar 2010, 16:18

30 Apr 2010, 11:47

Problem solved! After reading javadoc for findComponent, i found a solution. Target attribute for dataExporter has to start with separator character, which is ':'. With ':' at the beginning, findComponent looks for component in jsf page, and without it, findComponent starts searching in composite component.
Thanks for help Cagatay!

peter
Posts: 27
Joined: 10 Mar 2010, 16:18

30 Apr 2010, 11:53

And one important thing - one also has to include form id before dataTable id , even if from has prependId="false", so target should looks like: target=":myForm:myDataTable" .

rdeoliveira
Posts: 61
Joined: 23 Jun 2011, 11:40

24 Jun 2011, 11:39

Hello everybody

I have the same problem. When i click on export (excel or pdf), i have the following error:

Code: Select all

exception

javax.servlet.ServletException: Cannot find component ":pdtUserSearch" in view.
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:422)

root cause

javax.faces.FacesException: Cannot find component ":pdtUserSearch" in view.
	org.primefaces.component.export.DataExporter.processAction(DataExporter.java:89)
	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.UIData.broadcast(UIData.java:1093)
	org.primefaces.component.datatable.DataTable.broadcast(DataTable.java:630)
	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:409)
Here's my xhtml code :

Code: Select all

<p:dataTable var="user" paginator="true" rows="2" paginatorPosition="bottom" lazy="true"
		                   paginatorAlwaysVisible="false" value="#{loginManagedBean.lazyUserSearch}" id="pdtUserSearch"
		                   paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
		                   selectionMode="single" selection="#{loginManagedBean.selectedUser}">
		                   <f:facet name="header">
		                       <cc:align position="right">
		                           #{msg.genExportLabel} :
			                       <h:commandLink>
			                           <h:graphicImage value="/resources/imgs/icons/page_white_acrobat.png" />
			                           <p:dataExporter target=":pdtUserSearch" type="pdf" fileName="userSearch" />
			                       </h:commandLink>
			                       <p:spacer width="10" />
			                       <h:commandLink>
			                           <h:graphicImage value="/resources/imgs/icons/page_white_excel.png" />
			                           <p:dataExporter target=":pdtUserSearch" type="xls" fileName="userSearch" />
			                       </h:commandLink>
		                       </cc:align>
		                   </f:facet>
		                   <p:column>
                               <f:facet name="header">
                                   #{msg.usersMgmtLabelLogin}
                               </f:facet>                              
                               <p:commandLink>
                                  #{user.login}
                               </p:commandLink>
                           </p:column>
		                   <p:column>
		                       <f:facet name="header">
		                           #{msg.usersMgmtLabelEmail}
		                       </f:facet>
		                       #{user.email}		                       
		                   </p:column>
		               </p:dataTable>
When i look the source code i have this :

Code: Select all

<div id="j_idt33:j_idt84:pdtUserSearch" class="ui-datatable ui-widget">
Any idea about this problem ?

Thanks
JSF 2.0
Primefaces 3.0.M3
Tomcat 7.0
--
French user of primefaces

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 34 guests