简体   繁体   中英

dataexporter primefaces not working

I am using PrimeFaces 5 and using dataexporter to export .xls and pdf file. When i click on export, nothing seems to be happening. Below is my code:

<h:body>
    <h:form id="formReport">
        <ui:include src="menu.xhtml"></ui:include>
             <p:dataTable id="ngoReporttbl" var="obj" styleClass="datatable"
                    value="#{ngoReportController.ngoReportList}" >

                    <f:facet name="header">
                      List of Cars
                        <p:commandButton id="toggler" type="button" value="columns" style="float:right" icon="ui-icon-calculator"></p:commandButton>
                        <p:columnToggler datasource="ngoReporttbl" trigger="toggler"></p:columnToggler>
                    </f:facet>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="NGO Id"></h:outputText>
                        </f:facet>
                        <h:outputText value="#{obj.ngoId}"></h:outputText>
                    </p:column>
                        <p:column>
                        <f:facet name="header">
                            <h:outputText value="NGO Name Org"></h:outputText>
                        </f:facet>
                        <h:outputText value="#{obj.ngoNameOrg}"></h:outputText>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Environment"></h:outputText>
                        </f:facet>
                        <h:outputText value="#{obj.environment}"></h:outputText>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Livelihood"></h:outputText>
                        </f:facet>
                        <h:outputText value="#{obj.livelihood}"></h:outputText>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Country"></h:outputText>
                        </f:facet>
                        <h:outputText value="#{obj.country}"></h:outputText>
                    </p:column>
                </p:dataTable>  

                <h:commandLink style="float:right">
                    <p:graphicImage  value="../images/pdf.png" width="45"></p:graphicImage>
                   <p:dataExporter type="pdf" target="ngoReporttbl" fileName="ngoReport" pageOnly="true"></p:dataExporter>
                 </h:commandLink>
                 <h:commandLink style="float:right">
                    <p:graphicImage  value="../images/csv.png" width="45"></p:graphicImage>
                   <p:dataExporter type="xls" target="ngoReporttbl" fileName="ngoReport" pageOnly="true"></p:dataExporter>
                 </h:commandLink>

        <ui:include src="footer.xhtml"></ui:include>
    </h:form>
</h:body>

Both the dataTable and the Export command are within one form. It is similar to the example given on primefaces.org site. But, I'm unable to export data to pdf, cvs.

For XLS, you don't need anything extra. For PDF, you need POI. Primefaces only works with 2.1.7 due to licensing issues. And your commandButton / commandLink need to be ajax="false". Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM