Read Template From Database

  • Last update:  2020-12-17
  • 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.

    11.png

    III. Read an FRM Report

    1. Create a New Class

    Create a new class ReadFromDatabase. You can check the complete code example here:

    https://github.com/finereport-overseas/example/blob/release/10.0/src/main/java/com/fr/demo/ReadfrmFromDatabase.java


    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.

    22.png


    Attachment List


    Theme: Secondary Development
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy