Problem with datable + link

UI Components for JSF
Post Reply
orko2002
Posts: 44
Joined: 27 Dec 2010, 22:31

27 Dec 2010, 22:37

Hi i'm very new in prime...
I'm trying to put a data table with in a column a link to download a pdf file aditional in the footer a download data explorer, the problem is if i put a action in the commandlink with ajax=false the pdf works but the dataexplorer do the same download the jasper pdf. If put ajax="true" works the dataexplorer but the pdf do nothing what im doing wrong?

Code: Select all

				<p:dataTable id="tbl" var="op" value="#{ordenDePagoBean.ordenes}" 
					paginatorAlwaysVisible="false" paginator="true" rows="10">
					
                    <p:column headerText="#{msg.label_fecha}">
	                	<h:outputText value="#{op.fechaOrdenDePago}" />
					</p:column>

                    <p:column headerText="#{msg.label_numero}" >
	                	<h:outputText value="#{op.numeroOrdenDePago}" />
					</p:column>

                    <p:column headerText="#{msg.label_empresa}" >
	                	<h:outputText value="#{op.empresa}" />
					</p:column>

                    <p:column headerText="#{msg.label_monto}" >
	                	<h:outputText value="#{op.monto}" />
					</p:column>

                    <p:column headerText="" >
						<p:commandLink actionListener="#{ordenDePagoBean.download(op)}" update="messages">
							<p:graphicImage value="/images/pdf.png" />
						</p:commandLink>
					</p:column>
				</p:dataTable>

				<h:panelGrid columns="2">  
				    <p:panel header="Exportar todos">  
				        <h:commandLink>  
				            <p:graphicImage value="/images/excel.png" />  
				            <p:dataExporter type="xls" target="tbl" fileName="ordenes" />  
				        </h:commandLink>  
				  
				        <h:commandLink>  
				            <p:graphicImage value="/images/pdf.png" />  
				            <p:dataExporter type="pdf" target="tbl" fileName="ordenes"/>  
				        </h:commandLink>  
				          
				        <h:commandLink>  
				            <p:graphicImage value="/images/csv.png" />  
				            <p:dataExporter type="csv" target="tbl" fileName="ordenes" />  
				        </h:commandLink>  
				          
				        <h:commandLink>  
				            <p:graphicImage value="/images/xml.png" />  
				            <p:dataExporter type="xml" target="tbl" fileName="ordenes" />  
				        </h:commandLink>  
				    </p:panel>  
				      
				    <p:panel header="Exportar pagina actual">  
				        <h:commandLink>  
				            <p:graphicImage value="/images/excel.png" />  
				            <p:dataExporter type="xls" target="tbl" fileName="ordenes" pageOnly="true"/>  
				        </h:commandLink>  
				  
				        <h:commandLink>  
				            <p:graphicImage value="/images/pdf.png" />  
				            <p:dataExporter type="pdf" target="tbl" fileName="ordenes" pageOnly="true"/>  
				        </h:commandLink>  
				          
				        <h:commandLink>  
				            <p:graphicImage value="/images/csv.png" />  
				            <p:dataExporter type="csv" target="tbl" fileName="ordenes" pageOnly="true"/>  
				        </h:commandLink>  
				          
				        <h:commandLink>  
				            <p:graphicImage value="/images/xml.png" />  
				            <p:dataExporter type="xml" target="tbl" fileName="ordenes" pageOnly="true"/>  
				        </h:commandLink>  
				    </p:panel>  
				</h:panelGrid>
my backbean

Code: Select all

	public void download(OrdenDePago op) throws DaoException {
		if (op != null) {
			ReporteOrdenDePagoService.downloadPdf(op.getCuit(), op.getNumeroOrdenDePago());
		}
	}

healeyb
Posts: 365
Joined: 07 Apr 2010, 16:05

28 Dec 2010, 02:43

Was this the line that was causing problems? the messages component
is not being updated? If so use h:form id="formid" and then use update=
"formid:messages".

Code: Select all

<p:commandLink actionListener="#{ordenDePagoBean.download(op)}" update="messages">
Regards,
Brendan.

orko2002
Posts: 44
Joined: 27 Dec 2010, 22:31

29 Dec 2010, 17:04

Thank for the reply. No that line works fine, i dont know whats the problem, i want to put a download link y every row and a dataexporter i change the datatable to this

Code: Select all

 
	<p:dataTable id="tbl" var="op" value="#{ordenDePagoBean.ordenes}" 
				paginator="true" rows="10" paginatorPosition="top" paginatorAlwaysVisible="true">
					
                    <p:column sortBy="#{op.fechaOrdenDePago}" parser="date" headerText="#{msg.label_fecha}">
	                	<h:outputText value="#{op.fechaOrdenDePagoDMY}" />
					</p:column>

                    <p:column sortBy="#{op.numeroOrdenDePago}" parser="number" headerText="#{msg.label_numero}" >
	                	<h:outputText value="#{op.numeroOrdenDePago}" style="float: right" />
					</p:column>

                    <p:column sortBy="#{op.empresa}" headerText="#{msg.label_empresa}" >
	                	<h:outputText value="#{op.empresa}" />
					</p:column>

                    <p:column headerText="#{msg.label_monto}" >
	                	<h:outputText value="#{op.monto}" style="float: right" />
					</p:column>

                    <p:column headerText="" >
	        		<h:commandLink action="#{ordenDePagoBean.bajarPdf()}">  
						<p:graphicImage value="/images/pdf.png" />
						<f:setPropertyActionListener value="#{op}" target="#{ordenDePagoBean.selectedOp}" />
				</h:commandLink>
		</p:column>
	</p:dataTable>
using the f:setPropertyActionListener and change the name of the method from download to bajarPdf and works...

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 50 guests