Setting dynamic parameter values when running/scheduling report set via API

When running or scheduling a report set with parameters via API, you can specify dynamic parameter values by implementing the ParameterGenerator interface. See JReport Enterprise Server Javadoc in <install_root>\help\server\en\api for detailed usage of the API.

To set dynamic parameter values to a report set:

  1. Create a class MyParameterGeneratorImpl to implement the ParameterGenerator interface. See the API demo DemoParameterGenerator.java in <install_root>\help\server\en\samples for an example of implementing the ParameterGenerator interface.
  2. Add the class path into the class path of your implementation of running or scheduling the report set such as DemoParameterRunReport.
  3. In DemoParameterRunReport, replace the way of setting static parameter values and instead set dynamic values of the required parameters in the report set. Take the parameter PToday for example:

    First disable or delete the line:

    props.put(APIConst.TAG_PARAM_PREFIX + "PToday", "2007-5-21");

    and then add a line as follows:

    props.put(APIConst.TAG_PARAM_PREFIX + "PToday", APIConst.TAG_PARAM_GEN_PREFIX + "MyParameterGeneratorImpl";