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.
5 Answers:
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`.
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