How to pass parameter value in the field value ?

0

 

i want to do this $F{$P{subject}}.

i create general structure for .jrxml file. i pass query dynamically to the query tag like this,

    <queryString language="SQL">
        <![CDATA[$P!{Query}]]>
    </queryString>

So here Field is dyanamically changes. field can be fill by parameter ?

jani99harsh's picture
Joined: Mar 3 2017 - 1:12am
Last seen: 2 months 1 week ago

1 Answer:

0

Since JR 6.3.1 you could use the net.sf.jasperreports.sql.field.column.name property for each field, to map the column name dinamically. Meaning you could use a static field name in JRXML that will map a column name in your dynamic query. For instance:

 

 <parameter name="paramId" class="java.lang.String">
   <defaultValueExpression><![CDATA["emp_id"]]></defaultValueExpression>
 </parameter>
...
 <field name="id" class="java.lang.Integer">
   <propertyExpression name="net.sf.jasperreports.sql.field.column.name"><![CDATA[$P{paramId}]]></propertyExpression>
 </field>

In the above example, whenever you will use the $F{id} expression in the JRXML file, the "emp_id" column in the sql query will be referenced, via the parameter paramId.

shertage's picture
1529
Joined: Sep 26 2006 - 8:06pm
Last seen: 1 month 2 days ago
Feedback
randomness