views:

244

answers:

1

Is there a way I could declare a variable of type HashMap which would call some java method to populate the HashMap?

I want to have a hashmap in a report so depending on what the value of a certain field is, I would like to get the full description of it from an Hashmap.

A: 

The expression used in jasper are actually java expressions (or Groovy if you're using that).

So, for instance you can use something like:

<parameter name="name" class="java.lang.String"/>
   <parameter name="name_percent" class="java.lang.String" isForPrompting="false">
   <defaultValueExpression>
       <![CDATA["%" + $P{name} + "%"]]>
   </defaultValueExpression>
</parameter>

Where the expression in the CDATA expression is a java expression. You can import classes using the element, and you can add parameters to the report using the element.

MatthieuF