quacker.2715 Posted May 1, 2017 Share Posted May 1, 2017 My report is using a parameter to determine the report title. It is displaying null when there is no data. I've tried changing the variable $V{reportName} Evaluation Time, but no luck. Can anybody help me?Thanks.PS: It is using mssql data adapter and the current querystring does not return any row. To return rows, change 2=1 to 1=1.<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 5.6.1.final using JasperReports Library version 5.6.1 --><!-- 2017-05-01T15:39:40 --><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="Evaluate" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a736ce53-7e76-4194-9086-96d2270a6250"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="SQLEXPRESSR2"/> <parameter name="ReportType" class="java.lang.String"> <defaultValueExpression><![CDATA["A"]]></defaultValueExpression> </parameter> <queryString language="SQL"> <![CDATA[select Col1 from (values (1),(2)) as a(Col1) where 2=1]]> </queryString> <field name="Col1" class="java.lang.Integer"/> <variable name="ReportName" class="java.lang.String"> <variableExpression><![CDATA[$P{ReportType}.equals("A")? $V{reportTitleA}:$V{reportTitleB}]]></variableExpression> </variable> <variable name="reportTitleA" class="java.lang.String"> <variableExpression><![CDATA["Report A"]]></variableExpression> </variable> <variable name="reportTitleB" class="java.lang.String"> <variableExpression><![CDATA["Report Other"]]></variableExpression> </variable> <pageHeader> <band height="22" splitType="Stretch"> <textField evaluationTime="Report"> <reportElement x="0" y="0" width="390" height="20" uuid="98c519b9-7350-4cd6-a71e-f2fb1c0e7b80"/> <textFieldExpression><![CDATA[$V{ReportName}]]></textFieldExpression> </textField> </band> </pageHeader> <columnHeader> <band height="14" splitType="Stretch"/> </columnHeader> <detail> <band height="15" splitType="Stretch"> <property name="local_mesure_unitheight" value="pixel"/> <property name="com.jaspersoft.studio.unit.height" value="px"/> <textField> <reportElement x="0" y="0" width="100" height="14" uuid="82ab5741-1138-4173-88f5-42ef07a6cb9f"> <property name="local_mesure_unitheight" value="pixel"/> <property name="com.jaspersoft.studio.unit.height" value="px"/> </reportElement> <textFieldExpression><![CDATA[$F{Col1}]]></textFieldExpression> </textField> </band> </detail></jasperReport>[/code] Link to comment Share on other sites More sharing options...
mlopez_1 Posted May 1, 2017 Share Posted May 1, 2017 Use paramaters for this purpose instead. Is what I use.Mariano Link to comment Share on other sites More sharing options...
nessrineselmi215 Posted May 3, 2017 Share Posted May 3, 2017 its simply Link to comment Share on other sites More sharing options...
Solution szaharia Posted May 4, 2017 Solution Share Posted May 4, 2017 Hi,In order to be properly evaluated, the variable ReportName should be placed after reportTitleA and reportTitleB. You also need to set the initial value expressions for all variables: <variable name="reportTitleA" class="java.lang.String"> <variableExpression><![CDATA["Report A"]]></variableExpression> <initialValueExpression><![CDATA["Report A"]]></initialValueExpression> </variable> <variable name="reportTitleB" class="java.lang.String"> <variableExpression><![CDATA["Report Other"]]></variableExpression> <initialValueExpression><![CDATA["Report Other"]]></initialValueExpression> </variable> <variable name="ReportName" class="java.lang.String"> <variableExpression><![CDATA[$P{ReportType}.equals("A")? $V{reportTitleA}:$V{reportTitleB}]]></variableExpression> <initialValueExpression><![CDATA[$P{ReportType}.equals("A")? $V{reportTitleA}:$V{reportTitleB}]]></initialValueExpression> </variable>[/code] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now