Jump to content
Changes to the Jaspersoft community edition download ×

Do the parameters work or not ?


2004 IR Help

Recommended Posts

By: Luciano Zanin - cianoz

Do the parameters work or not ?

2004-03-26 03:12

I'm very confused about the parameters in iReport 0.2.3. Please, I would to know if parameters are working on iReport 0.2.3 or not. I tried to use them and i got any result, so i read some posts on this forum but i didn't understand if it is a "in progress" feature or it is already working.

 

Most of all, i would to know:

? if parameters feature is intended as: "when running the report the user can be asked for parameters"

? if a parameter can consist in a list of items proposed to the user, and if it can be done inserting a query in the parameter definition field

 

Thanks in advance to everyone who will post an answer.

 

 

 

 

By: Rick Millar - rmillar

RE: Do the parameters work or not ?

2004-03-26 08:23

Yes, parameters do work in all versions of iReports. However, if you are looking for something in iReports to prompt a user for the parameters at run time, then you won't find it. The confusion may lie in a misconception of what iReports is. iReports is a design-time tool to create reports to be executed using the Jasperreports reporting engine. iReports does have report previewers so that you can see what your report will look like. However, there is no mechanism for prompting for parameters. That said, however, you can still test your reports by giving your parameters default values. These default values will be used at runtime. You can assign a default value to a parameter in the property sheet for the parameter.

 

I do not believe you can insert a query directly into the parameter definition field. If you want to access values from a database for use at runtime, I believe you will need to include those values in your report query and map them to Fields that you can reference.

 

Hope my explanation does more to help than to confuse.

 

Rick

 

 

 

 

By: Luciano Zanin - cianoz

RE: Do the parameters work or not ?

2004-03-27 01:03

Yes, you have been clear, thanks Rick.

 

I'd have several questions to ask about the argument, really, but i understand i cannot put them all in this thread.

Only, i should need help to know why in my simple(s) report(s) i always get a "report has no pages" msg if i assign a default value to my parameter (a correct value, obviously)

 

I tried to refer different fields to a parameter, but the default value always return an empty report.

 

 

 

 

By: Rick Millar - rmillar

RE: Do the parameters work or not ?

2004-03-29 08:43

Cianoz,

 

Please post your XML file. There can be many reasons why you are getting an empty report.

 

Rick

 

 

 

 

By: Luciano Zanin - cianoz

RE: Do the parameters work or not ?

2004-03-29 09:40

Here is the XMl file of my simple report:

 

<?xml version="1.0" encoding="UTF-8" ?>

<!-- Created with iReport - A designer for JasperReports -->

<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">

<jasperReport

name="contatti_saie2_ori_1"

columnCount="1"

printOrder="Vertical"

orientation="Portrait"

pageWidth="595"

pageHeight="842"

columnWidth="538"

columnSpacing="0"

leftMargin="25"

rightMargin="25"

topMargin="17"

bottomMargin="28"

whenNoDataType="NoPages"

isTitleNewPage="false"

isSummaryNewPage="false">

<parameter name="nazione" isForPrompting="false" class="java.lang.String">

<defaultValueExpression ><![CDATA["America"]]></defaultValueExpression>

</parameter>

<queryString><![CDATA[sELECT * FROM saie204t

WHERE stato <> "" AND stato=$P{nazione}

ORDER BY stato]]></queryString>

<field name="data" class="java.util.Date"/>

<field name="nominativo" class="java.lang.String"/>

<field name="azienda" class="java.lang.String"/>

<field name="indirizzo" class="java.lang.String"/>

<field name="citta" class="java.lang.String"/>

<field name="prov" class="java.lang.String"/>

<field name="tipocont" class="java.lang.String"/>

<field name="stato" class="java.lang.String"/>

<field name="id" class="java.lang.Double"/>

<variable name="test" class="java.lang.String" resetType="None" calculation="Nothing">

<variableExpression><![CDATA["test"]]></variableExpression>

<initialValueExpression><![CDATA["test" ]]></initialValueExpression>

</variable>

<background>

<band height="0" isSplitAllowed="true" >

</band>

</background>

<title>

<band height="0" isSplitAllowed="true" >

</band>

</title>

<pageHeader>

<band height="32" isSplitAllowed="true" >

<staticText>

<reportElement

mode="Transparent"

x="93"

y="1"

width="380"

height="20"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Center" verticalAlignment="Top" lineSpacing="Single">

<font fontName="Helvetica" pdfFontName="Helvetica" size="14" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" />

</textElement>

<text><![CDATA[Contatti da Saie2 2004]]></text>

</staticText>

<staticText>

<reportElement

mode="Transparent"

x="94"

y="2"

width="380"

height="20"

forecolor="#808080"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Center" verticalAlignment="Top" lineSpacing="Single">

<font fontName="Helvetica" pdfFontName="Helvetica" size="14" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" />

</textElement>

<text><![CDATA[Contatti da Saie2 2004]]></text>

</staticText>

</band>

</pageHeader>

<columnHeader>

<band height="0" isSplitAllowed="true" >

</band>

</columnHeader>

<detail>

<band height="52" isSplitAllowed="true" >

<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="102"

y="0"

width="134"

height="20"

forecolor="#0000CC"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Middle" lineSpacing="Single">

<font fontName="Arial" pdfFontName="Helvetica" size="9" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[$F{nominativo}]]></textFieldExpression>

</textField>

<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="235"

y="0"

width="129"

height="20"

forecolor="#660099"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Middle" lineSpacing="Single">

<font fontName="Arial" pdfFontName="Helvetica" size="9" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[$F{azienda}]]></textFieldExpression>

</textField>

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="368"

y="1"

width="176"

height="13"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="Helvetica" pdfFontName="Helvetica" size="9" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[$F{indirizzo}]]></textFieldExpression>

</textField>

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="368"

y="15"

width="130"

height="13"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="Helvetica" pdfFontName="Helvetica" size="9" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[$F{citta}]]></textFieldExpression>

</textField>

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="499"

y="15"

width="19"

height="13"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="Helvetica" pdfFontName="Helvetica" size="9" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[$F{prov}]]></textFieldExpression>

</textField>

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="65"

y="25"

width="130"

height="14"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="Helvetica" pdfFontName="Helvetica" size="9" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[$F{tipocont}]]></textFieldExpression>

</textField>

<staticText>

<reportElement

mode="Transparent"

x="2"

y="25"

width="60"

height="14"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="Helvetica" pdfFontName="Helvetica" size="9" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" />

</textElement>

<text><![CDATA[Tipo contatto]]></text>

</staticText>

<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="368"

y="28"

width="176"

height="13"

forecolor="#660000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="Arial" pdfFontName="Helvetica" size="9" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[$F{stato}]]></textFieldExpression>

</textField>

<staticText>

<reportElement

mode="Transparent"

x="2"

y="4"

width="24"

height="14"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="Helvetica" pdfFontName="Helvetica" size="8" isBold="false" isItalic="true" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" />

</textElement>

<text><![CDATA[Reg.]]></text>

</staticText>

<textField isStretchWithOverflow="false" pattern=" #,###" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Opaque"

x="23"

y="4"

width="25"

height="14"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="SansSerif" pdfFontName="Helvetica" size="8" isBold="false" isItalic="true" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.Double"><![CDATA[$F{id}]]></textFieldExpression>

</textField>

</band>

</detail>

<columnFooter>

<band height="0" isSplitAllowed="true" >

</band>

</columnFooter>

<pageFooter>

<band height="22" isSplitAllowed="true" >

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="334"

y="6"

width="174"

height="13"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Right" verticalAlignment="Top" lineSpacing="Single">

<font fontName="Helvetica" pdfFontName="Helvetica" size="9" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA["Page " + $V{PAGE_NUMBER} + " of "]]></textFieldExpression>

</textField>

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Report" hyperlinkType="None" > <reportElement

mode="Transparent"

x="508"

y="6"

width="36"

height="13"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="Helvetica" pdfFontName="Helvetica" size="9" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA["" + $V{PAGE_NUMBER}]]></textFieldExpression>

</textField>

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="4"

y="6"

width="123"

height="13"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="Helvetica" pdfFontName="Helvetica" size="9" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.util.Date"><![CDATA[new Date()]]></textFieldExpression>

</textField>

</band>

</pageFooter>

<summary>

<band height="0" isSplitAllowed="true" >

</band>

</summary>

</jasperReport>

 

 

I set "America" as default value for the "nazione" parameter; i have several records that matches "America" as value.

 

 

 

 

By: Rick Millar - rmillar

RE: Do the parameters work or not ?

2004-03-29 10:39

Cianoz,

 

I think the problem may lie in your where clause.

 

WHERE stato <> "" AND stato=$P{nazione}.

 

First, I don't think you need to check for <> "" since you will have to exactly match nazione to return a row. The only time you will return null values is if nazion is null. Try removing the check just to make sure it isn't the cause of your problem.

 

Second, you should put a "!" in the reference to the parameter.

 

WHERE stato=$P!{nazione}

 

Hope that helps.

 

 

 

 

 

 

By: Rick Millar - rmillar

RE: Do the parameters work or not ?

2004-03-29 11:58

Also,

 

make sure the case of your parameter matches the case of the value in the database since the where clause is case sensitive. You might want to make the parameter all upper case and use the UPPER() function to ensure that all values in the table are converted to upper case in the comparison as well.

 

WHERE stato <> "" AND UPPER(stato)=$P{nazione}

 

 

 

 

By: Luciano Zanin - cianoz

RE: Do the parameters work or not ?

2004-03-30 03:42

I considered all of your suggestions but i can't get the expected result.

 

I didn't tell you that i'm using an ODBC driver that i thought could be responsible of this abnormal behaviour.

My connection uses an ODBC datasource defined by a Microsoft Visual Fox Pro driver, and in iReport i set a connection using the "sun.jdbc.odbc.JdbcOdbcDriver".

I recreated a similar database in MySQL and tried to set the parameter as suggested... and it works!

 

So i have to think the ODBC driver is unable to handle parameters correctly (i can't imagine anything else).

Thanks to everybody for your help.

 

(well, there is still some problems running parameters with OpenReports, but i'll open an other thread for this...)

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...