Meaning of Exclamation mark jasper uses in $P ?

1

Hello,

I'm looking for a method to pass all parameters supplied to my main report to the subreports, to do I think about passing a parameter that is actually a map of parameters and then fetching the actuall object using something like ParameterUtils.P($P{P}, "paramName").

This is the only parameter that will be passed to the subreport.

I'm wonding if in the ParameterUtils I should be doing more then :

public class ParameterUtils {
    public static Object P(Map<String, Object> jasperParameters, String key) {
        return jasperParameters.get(key);
    }
}
 

 

Thank you,

Maxim.

hq4ever's picture
39
Joined: Sep 18 2007 - 11:02pm
Last seen: 13 years 2 months ago

5 Answers:

0
perhaps the question wasn\'t clear enough, I\'m asking for the meaning of syntax like $P!{paramName}. The rest of the question was just to provide background as for the reason to the question.
hq4ever's picture
39
Joined: Sep 18 2007 - 11:02pm
Last seen: 13 years 2 months ago
1

To pass all parameters you can just pass $P{REPORT_PARAMETERS_MAP} to your subreport. 

The meaning of exclaimation points in parameters is to pass them into sql without adding quotes around them.  For example, I used this some time ago when I needed to pass in a dynamic table name: select * from `$P!{prefix}_table`.

zmanning's picture
Joined: Dec 15 2006 - 5:49am
Last seen: 13 years 11 months ago
0
Wait a minute, Do you mean that If I pass $P{REPORT_PARAMETERS_MAP} to the subreport I will automatically get all report parameters in my subreport? If so this is very useful for me. Thank you, Maxim.
hq4ever's picture
39
Joined: Sep 18 2007 - 11:02pm
Last seen: 13 years 2 months ago
2

First of all, let me get the doubt.

You mean to ask the use of exclamation in $P!{param_name}.

Lets suppose I have the following query,

Select L_name, 
age_1,
$P!{check} as Characteristic
from table


This paramater allows me to view the various characteristics of the person I am refering above. It would be dependent on another parameter, let us call that parameter as $P{value}. 

In the default expression of the parameter "check", I could define the following;

$P{value}==1 ? "Physical_strength" : $P{value}==2 ? "IQ": "Nature";

Depending on the various values of $P{value}, the parameter "check" will input the values into the query and mind you, the above three stated characteristics are nothing but the table columns, so basically we are displaying different columns based on the parameter "value".

For instance, the parameter "value" was entered as 2, so my running query would look like (which you can check in the logs);

 

select L_name, age_1, IQ as characteristics from table

 

I know its too late but I Hope This was of some help to the new learners.


Thank you
KKriplani

 

kkriplani's picture
876
Joined: Sep 4 2015 - 2:18am
Last seen: 10 months 3 days ago
0

--

fender989100's picture
Joined: Sep 5 2012 - 12:35am
Last seen: 3 years 4 months ago
Feedback