Buongiorno a tutti,
sto sviluppando un' applicazione in Java che gira sotto Tomcat 6 e sfrutta un DB MySql con circa 50 tabelle.
Per stampare Report utilizzo iReport che permette le creazione di documenti PDF e la relativa stampa; fino qui tutto Ok.
Sono riuscito ad integrare i template (file .jrxml e .jasper) nella mia applicazione, ma non riesco a sfruttare a pieno iReport per il seguente problema:
- in questo momento, dall' applicazione quando richiamo la classe Java che genera Report, mi collego diretto al DB ed eseguo comandi mysql (select, etc..) per tirar fuori dati, presenti in quel momento in una tabella specifica.
- Ma, se io desidero tirar fuori solo deteminati dati, o meglio, solo quelli impostati in un filtro dall' utente, cosa debbo fare?
Riporto di seguito il template .jrxml della Tabella Citta sulla quale eseguo Report; in questo modo al richiamo del template (e quindi del comando Stampa lato utente) nel Report generato riporto tutti i campi presenti, non tenendo conto magari del filtro impostato dall' utente...
Non so magari anche a Voi è capitato....ma non so davvero come impostare dati dinamici, ossia, passare al template solo ed esclusivamente i dati che desidero tirar fuori...codice:<?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...sperreport.xsd" name="ReportCitta" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"> <queryString language="SQL"> <![CDATA[SELECT tb_citta.`COD_CITTA` AS tb_citta_COD_CITTA, tb_citta.`DESCR` AS tb_citta_DESCR, tb_citta.`COD_PROVINCIA` AS tb_citta_COD_PROVINCIA, tb_citta.`COD_CAP_IN` AS tb_citta_COD_CAP_IN, tb_citta.`COD_CAP_FI` AS tb_citta_COD_CAP_FI, tb_citta.`COD_NAZIONE` AS tb_citta_COD_NAZIONE, FROM `tb_citta` tb_citta]]> </queryString> <field name="tb_citta_DESCR" class="java.lang.String"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="tb_citta_COD_CITTA" class="java.lang.String"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="tb_citta_COD_PROVINCIA" class="java.lang.String"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="tb_citta_COD_CAP_IN" class="java.lang.String"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="tb_citta_COD_CAP_FI" class="java.lang.String"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="tb_citta_COD_NAZIONE" class="java.lang.String"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <background> <band/> </background> <title> <band height="58"> <line> <reportElement x="0" y="4" width="802" height="1"/> </line> <line> <reportElement positionType="FixRelativeToBottom" x="0" y="54" width="802" height="1"/> </line> <staticText> <reportElement x="255" y="23" width="235" height="24"/> <textElement> <font fontName="Broadway" size="20" isBold="true"/> </textElement> <text><![CDATA[Riepilogo Citta']]></text> </staticText> <staticText> <reportElement x="169" y="28" width="89" height="20"/> <textElement> <font isItalic="true"/> </textElement> <text><![CDATA[Stampa richiesta : ]]></text> </staticText> </band> </title> <pageHeader> <band/> </pageHeader> <columnHeader> <band height="24"> <staticText> <reportElement mode="Opaque" x="11" y="0" width="69" height="18" forecolor="#FFFFFF" backcolor="#999999"/> <textElement> <font size="12" isBold="true" isItalic="true"/> </textElement> <text><![CDATA[Descrizione]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="141" y="0" width="69" height="18" forecolor="#FFFFFF" backcolor="#999999"/> <textElement> <font size="12" isBold="true" isItalic="true"/> </textElement> <text><![CDATA[Citta']]></text> </staticText> <staticText> <reportElement mode="Opaque" x="284" y="2" width="91" height="18" forecolor="#FFFFFF" backcolor="#999999"/> <textElement> <font size="12" isBold="true" isItalic="true"/> </textElement> <text><![CDATA[Provincia]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="439" y="0" width="69" height="18" forecolor="#FFFFFF" backcolor="#999999"/> <textElement> <font size="12" isBold="true" isItalic="true"/> </textElement> <text><![CDATA[CAP Iniziale]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="567" y="2" width="69" height="18" forecolor="#FFFFFF" backcolor="#999999"/> <textElement> <font size="12" isBold="true" isItalic="true"/> </textElement> <text><![CDATA[CAP Finale]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="697" y="2" width="69" height="18" forecolor="#FFFFFF" backcolor="#999999"/> <textElement> <font size="12" isBold="true" isItalic="true"/> </textElement> <text><![CDATA[Nazione]]></text> </staticText> </band> </columnHeader> <detail> <band height="32"> <textField isStretchWithOverflow="true" isBlankWhenNull="true" hyperlinkType="None"> <reportElement x="7" y="0" width="69" height="20" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true"/> <textElement verticalAlignment="Middle"> <font size="12"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{tb_citta_DESCR}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true" hyperlinkType="None"> <reportElement x="141" y="0" width="69" height="20" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true"/> <textElement> <font size="12"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{tb_citta_COD_CITTA}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true" hyperlinkType="None"> <reportElement x="296" y="0" width="69" height="20" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true"/> <textElement> <font size="12"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{tb_citta_COD_PROVINCIA}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true" hyperlinkType="None"> <reportElement x="439" y="0" width="69" height="20" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true"/> <textElement> <font size="12"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{tb_citta_COD_CAP_IN}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true" hyperlinkType="None"> <reportElement x="567" y="0" width="69" height="20" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true"/> <textElement> <font size="12"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{tb_citta_COD_CAP_FI}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true" hyperlinkType="None"> <reportElement x="697" y="0" width="69" height="20" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true"/> <textElement> <font size="12"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{tb_citta_COD_NAZIONE}]]></textFieldExpression> </textField> <line> <reportElement x="89" y="-27" width="1" height="52"/> </line> <line> <reportElement x="0" y="-28" width="1" height="54"/> </line> <line> <reportElement x="254" y="-27" width="1" height="52"/> </line> <line> <reportElement x="681" y="-25" width="1" height="49"/> </line> <line> <reportElement x="530" y="-26" width="1" height="51"/> </line> <line> <reportElement x="402" y="-23" width="1" height="49"/> </line> <line> <reportElement x="802" y="-25" width="1" height="49"/> </line> <line> <reportElement isPrintRepeatedValues="false" x="1" y="-5" width="801" height="1"/> </line> <line> <reportElement x="1" y="25" width="801" height="1" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true"/> </line> </band> </detail> <columnFooter> <band/> </columnFooter> <pageFooter> <band height="30"> <textField evaluationTime="Report" pattern="" isBlankWhenNull="false" hyperlinkType="None"> <reportElement key="textField" x="766" y="7" width="36" height="19" forecolor="#000000" backcolor="#FFFFFF"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement> <font size="10" isBold="true"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA["" + $V{PAGE_NUMBER}]]></textFieldExpression> </textField> <textField pattern="" isBlankWhenNull="false" hyperlinkType="None"> <reportElement key="textField" x="596" y="7" width="170" height="19" forecolor="#000000" backcolor="#FFFFFF"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement textAlignment="Right"> <font size="10" isBold="true"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA["Page " + $V{PAGE_NUMBER} + " of "]]></textFieldExpression> </textField> <textField pattern="" isBlankWhenNull="false" hyperlinkType="None"> <reportElement key="textField" x="1" y="6" width="209" height="19" forecolor="#000000" backcolor="#FFFFFF"/> <box> <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> </box> <textElement> <font size="10" isBold="true"/> </textElement> <textFieldExpression class="java.util.Date"><![CDATA[new Date()]]></textFieldExpression> </textField> </band> </pageFooter> <summary> <band/> </summary> </jasperReport>
Grazie per l' aiuto e buona giornata a tutti...

Rispondi quotando