Parameter Assignment and Report Lifecycle

Hello everyone.

My predecessor developed a lot of reports with iReport. All those reports rely on a mechanism where a first parameter P1 is prompted to the user and then, during the report generation, the value of P1 is checked and copied into a second prameter P2 that is used in the actual queries.

My problem is that I am not able to replicate this behaviour in iReport 5.5 or Jasper Studio 6.x
It seems Jasper tries to execute the underlying queries before assigning the values to the parameters needed for the queries to have meaning.

So, what am I doing wrong? How the report lifecycle works? Is Jasper executing queries before assigning the related parameters a value?

Below is attanched the simpliest jrxml i could compile as an example.

Thank you all very much for the help.

P.S. This html editor has serious problems with the Vivaldi Browser.

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version using JasperReports Library version 5.5.0  -->
<!-- 2016-08-03T10:28:13 -->
<jasperReport xmlns="" xmlns:xsi="" xsi:schemaLocation="" name="Blank_A4_1" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="0301fad8-615c-4f40-82f4-5a51de576379">
    <parameter name="_idNoPrompt" class="java.lang.Integer" isForPrompting="false">
    <parameter name="idPrompt" class="java.lang.Integer"/>
        <![CDATA[select f1, f2 from table where id = $P{_idNoPrompt}]]>
    <field name="name" class="java.lang.String"/>
    <field name="surname" class="java.lang.String"/>
        <band splitType="Stretch"/>
        <band height="86" splitType="Stretch">
                <reportElement x="260" y="20" width="100" height="30" uuid="d040e37f-a5a3-4810-92a2-9f1be468211d"/>
                <reportElement x="400" y="20" width="100" height="30" uuid="5ce3ca73-78b4-471a-a9f1-6e51feadabcd"/>
                <reportElement x="130" y="0" width="100" height="30" uuid="3e38dc81-ee8a-4f78-b1aa-9e82c0683846"/>
                <reportElement x="20" y="0" width="100" height="30" uuid="e4f7561b-cd19-412b-89c9-009a831e726c"/>
francesco.basenghi_1's picture
Joined: Mar 29 2016 - 1:27am
Last seen: 6 years 2 weeks ago

1 Answer:

Hello Francesco,

parameters like variables are evaluated in the order their expressions are encountered in the JRXML. In your example you have idNoPrompt before idPrompt. When idNoPrompt default value expression is evaluated the idPrompt value does not exist therefore it ends up with null. JasperReports first evaluates parameters and then evaluates the query. $V{} Variables can get re-evaluated during the the report runtime based on their reset type and incrementer.

Friendly User's picture
Joined: Oct 8 2009 - 5:59am
Last seen: 1 week 2 days ago