Jump to content

getDefaultValueExpression of parameter


linuxapple

Recommended Posts

Hi All,

 

While trying to getDefaultValueExpression of parameter, I just got a class expression, which printed net.sf.jasperreports.engine.design.JRDesignExpression@d898be .

What I need is default value of the parameter.

 

Any suggestions will be greatly appreciated.

Code:
jasperDesign=JRXmlLoader.load(fileName);

List list=jasperDesign.getParametersList();

if(list!=null){
for(int i=0;i<list.size();i++){
//System.out.println("size="+list.size());
//System.out.println("name of parameter:"+((JRParameter)list.get(i)).getName());
//System.out.println("Description of parameter:"+((JRParameter)list.get(i)).getDescription());
if(!arrParameters.contains(((JRParameter)list.get(i)).getName())){
VOParameter voparameter=new VOParameter();
voparameter.setName(((JRParameter)list.get(i)).getName());
if(((JRParameter)list.get(i)).getDefaultValueExpression()!=null){
System.out.println(((JRParameter)list.get(i)).getDefaultValueExpression());
System.out.println(((JRParameter)list.get(i)).getClass());
System.out.println(((JRParameter)list.get(i)).getValueClass());
System.out.println(((JRParameter)list.get(i)).getValueClassName());
voparameter.setDefaultValueExpression(((JRParameter)list.get(i)).getDefaultValueExpression().toString());
}
voparameter.setDescription(((JRParameter)list.get(i)).getDescription());
colnAdditonalParameters.add(voparameter);
b=true;
}

}
}

 

Thanks,

 

Shuaibing

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

In iReport when you add a parameter you can add a default value. Be careful if you're using earlier version of java that do not support auto boxing. If that's the case, just use java 1.4 syntax to express your initial values.
Link to comment
Share on other sites

Hi schaibaa,

 

Thanks for your reply!

 

I am really using jdk1.4 because I need to deploy my simple reporting framework(using jasperreports-1.3.1.jar) webapp on weblogic8.1, and my client wanted the software to automatically detect the default value of each parameter and pop a window for him to choose whether the default values or retyped values should be used when printing.

 

Would you tell me exactly how to use java 1.4 syntax to express initial values?

 

Thanks in advance!

 

Shuaibing

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

I was wondering, is there a class that can evaluate parameters besides their default values. I have a parameter that relies on another user supplied parameter. Is it possible to calculate that value? For example:

 

User Parameter: MONTH

Parameter MONTH + 1: $P{MONTH} + 1

Link to comment
Share on other sites

You can use JRParameterDefaultValuesEvaluator in this scenario as well. The evaluateParameterDefaultValues method takes as argument a map containing initial parameter values, so if you supply the user parameter value, the other parameter will use this value while evaluation its default value expression.

 

HTH,

Lucian

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...