Boa tarde.
Estou pesquisando alguns fóruns e tópicos pela internet para tentar entender o funcionamento do JasperReport. Não tive sucesso! Todos os métodos que encontrei utilizam um resource como parâmetro juntamento com o InputStream do arquivo .jarper e o Map.
O que eu gostaria de fazer:
HttpServletRequest request = ServletActionContext.getRequest();
String numeroPedido = request.getParameter("numero");
pedido = pedidoServicoRepository.getById(Integer.parseInt(numeroPedido));
Map<String, Object> parametros = new HashMap<String, Object>();
parametros.put("numero_pedido", pedido.getNumeroPedido());
parametros.put("permissionario", pedido.getOcupacao().getPermissionario().toString());
parametros.put("pnr", pedido.getOcupacao().getPnr().toString());
parametros.put("data_solicitacao", pedido.getDataPedido().toString());
parametros.put("situacao_pedido", pedido.getSituacaoPedidoServico().getDescricao());
parametros.put("prioridade_pedido", pedido.getPrioridadePedidoServico().getDescricao());
parametros.put("email", pedido.getEmail());
parametros.put("fone", pedido.getFone());
parametros.put("descricao_pedido", pedido.getDescricaoPedido());
parametros.put("retorno_pedido", pedido.getRetornoPedido());
E agora gostaria de compilar o jrxml que contém todos os campos declarados no Map:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="extrair-pedido-servico" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.5"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="388"/>
<parameter name="numero_pedido" class="java.lang.String"/>
<parameter name="permissionario" class="java.lang.String"/>
<parameter name="pnr" class="java.lang.String"/>
<parameter name="situacao_pedido" class="java.lang.String"/>
<parameter name="data_pedido" class="java.lang.String"/>
<parameter name="prioridade_pedido" class="java.lang.String"/>
<parameter name="email" class="java.lang.String"/>
<parameter name="fone" class="java.lang.String"/>
<parameter name="descricao_pedido" class="java.lang.String"/>
<parameter name="retorno_pedido" class="java.lang.String"/>
<field name="endereco" class="java.lang.String"/>
<field name="permissionario" class="java.lang.String"/>
<field name="numero_pedido" class="java.lang.String"/>
<field name="id_situacao_pedido_servico" class="java.lang.String"/>
<field name="email" class="java.lang.String"/>
<field name="fone" class="java.lang.String"/>
<field name="data_pedido" class="java.sql.Date"/>
<field name="id_prioridade_pedido_servico" class="java.lang.String"/>
<field name="retorno_pedido" class="java.lang.String"/>
<field name="descricao_pedido" class="java.lang.String"/>
<field name="dt_ocupacao" class="java.sql.Date"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="170" splitType="Stretch">
<staticText>
<reportElement x="152" y="134" width="250" height="36"/>
<textElement textAlignment="Center">
<font fontName="Arial Black" size="23" isBold="false"/>
</textElement>
<text><![CDATA[Pedido de Serviço]]></text>
</staticText>
<staticText>
<reportElement x="212" y="98" width="129" height="36"/>
<textElement textAlignment="Center">
<font fontName="Arial Black" size="23" isBold="false" isUnderline="false"/>
</textElement>
<text><![CDATA[SIGEPNR]]></text>
</staticText>
<image>
<reportElement x="226" y="6" width="105" height="92"/>
<imageExpression><![CDATA["C:\\Users\\Édion\\Desktop\\Áhgil\\Associação dos Permissionários do COM7°DN\\Logo\\SPI - Nova Logo\\lOGO_spi_FINAL_X11.jpg"]]></imageExpression>
</image>
</band>
</title>
<pageHeader>
<band height="94" splitType="Stretch">
<staticText>
<reportElement x="123" y="32" width="328" height="31"/>
<textElement>
<font size="24"/>
</textElement>
<text><![CDATA[Extrato para Simples Consulta]]></text>
</staticText>
</band>
</pageHeader>
<columnHeader>
<band height="118" splitType="Stretch">
<staticText>
<reportElement x="2" y="25" width="70" height="14"/>
<textElement>
<font isBold="true" isUnderline="true"/>
</textElement>
<text><![CDATA[NOME: ]]></text>
</staticText>
<staticText>
<reportElement x="2" y="42" width="70" height="14"/>
<textElement>
<font isBold="true" isUnderline="true"/>
</textElement>
<text><![CDATA[PNR: ]]></text>
</staticText>
<staticText>
<reportElement x="283" y="42" width="133" height="14"/>
<textElement>
<font isBold="true" isUnderline="true"/>
</textElement>
<text><![CDATA[DATA DE SOLICITAÇÃO: ]]></text>
</staticText>
<textField>
<reportElement x="416" y="42" width="139" height="14"/>
<textElement/>
<textFieldExpression><![CDATA[$P{data_pedido}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="2" y="59" width="70" height="14"/>
<textElement>
<font isBold="true" isUnderline="true"/>
</textElement>
<text><![CDATA[SITUAÇÃO:]]></text>
</staticText>
<textField>
<reportElement x="72" y="59" width="201" height="14"/>
<textElement/>
<textFieldExpression><![CDATA[$P{situacao_pedido}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="283" y="59" width="133" height="14"/>
<textElement>
<font isBold="true" isItalic="false" isUnderline="true"/>
</textElement>
<text><![CDATA[PRIORIDADE:]]></text>
</staticText>
<textField>
<reportElement x="416" y="59" width="139" height="14"/>
<textElement/>
<textFieldExpression><![CDATA[$P{prioridade_pedido}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="2" y="83" width="72" height="13"/>
<textElement>
<font isBold="true" isItalic="false" isUnderline="true"/>
</textElement>
<text><![CDATA[E-MAIL:]]></text>
</staticText>
<textField>
<reportElement x="72" y="83" width="201" height="13"/>
<textElement/>
<textFieldExpression><![CDATA[$P{email}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="283" y="83" width="133" height="13"/>
<textElement>
<font isBold="true" isItalic="false" isUnderline="true"/>
</textElement>
<text><![CDATA[FONE:]]></text>
</staticText>
<textField>
<reportElement x="416" y="83" width="139" height="13"/>
<textElement/>
<textFieldExpression><![CDATA[$P{fone}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="2" y="1" width="70" height="14"/>
<textElement>
<font isBold="true" isUnderline="true"/>
</textElement>
<text><![CDATA[NR PEDIDO:]]></text>
</staticText>
<textField>
<reportElement x="72" y="1" width="481" height="14"/>
<textElement/>
<textFieldExpression><![CDATA[$P{numero_pedido}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="72" y="42" width="201" height="14"/>
<textElement/>
<textFieldExpression><![CDATA[$P{pnr}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="74" y="25" width="479" height="14"/>
<textElement/>
<textFieldExpression><![CDATA[$P{permissionario}]]></textFieldExpression>
</textField>
</band>
</columnHeader>
<detail>
<band height="160" splitType="Stretch">
<textField>
<reportElement x="0" y="56" width="553" height="87"/>
<textElement textAlignment="Justified"/>
<textFieldExpression><![CDATA[$P{descricao_pedido}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="189" y="24" width="168" height="19"/>
<textElement>
<font size="14" isBold="true" isItalic="false" isUnderline="true"/>
</textElement>
<text><![CDATA[DESCRIÇÃO DO PEDIDO]]></text>
</staticText>
</band>
</detail>
<columnFooter>
<band height="163" splitType="Stretch">
<staticText>
<reportElement x="189" y="10" width="168" height="20"/>
<textElement textAlignment="Center">
<font size="14" isBold="true" isUnderline="true"/>
</textElement>
<text><![CDATA[HISTÓRICO DO PEDIDO]]></text>
</staticText>
<textField>
<reportElement x="0" y="40" width="553" height="79"/>
<textElement/>
<textFieldExpression><![CDATA[$P{retorno_pedido}]]></textFieldExpression>
</textField>
</band>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
Como posso gerar um pdf com isso?
Isso é uma aplicação web e também estava tendo problemas na localização do arquivos jrxml/jasper dentro do WebContent.
Agradeço a ajuda.