PrimeFaces 3.2 dataExporter not working - primefaces

I am using PrimeFaces 3.2 and want to export a dynamically created table as an .xls file. When i click on export, nothing seems to be happening.
Export Code
<h:commandLink id="Download_Excel_Format" ajax="false">
<p:graphicImage value="/resources/Excel_Icon.jpg" height="25" width="25" />
<p:dataExporter type="xls" target="dataTable" fileName="SomeFileName"/>
</h:commandLink>
dataTable
<p:dataTable id="dataTable" var="c" value="#{databaseSearch.customerList}"
paginator="true" rows="10" paginatorAlwaysVisible="false"
paginatorTemplate="Page {CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} Rows per page {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15,30">
<p:column>
<f:facet name="header">
<h:outputText value="Machine" />
</f:facet>
<p:commandButton id="basic" value="#{c.machine}" action="#{updateEntry.setMachine(c.machine)}" oncomplete="dlg1.show();" styleClass="ui-Machinebutton" update=":Update_Entry"/>
<p:tooltip for="basic" value="Update/Delete Database Entry" showEffect="fade" hideEffect="fade" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Company" />
</f:facet>
<h:outputText value="#{c.company}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Contact" />
</f:facet>
<h:outputText value="#{c.contact}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Phone" />
</f:facet>
<h:outputText value="#{c.phone}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Email" />
</f:facet>
<!-- <h:outputText value="#{c.email}" />-->
<h:outputLink value="mailto:#{c.email}?Subject=Baseline Monitor Alert | Machine : #{c.machine}">#{c.email}</h:outputLink>
</p:column>
</p:dataTable>
Both the dataTable and the Export command are within one form, however the dataTable is in a output panel (within the form).
Form
<h:form prependId="false" id="Main_Form">
</h:form>
Output Panel
<p:outputPanel id="panel" autoUpdate="false">
</p:outputPanel>
I even updated to PrimeFaces 3.4.2 to see if the dataExporter would work, but no avail, as far as i remember 3.2 has a bug if the dataTable generates columns dynamically, but that is not the case here right? am i doing something wrong?
dataExporter option looks much simpler, but if there is an alternative which is simple enough i am up for it.
Update
I am using a GlassFish 3.1.2.2 (build 5) & NetBeans 7.2.1, i do not get any errors, just the page refresh's, has a '#' at the end of the URL and stops, no errors means that i am not lacking any dependencies either... so i am lost here ...

Ok, i found the answer ! Tricky one though ... i had a commandButton with the ID=submit...renamed it and that did the trick !
<p:commandButton id="xsubmit" icon="ui-icon-search" title="Search Database" update="panel" actionListener="#{databaseSearch.customerList}" />

Related

Datatable emptyMessage is not shown in PF5.3

I am using PF 5.3, on (weblogic 11g/jsf2.0/java 1.6).
I thought the issue of not shown emptyMessage in Datatable is fixed in 5.3, but inspite of using the latest version, i still dont see the message. Below is my sample code.
<p:dataTable id="attaDt" var="fileRow" value="#{pendpaybean.selectedPayDetailsFiles}"
rowIndexVar="rowIndex"
emptyMessage="No Files Uploaded"
>
<p:column headerText="Uploaded Date"
width="15px;" style="text-align:center"
>
<h:outputText value="#{fileRow.columns[0]}" />
</p:column>
<p:column headerText="Uploaded By"
width="30px;" style="text-align:center"
>
<h:outputText value="#{fileRow.columns[3]}" />
</p:column>
</p:datatable>
Any help ?
Your code works well. NOTE I put attribute value to null for showing emptyMessage.
Your adapted code:
<h:body>
<h:form>
<p:dataTable id="attaDt" value="#{null}" var="fileRow" rowIndexVar="rowIndex" emptyMessage="No Files Uploaded">
<p:column headerText="Uploaded Date" width="15px;" style="text-align:center">
<h:outputText value="#{fileRow.columns[0]}" />
</p:column>
<p:column headerText="Uploaded By" width="30px;" style="text-align:center">
<h:outputText value="#{fileRow.columns[3]}" />
</p:column>
</p:dataTable>
</h:form>
</h:body>

export text then datalist in excel and pdf with dataexporter

I am using primefaces 3.4.2 jar. I have a datatable with four columns. In two columns I have a datalist and I want to export text showed by datalist. But when I export it, it shows the following "org.primefaces.component.datalist.DataList#1195cc3" in the pdf and xls file.
<p:dataTable emptyMessage="#{messages['empty.result.set']}" id="searchResult" var="row" value="#{managePessoaJuridica.manageableList}" rows="10" paginator="true" paginatorPosition="top" paginatorAlwaysVisible="false" style="display:#{managePessoaJuridica.manageableList == null? 'none': ''}">
<p:column styleClass="column_icons" exportable="false">
<p:panelGrid columns="#{pessoaJuridicaController.showSelectAction?3:2}">
<p:commandButton id="selectAction" icon="ui-icon-circle-check" title="#{messages['action.select']}" action="#{pessoaJuridicaController.select(row.id)}" immediate="true" process="#this" rendered="#{pessoaJuridicaController.showSelectAction}"/>
<p:commandButton id="editAction" icon="ui-icon-pencil" title="#{messages['action.edit']}" action="#{pessoaJuridicaController.load(row.id)}" immediate="true" process="#this" update="#form"/>
<p:commandButton id="deleteAction" icon="ui-icon-trash" title="#{messages['action.delete']}" action="#{pessoaJuridicaController.delete(row.id)}" immediate="true" process="#this" update="searchResult"
onclick="return confirm('#{messages['confirm.delete.this']} #{messages['pessoa.juridica.view.title']}');" />
</p:panelGrid>
</p:column>
<p:column id="column_nome" sortBy="#{row.nome}" >
<f:facet name="header">
<h:outputText id="columnHeader_nome" value="#{messages['pessoa.nome']}"/>
</f:facet>
<h:outputText id="nome" value="#{row.nome}">
</h:outputText>
</p:column>
<p:column style="width:0px;">
<f:facet name="header">
<h:outputText id="columnHeader_categoriasPessoa" value="#{messages['pessoa.categorias.pessoa']}"/>
</f:facet>
<p:dataList type="definition" id="categoriasPessoa" var="item" value="#{row.categoriasPessoa}" >
<p:column>
<h:outputText id="item_categoriasPessoa" value="#{item}" converter="com.domain.configuracao.crud.CategoriaPessoaJsfConverter"/>
</p:column>
</p:dataList>
</p:column>
<p:column style="width:0px;">
<f:facet name="header">
<h:outputText id="columnHeader_identificacoesPessoa" value="#{messages['pessoa.identificacoes.pessoa']}"/>
</f:facet>
<p:dataList type="definition" id="identificacoesPessoa" var="item" value="#{row.identificacoesPessoa}">
<p:column>
<h:outputText id="item_categoriaIdentificacoes" value="#{pessoaJuridicaController.getCategoriaIdentificacao(item)}" converter="com.domain.configuracao.crud.CategoriaIdentificacaoJsfConverter"/>:
<h:outputText id="item_identificacoesPessoa" value="#{item}" converter="com.domain.configuracao.crud.IdentificacaoPessoaJsfConverter"/>
</p:column>
</p:dataList>
</p:column>
<p:column id="column_ativo" sortBy="#{row.ativo}" >
<f:facet name="header">
<h:outputText id="columnHeader_ativo" value="#{messages['classe.base.cadastro.ativo']}" />
</f:facet>
<h:outputText id="ativo" value="#{row.ativo}" converter="com.BooleanJsfConverter" >
</h:outputText>
</p:column>
<f:facet name="footer">
<p:menuButton value="#{messages['export.action']}" rendered="#{not empty managePessoaJuridica.manageableList}">
<p:menuitem value="#{messages['export.spreadsheet']}" ajax="false">
<p:dataExporter type="xls" target="searchResult" fileName="export" excludeColumns="0" encoding="ISO-8859-1"/>
</p:menuitem>
<p:menuitem value="#{messages['export.pdf']}" ajax="false">
<pe:exporter type="pdf" target="searchResult" fileName="export" excludeColumns="0" encoding="ISO-8859-1"/>
</p:menuitem>
<p:menuitem value="#{messages['export.csv']}" ajax="false">
<p:dataExporter type="csv" target="searchResult" fileName="export" excludeColumns="0" encoding="ISO-8859-1"/>
</p:menuitem>
</p:menuButton>
<p:spacer width="10"/>
<h:outputText value="#{fn:length(managePessoaJuridica.manageableList)} #{messages['records.found']}" rendered="#{not empty managePessoaJuridica.manageableList}"/>
</f:facet>
</p:dataTable>
But when I export it, it shows the following
"org.primefaces.component.datalist.DataList#1195cc3" in the pdf and
xls file.
Obviously, Primefaces's data exporter use the toString() method of an object to print its "value(s)".
Suggestions :
Write a custom exporter (recommended)
Override toString() method of org.primefaces.component.datalist.DataList (not advised)

Primefaces rowExpansion not working in primefaces 3.5

I am trying to use the p:rowToggler and p:rowExpansion in my datatable. It was working fine on primefaces 3.2, recently i upgraded to primefaces 3.5. Since then it is not working. Following is the datatable with roToggler and rowExpansion
<p:datatable value="#{myBean.valueList}">
<p:column>
<p:rowToggler/>
</p:column>
<p:rowExpansion>
...
</p:rowExpansion>
</p:datatable>
Any help would be appreciated
Thanks
Praveen
Please try as below,
<p:dataTable var="education"
value="#{backingBean.schoolList}"
reflow="true"
paginator="true"
sortMode="multiple"
emptyMessage="No records found."
rows="#{backingBean.rowsPerPage}">
<p:column headerText="Details" styleClass="Wid10">
<p:rowToggler expandLabel="Show" collapseLabel="Hide" icon="ui-icon-close"/>
</p:column>
<p:column headerText="Center">
<h:outputText value="#{education.centerName}"/>
</p:column>
<p:column headerText="Address">
<h:outputText value="#{education.addr}" />
</p:column>
<p:rowExpansion>
<p:outputLabel value="Course: " styleClass="FontBold" />
<BR />
<h:outputText value="#{education.course}" />
<Br />
<p:outputLabel value="Details: " styleClass="FontBold" />
<BR />
<h:outputText value="#{education.details}" />
</p:rowExpansion>
</p:dataTable>

How do I load rows into dataTable 2 when a row in dataTable 1 is clicked?

I have a form with a panel and two dataTables. The code below has had most of the columns removed to make it easier to follow.
<h:form id="invoiceLookUp">
<p:panel>
<f:facet name="header">
<p:column style="font-weight: bold;">
Invoice Selection Criteria
</p:column>
</f:facet>
<h:outputText value="Seq ID"/>
<p:inputText
id="invoice_header_seq_id" styleClass="field" size="10"
value="#{invoiceBean.invoice_header_seq_id}"
/>
<p:commandButton
update="invoicesTable" value="Look Up"
action="#{invoiceBean.addInvoices()}"
/>
</p:panel>
<p:dataTable
id="invoicesTable" var="invoice" rows="15" lazy="true" selectionMode="single"
value="#{invoiceBean.invoiceList}"
rowKey="#{invoice.invoiceHeader.invoiceHeaderSeqId}"
selection="#{invoiceBean.selectedInvoice}"
>
<p:ajax event="rowSelect" update=":invoiceLookUp:invoiceLinesTable"/>
<f:facet name="header"><h:outputText value="Invoice Headers" /></f:facet>
<p:column sortBy="#{invoice.invoiceHeader.invoiceHeaderSeqId}" id="invoiceSeqId">
<f:facet name="header">
<h:outputText value="Seq ID" title="Invoice Header Seq ID"/>
</f:facet>
<h:outputText value="#{invoice.invoiceHeader.invoiceHeaderSeqId}" />
</p:column>
</p:dataTable>
<p:dataTable
id="invoiceLinesTable" var="invoiceLine" rows="15" lazy="true" selectionMode="single"
value="#{invoiceBean.selectedInvoice.invoiceLines}"
rowKey="#{invoiceLine.invoiceLineSeqId}"
selection="#{invoiceBean.selectedInvoiceLine}"
>
<f:facet name="header"><h:outputText value="Invoice Lines" /></f:facet>
<p:column sortBy="#{invoiceLine.invoiceLineSeqId}" id="invoiceLineSeqId">
<f:facet name="header"><h:outputText value="Line Seq ID"/></f:facet>
<h:outputText value="#{invoiceLine.invoiceLineSeqId}"/>
</p:column>
</p:dataTable>
</h:form>
When you enter a Seq ID and then click Look Up, the table populates as expected. When I select a row in the invoicesTable, I get the following error:
javax.faces.FacesException: Cannot find component with identifier ":invoiceLookUp:invoiceLinesTable" referenced from "form:invoiceLookUp:invoicesTable".
Can anyone tell me what I am doing wrong?

Primefaces RowEditor does not work with Spring Webflow

I have Primefaces DataTable with in-cell editing:
<p:dataTable id="docsTable" editable="true" value="#{customer.docs}" var="doc" style="border-width:0px;" >
<p:growl id="docsMessages" showDetail="true"></p:growl>
<p:ajax event="rowEdit" update="docsMessages,docsTable" listener="#{customerController.onEditDocument}"></p:ajax>
<p:ajax event="rowEditCancel" update="docsMessages,docsTable" listener="#{customerController.onEditDocumentCancel}"></p:ajax>
<p:column headerText="Document Type">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{doc.docType}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{doc.docType}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Document Number">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{doc.docNum}"></h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText value="#{doc.docNum}"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column>
<p:rowEditor></p:rowEditor>
</p:column>
</p:dataTable>
Here is corresponding SWF view state definition:
<view-state id="enterDetails" view="/WEB-INF/views/tiles/customer/s3-custDetails.xhtml" model="customer"> <!-- tiles/customer/s3-custDetail -->
<secured attributes="ROLE_WEB" />
<var name="customerController" class="com.my.CustomerController"/>
<transition on="addNewDocument">
<evaluate expression="customer.docs.add(new com.my.CustomersDocs())"></evaluate>
<render fragments="custDetails"></render>
</transition>
</view-state>
The view renders fine, values are saved in backing bean, and rowEdit listener is called in my controller as well. However it never exits the editor mode no matter what user does. I did some network sniffing and it appears SWF is only sending back the viewstate, whereas Primefaces showcase also sends back rendered fragment.
How do I fix this?
This is a bug/deficiency in Spring webflow. It is mentioned in Spring docs (see http://static.springsource.org/spring-webflow/docs/2.3.x/reference/html/ch13s10.html) but in a rather obscure fashion and does not mention relation to partial rendering issues. The fix is simple, add the following in webflow:flow-executor tag:
<webflow:flow-execution-attributes>
<webflow:redirect-in-same-state value="false"/>
</webflow:flow-execution-attributes>