Importing parameter values

When you view a report with parameters, the Enter Parameter Values dialog will be displayed, showing the parameters the report uses for you to input values. The default values shown in the dialog are fixed at the development time. However, showing a default, fixed value which is dated makes no sense to users.

JReport provides an interface for importing different default values from an outside class file so that the default values can be specified flexibly. There is only one method for this interface:public Hashtable promptValues(String paramsName[]);

Reference: JReport Javadoc jet.util.ImportParamValues interface in <install_root>\help\api.

The following are the general steps for importing parameter values from a class file:

  1. Define a Java class file. For help, see our sample programs ParamTest.java and TestParamList.java in <install_root>\help\samples\APIParameter. To import parameter values, implement the interface jet.util.ImportParamValues in your Java file. The class definition may be as follows:
    package help.;
    import java.util.*;
    import jet.util.*;
    public class ParamTest implements ImportParamValues
    {
        public ParamTest()
        {
            //Class body
        }
        public Hashtable promptValues(String paramsName[])
        {
            //Class body
        }
    }
    

    The following explains the code:

  2. Compile the Java file to generate the class file.
  3. Append the class path to the ADDCLASSPATH variable of the file setenv.bat in <install_root>\bin.
  4. Start JReport Designer with the modified batch file.
  5. Open the report with the parameter value that you want to import.
  6. In the Report Inspector, set the property Import Parameter Values of the report to be the class name that you just generated with the package name, and set Parameter List Auto to false.

Notes:

The following two examples explain how to import parameter values and what you should be aware of while using this feature: