1.Overview
In practical applications, it may be necessary to dynamically change the data source according to the table name. For example, in the class dataset, the parameter table name is passed and used to retrieve the corresponding data table as the data source from the database. The parameter variable parameters used by the class dataset is a field that AbstractTableData inherits from its parent class AbstractParameterTableData.
2.Example
2.1 Define Class Data Source
Define a class which inherits AbstractTableData and gets the methods implemented. Check out the following link to get more details:
2.2 Compile the Class
Compile ParamTableDataDemo.java and copy the corresponding class file under the path %FR_HOME%\webapps\webroot\WEB-INF\classes\com\fr\data.
At this point, class data source has already been defined.
2.3 Configure Class Dataset
1) Create a report, create a class in the dataset panel and select the class file we have defined, as shown in the figure below:
2) Add default parameters, the first parameter in the class is the table name, and the rest of the parameter names can be arbitrary. As shown below:
2.4 Preview Class Dataset
1) Choose the class dataset just created and click on the preview button, type in the parameter values,as shown below:
2) Query results is shown below:
3. Remarks
3.1 Parameter Name Conflicts of Class Datasets in FRM
1) Problem description
Multiple class datasets are created in the decision report. The parameter names of each dataset are the same while the parameter values are different. The data displayed in the preview is the same.
2) Reason
If the parameter names of multiple class datasets are the same in the decision report, conflicts will occur.
3) Resolution
The parameter names of the class datasets in the decision report cannot be the same. If the same names exist, they need to be modified to be different ones.