Jump to content
Changes to the Jaspersoft community edition download ×

Access Parameters Default Value.

2005 IR Help

Recommended Posts

By: Mathieu Rousseau - nono31

Access Parameters Default Value.

2004-04-12 12:32



I've got a personalized DataSource to access my remote DataBase. A Personalized Query Handler. But for some reason, I need to access the default value of some parameters of my report.


I agree that I can get the defaultValueExpression... That give me (in my case) new Integer(200) (when I get the text). I can get the class and stuff... But I would want to get directly the value intialized at compile time (jasper compilation time) instead of beeing obliged of doing some trick (redeclare an object depending of the class, and getting the value by char

offset... or getting the value filling the description tag)....








By: David Lim - aberrant80

RE: Access Parameters Default Value.

2004-04-12 21:46

I don't really understand you. Are you just trying to say you want to set default values for your parameters? But parameters are only set once the report filling begins.... so no, you can't set them at jasper compile time. So you still have to wait until your data filling part to pass in values to your parameters.





By: Mathieu Rousseau - nono31

RE: Access Parameters Default Value.

2004-04-13 06:13

I was sure I did not make myself clear!!! ;-))))


I compile the report. When it compile, does it instanciate the default value?

<parameter name="AgeMax" class="java.lang.Integer">


<defaultValueExpression>new Integer(200)</defaultValueExpression>



This is one parameter with a default value as an Interger.


So my question is simple: can we access this value (as an Integer) just after the compilation?


Because in fact I would like to put it in a Hashtable...

Unfortunately, I need to use the Description field until now:


JRParameter[] ReportParameters = jReport.getParameters();

LocalData = new Hashtable(ReportParameters.length-4);

for(int i = 4 ; i < ReportParameters.length ; i++){

Class fieldClass = ReportParameters.getValueClass();

String fieldName = ReportParameters.getName();

if(stringValue.length() == 0) {

stringValue = ReportParameters.getDescription();


Object value;


value = new Integer(stringValue);

}else if(fieldClass.equals(Boolean.class)){

value = new Boolean(stringValue);

}else if(fieldClass.equals(String.class)){

value = new String(stringValue);

}else {

value = new String(stringValue);


LocalData.put(fieldName, value);




This is quite not Elegant...


Because I need these default values before filling.




Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...