Jump to content
Changes to the Jaspersoft community edition download ×

How to retreive the value of an entered parameter in JRDataSource implementation?


ward.vantichelen

Recommended Posts

I have created a MyCustomDataSource that implements the JRDataSource interface. This data source will call a webservice to retreive the data. The end user must be able to enter some parameters. In the report designer in JasperSoft Studio I've created the parameter with a name MYPARAMETER1 and MYPARAMETER2 as an example.

These parameters must be passed to the webservice call.

Do do this I've implemented a myCustomDataSourceProvider that implements the JRDataSourceProvider interface. With this I can pass the JasperReport to the MyCustomerDataSource.

@Override
public JRDataSource create(JasperReport arg0) throws JRException 
{
   return new MyCustomDataSource(arg0);
}
 
Inside the constructor of MyCustomDataSource I try to read out the values of the entered parameters, but I am unable to do that.
 
public MyCustomDataSource(JasperReport jrreport){
  String myParameter1Value = "";
   //Retrieving the array of parameters:
   JRParameter[] params = jrreport.getParameters();
   for(JRParameter param : params) {
       if(param.getName().equals("MYPARAMETER1"))  {
          //here I can retreive a lot of information of the parameter, but not the actual entered value:
          String description = param.getDescription();//works fine
          String defaultValue = param.getDefaultValueExpression();//works fine (and I can use this for hidden parameters) 
          //the following statement does not work (does not even compile), but I actually need something like this
          //myParameter1Value = param.getValue();          
       }
   }
 
So my question is: how can I retreive the value of an entered parameter in my customer data source? 
This seems to be a very straightforward functionality and I've seen several similar posts like this, but none of them were answered.
Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

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