Importing parameter values

When you are viewing a report set with parameter(s), the Enter Parameter Values dialog will be displayed, showing the parameters the report set uses for you to input a value. The default value(s) shown in the dialog were fixed at the development time. However, showing a default, fixed value which was 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\designer\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\designer\samples. 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()
    {
    ;
    }
    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 classpath variable of the file JReport.bat in <install_root>\bin.
  4. Start JReport Designer with the modified batch file.
  5. Open the report set with the parameter value that you want to import.
  6. In the Report Inspector, set the property Import Parameter Values of the report set 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: