Modify Data Dynamically

  • Last update:  2020-12-17
  • I. Overview

    Developers may have a demand for displaying data in a single web report that is connected to multiple databases with the same table structure. How can this be achieved?

    II. Principle

    Define a class web report extending from an abstract class "com.fr.web.reportlet" and implement the createReport(ReportletRequest arg0) method to return a report object.

    Then, set up a new dataset for the returned report object, and add it into the report to modify the template data by putTableData(DSName,tableData) method. In this method, "DSName" refers to the name of the defined dataset (for example, "ds1") and "tableData" is the dataset used.


    III. Instructions

    1. Define a Class Dataset

    The class dataset can be used to acquire values from different databases, or to insert query results from Java into the class dataset and display them in the report. For more details on how to use class dataset, please refer to class data source.


    2. Create a New Template

    Create a new template "1.cpt", and define a dataset "ds2". Drag and drop the fields in ds2 into the report. Save to the root directory. Please see the configuration below for reference.

    3.jpg

    Column names of the defined class dataset should be matched with the format of the data table connected via "ds2". In this case, the names ought to be "Name" and "Score", so that granting values to the dataset can bring out corresponding results in the report.


    3. Define a Class Web Report

    Please see here for detailed codes: https://github.com/finereport-overseas/example/blob/release/10.0/src/main/java/com/fr/demo/NewDateDemo.java

    Here we need to call the ArrayTableDataDemo class located in %FR_HOME%\webapps\webroot\WEB-INF\classes\com\fr\data.

     

    4. Compile and Generate a Class File

    The Java IDE will carry out the compilation automatically.

    Place the compiled NewDateDemo.class into the root directory of the web report. Since the class is in com.fr.demo, you can put it into %FR_HOME%\webapps\webroot\WEB-INF\classes\com\fr\demo.

     

    5. Publish and Preview

    Save the file. Startup the report server and go to the following URL to preview the result: http://localhost:8075/webroot/decision/view/report?viewlet=com.fr.demo.NewDateDemo.

    4.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