I. Overview
Since Save Template to Database has described how to save CPT templates into databases, developers can access a report with its name when needed, convert the CPT template into the web report, and preview in a web browser without saving it locally. For example, type in the following URL into the browser:
http://localhost:8075/webroot/decision/view/report?viewlet=com.fr.demo.ReadFromDatabase&reportname=GettingStarted.cpt, press Enter and the template saved into the database will be displayed.
Modify the value of parameter "reportname" to see other reports in the database.
Note: the method doesn't apply to accessing FRM dashboards, which is a bit different from CPT files. The specific instructions will be given respectively hereinbelow.
II. Read a CPT Report
1. Create a New Class
Create a new class ReadFromDatabase extending from com.fr.web.Reportlet (an abstract class), and implement the public Report createReport (ReportletRequest reportletRequest) method. Please refer to ReadFromDatabase.java for detailed code.
2. Compile and Generate a Class File
The Java IDE will carry out the compilation automatically.
Place the compiled ReadFromDatabase.class into %FR_HOME%/webapps/webroot/WEB-INF/classes/com/fr/demo/
3. Publish and Access
Compile the source file, start the report server, and go to http://localhost:8075/webroot/decision/view/report?viewlet=com.fr.demo.ReadFromDatabase&reportname=GettingStarted.cpt to see the results as shown below.
III. Read an FRM Report
1. Create a New Class
Create a new class ReadFromDatabase. You can check the complete code example here:
2. Compile and Generate a Class File
Place the compiled ReadfrmFromDatabase.class into %FR_HOME%/webapps/webroot/WEB-INF/classes/com/fr/demo/
3. Publish and Access
Start the report server and go to http://localhost:8075/webroot/decision/view/form?viewlet=com.fr.demo.ReadfrmFromDatabase&reportname=Sales Analysis.frm to see the results as shown below.