How to generate a pdf with Primefaces 5.3 using dataexport

Asked

Viewed 358 times

0

This is my screen to generate the 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>

Generates the following error when I click the button:

javax.servlet.Servletexception: Cannot find Component for Expression "subTableRespostas" 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)

  • I’m using the same examples of the primeface 5.3 showcase

1 answer

1


Dear colleague,

Looking at the Primefaces documentation, this dataExport does not have a subTable within a datatable. Probably the implementation that creates the PDF can’t get the data through that component. Try to take the subTable and just leave the datatable.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.