How to generate a pdf with Primefaces 5.3 using dataexport

0

This is my screen for generating pdf

<p:panel style="margin-left:30%" id="pnlTituloGabarito">
        <p:commandButton value="Export to PDF" ajax="false">
        <p:dataExporter type="pdf" target="subTableRespostas" fileName="gabaritoPDF"/>
        </p:commandButton>
        <h:outputLabel value="Instituição: "/>
        <h:outputText value="#{GabaritoRespostaControl.prova.instituicao.nomeFantasia}"/>
        <h:outputLabel style="margin-left:2.5%" value="Turma / Período: "/>
        <h:outputText value=" #{GabaritoRespostaControl.prova.periodo}"/>
        <a:newLine/>
        <h:outputLabel value="Curso: "/>
        <h:outputText value=" #{GabaritoRespostaControl.prova.curso.nome}"/>
        <h:outputLabel style="margin-left:1.5%" value="Disciplina: "/>
        <h:outputText value="#{GabaritoRespostaControl.prova.disciplina.nome}"/>
    </p:panel>
    <p:dataTable  var="listaPaginada" id="dTblRespostas" emptyMessage="Não há nenhuma questão para esta prova!" scrollable="true" scrollHeight="440" style="width:30%; margin-left:30%" value="#{GabaritoRespostaControl.gabarito.dataTableDividido }">
        <p:subTable id="subTableRespostas" value="#{listaPaginada }"  var="questao">
            <p:column headerText="Questão">
                <h:outputText value="#{questao.key }"/>
            </p:column>
            <p:column headerText="Resposta">
                <h:outputText value="#{questao.value }"/>
            </p:column>
        </p:subTable>
    </p:dataTable>

</p:panel>

Generate the following error when I click on the button:

  

javax.servlet.ServletException: Can not find component for expression "subTableResponses" referenced from "formCorpo: j_idt92".       javax.faces.webapp.FacesServlet.service (FacesServlet.java:659)       org.primefaces.webapp.filter.FileUploadFilter.doFilter (FileUploadFilter.java:78)       org.apache.tomcat.websocket.server.WsFilter.doFilter (WsFilter.java:52)

    
asked by anonymous 08.06.2017 / 01:39

1 answer

1

Dear colleague,

Looking at the documentation of Primefaces, this dataExport does not have a subTable within a dataTable. The implementation that creates the PDF is probably not able to get the data from this component. Try to get the subTable and just leave the dataTable.

    
11.06.2017 / 00:42