Search code examples
javajasper-reports

How to access a parameter in jrxml file and Print it?


My query is, I have set a parameter in my java file like given below

Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("ReportTitle", "MRSG Quarterly Report");

How to access this in my jrxml file and Print it as a text?


Solution

  • You need to declare the parameter in your jrxml

     <parameter name="ReportTitle" class="java.lang.String"></parameter>
    

    Then call it in a text field

    <textField isBlankWhenNull="true">               
      <textFieldExpression class="java.lang.String"><![CDATA[$P{"ReportTitle"}]]>
      </textFieldExpression>
    </textField>