Netbeans Does not recognize .jasper file

0

I'm having trouble calling JSF application report. Do not search data in NetBeans 8.1 does not recognize Jaspersoft generated file. I do not find plugin for this version.

ReportOrdered.xhtmlPrices

<ui:define name="titulo">Relatório de pedidos emitidos</ui:define>

<ui:define name="corpo">
    <h:form id="frm">
        <h1>Relatório de pedidos emitidos</h1>

        <p:messages autoUpdate="true" closable="true" />

        <p:toolbar style="margin-top: 20px">
            <p:toolbarGroup>
                <p:commandButton value="Emitir" action="#{relatorioPedidosEmitidosBean.emitir}"
                    ajax="true" />
            </p:toolbarGroup>
        </p:toolbar>

        <p:panelGrid columns="2" id="painel" style="width: 100%; margin-top: 20px"
                columnClasses="rotulo, campo">
            <p:outputLabel value="Data de criação" />
            <h:panelGroup>
                <p:calendar value="#{relatorioPedidosEmitidosBean.dataInicio}" label="Data inicial" 
                    pattern="dd/MM/yyyy" size="8" />
                <p:spacer width="8" />
                <h:outputText value="a" />
                <p:spacer width="8" />
                <p:calendar value="#{relatorioPedidosEmitidosBean.dataFim}" label="Data final" 
                    pattern="dd/MM/yyyy" size="8" />
            </h:panelGroup>
        </p:panelGrid>
    </h:form>
</ui:define>

ReportAssignedBean.java

@Named
@RequestScoped
public class RelatorioPedidosEmitidosBean implements Serializable {

private static final long serialVersionUID = 0L;

private Date dataInicio;
private Date dataFim;

@Inject
private FacesContext facesContext;

@Inject
private HttpServletResponse response;

@Inject
private EntityManager manager;

public void emitir() {
    Map<String, Object> parametros = new HashMap<>();
    parametros.put("data_inicio", this.dataInicio);
    parametros.put("data_fim", this.dataFim);

    ExecutorRelatorio executor = new ExecutorRelatorio("/relatorios/relatorios_pedidos_vendas.jasper",
            this.response, parametros, "Pedidos emitidos.pdf");

    Session session = manager.unwrap(Session.class);
    session.doWork(executor);

    if (executor.isRelatorioGerado()) {
        facesContext.responseComplete();
    } else {
        FacesUtil.addErrorMessage("A execução do relatório não retornou dados.");
    }
}

@NotNull
public Date getDataInicio() {
    return dataInicio;
}

public void setDataInicio(Date dataInicio) {
    this.dataInicio = dataInicio;
}

@NotNull
public Date getDataFim() {
    return dataFim;
}

public void setDataFim(Date dataFim) {
    this.dataFim = dataFim;
}

}

ExecutorReport.java

public class ExecutorRelatorio implements Work {

private String caminhoRelatorio;
private HttpServletResponse response;
private Map<String, Object> parametros;
private String nomeArquivoSaida;

private boolean relatorioGerado;

public ExecutorRelatorio(String caminhoRelatorio,
        HttpServletResponse response, Map<String, Object> parametros,
        String nomeArquivoSaida) {
    this.caminhoRelatorio = caminhoRelatorio;
    this.response = response;
    this.parametros = parametros;
    this.nomeArquivoSaida = nomeArquivoSaida;

    this.parametros.put(JRParameter.REPORT_LOCALE, new Locale("pt", "BR"));
}

@Override
public void execute(Connection connection) throws SQLException {
    try {
        InputStream relatorioStream = this.getClass().getResourceAsStream(this.caminhoRelatorio);

        JasperPrint print = JasperFillManager.fillReport(relatorioStream, this.parametros, connection);
        this.relatorioGerado = print.getPages().size() > 0;

        if (this.relatorioGerado) {
            Exporter<ExporterInput, PdfReportConfiguration, PdfExporterConfiguration, 
                OutputStreamExporterOutput> exportador = new JRPdfExporter();
            exportador.setExporterInput(new SimpleExporterInput(print));
            exportador.setExporterOutput(new SimpleOutputStreamExporterOutput(response.getOutputStream()));

                            JasperExportManager.exportReportToPdfStream(print, response.getOutputStream());

            response.setContentType("application/pdf");
            response.setHeader("Content-Disposition", "attachment; filename=\"" 
                    + this.nomeArquivoSaida  + "\"");

            exportador.exportReport();
        }
    } catch (Exception e) {
        throw new SQLException("Erro ao executar relatório " + this.caminhoRelatorio, e);
    }
}

public boolean isRelatorioGerado() {
    return relatorioGerado;
}

log when I try to issue a report;

MonitorFilter :: WARNING: the monitor filter must be the first filter in the chain. MonitorFilter :: WARNING: the monitor filter must be the first filter in the chain. Hibernate: select user0_.id as id1_7_, user0_.email as email2_7_, user0_.name as_name_7_, user0_.save the password4_7_ from user user0_ where lower (user0_.email) =? Hibernate: select groups0_.usuario_id user_1_8_0_, groups0_.grupo_id group_id2_8_0_, group1_.id as id1_3_1_, group1_.descriation as descrica2_3_1_, group1_.name the_name3_3_1_ from group_user groups0_ inner join group group1_ on groups0_.grupo_id = group1_.id where groups0_. user_id =? MonitorFilter :: WARNING: the monitor filter must be the first filter in the chain. Hibernate: select date (data_criacao) as data, sum (this_.value_total) as y1_ from request this_ where this_.data_criacao>? group by date (data_creation) Hibernate: select date (data_criacao) as data, sum (this_.value_total) as y1_ from request this_ where this_.data_criacao>? and this_.vender_id =? group by date (data_creation) MonitorFilter :: WARNING: the monitor filter must be the first filter in the chain. MonitorFilter :: WARNING: the monitor filter must be the first filter in the chain.

Image package

    
asked by anonymous 08.09.2016 / 07:04

1 answer

0

To generate the report with JasperReport you will need the following libraries:

  • commons-beanutils
  • commons-collections
  • commons-digester
  • commons-logging
  • groovy-all
  • iText poi
  • jasperreports

Make sure you have all of them added and configured to your project, use Ireport or JasperStudio to develop the report design, noting that the report is only compatible with Java 7. In such a way that there will be no reliance on Netbeans, everything will happen independently.

I hope I have helped!

    
14.09.2016 / 15:46