Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents


In this tutorial, we will be following the guideline for developing a plugin to develop our JDBC Form Load Binder plugin. Please also refer to this tutorial, How to develop a Bean Shell Hash Variable and also a JDBC related plugin How to develop a JDBC Options Binder for more details steps.

Thai

ในบทช่วยสอนนี้เราจะทำตามแนวทางการพัฒนาปลั๊กอินเพื่อพัฒนาปลั๊กอิน JDBC Form Load Binder ของเรา โปรดอ้างอิงถึงบทช่วยสอนนี้, How to develop a Bean Shell Hash Variable และปลั๊กอินที่เกี่ยวข้องกับ JDBC How to develop a JDBC Options Binder สำหรับขั้นตอนรายละเอียดเพิ่มเติม

1. What is the problem?

Thai

อะไรคือปัญหา?

For integration purpose, we would like to load our form data from a different database table instead of Joget form data table.

Thai

เพื่อจุดประสงค์ในการรวมเราต้องการโหลดข้อมูลฟอร์มของเราจากตารางฐานข้อมูลอื่นแทนที่จะเป็นตารางข้อมูล Joget

2. How to solve the problem?

Thai

วิธีแก้ปัญหา

Joget Workflow has provided a plugin type called Form Load Binder Plugin. We will refer to the former to develop a plugin to support JDBC connection and custom query to load form data.

Thai

Joget Workflow จัดทำประเภทปลั๊กอินที่เรียกว่า Form Load Binder Plugin เราจะอ้างถึงอดีตเพื่อพัฒนาปลั๊กอินเพื่อรองรับการเชื่อมต่อ JDBC และแบบสอบถามที่กำหนดเองเพื่อโหลดข้อมูลในแบบฟอร์ม

3. What is the input needed for your plugin?

Thai

สิ่งที่จำเป็นในการป้อนข้อมูลสำหรับปลั๊กอินของคุณ?

To develop a JDBC Load binder, we will need the JDBC connection setting and also the custom query to populate the form data based on primary key or foreign key (for Grid).

Thai

ในการพัฒนา JDBC Load binder เราจะต้องมีการตั้งค่าการเชื่อมต่อ JDBC และแบบสอบถามแบบกำหนดเองเพื่อเติมข้อมูลแบบฟอร์มตามคีย์หลักหรือคีย์ต่างประเทศ (สำหรับกริด)

  1. Datasource: Using custom datasource or Joget default datasource

    Thai

    แหล่งข้อมูล: การใช้แหล่งข้อมูลที่กำหนดเองหรือแหล่งข้อมูลเริ่มต้นของ Joget

  2. Custom JDBC Driver: The JDBC driver for custom datasource

    Thai

    Custom JDBC Driver: ไดรเวอร์ JDBC สำหรับแหล่งข้อมูลที่กำหนดเอง

  3. Custom JDBC URL: The JDBC connection URL for custom datasource

    Thai

    Custom JDBC URL: URL การเชื่อมต่อ JDBC สำหรับแหล่งข้อมูลที่กำหนดเอง

  4. Custom JDBC Username: The username for custom datasource

    Thai

    ชื่อผู้ใช้ JDBC แบบกำหนดเอง: ชื่อผู้ใช้สำหรับแหล่งข้อมูลที่กำหนดเอง

  5. Custom JDBC Password: The password for custom datasource

    Thai

    Custom JDBC Password: รหัสผ่านสำหรับแหล่งข้อมูลที่กำหนดเอง

  6. SQL Query: The query to populate form data.  

    Thai

    SQL Query: แบบสอบถามเพื่อเติมข้อมูลแบบฟอร์ม

The query should also support a syntax to inject the primary key (For Form/Section) or foreign key (For Grid element)

Thai

แบบสอบถามควรสนับสนุนไวยากรณ์เพื่อฉีดคีย์หลัก (สำหรับฟอร์ม / ส่วน) หรือคีย์ต่างประเทศ (สำหรับองค์ประกอบกริด)

Example:

Thai

ตัวอย่าง:

  1. SELECT * from app_fd_sample where id = ?

4. What is the output and expected outcome of your plugin?

Thai

ผลลัพธ์และผลลัพธ์ที่คาดหวังของปลั๊กอินของคุณคืออะไร?

All retrieved columns are auto mapped to the fields with column name equal to field id. 

Thai

คอลัมน์ที่ดึงข้อมูลทั้งหมดจะถูกแมปอัตโนมัติกับฟิลด์ที่มีชื่อคอลัมน์เท่ากับฟิลด์ ID

5. Are there any resources/API that can be reused?

Thai

มีทรัพยากร / API ที่สามารถนำกลับมาใช้ใหม่ได้หรือไม่?

We can refer to the implementation of other available Form Load Binder plugins. Joget default datasource can be retrieve with AppUtil.getApplicationContext().getBean("setupDataSource").

Thai

เราสามารถอ้างถึง Form Load Binder plugins อื่น ๆ ที่มีอยู่ แหล่งข้อมูลเริ่มต้นของ Joget สามารถเรียกดูได้ด้วย AppUtil.getApplicationContext (). getBean ("setupDataSource")

6. Prepare your development environment

Thai

เตรียมสภาพแวดล้อมการพัฒนาของคุณ

We need to always have our Joget Workflow Source Code ready and builded by following this guideline

The following tutorial is prepared with a Macbook Pro and Joget Source Code version 5.0.0. Please refer to Guideline for developing a plugin for other platform command.

Let say our folder directory is as follows. 

Thai

เราจำเป็นต้องให้ซอร์สโค้ด Joget Workflow ของเราพร้อมและสร้างโดยปฏิบัติตาม this guideline

บทช่วยสอนต่อไปนี้จัดทำขึ้นด้วย Macbook Pro และ Joget Source Code เวอร์ชั่น 5.0.0 โปรดอ้างอิง Guideline for developing a plugin สำหรับคำสั่งแพลตฟอร์มอื่น ๆ

สมมติว่าไดเรกทอรีโฟลเดอร์ของเรามีดังนี้

Code Block
- Home
  - joget
    - plugins
    - jw-community
      -5.0.0

The "plugins" directory is the folder we will create and store all our plugins and the "jw-community" directory is where the Joget Workflow Source code stored.

Run the following command to create a maven project in "plugins" directory.

Thai

ไดเรกทอรี "ปลั๊กอิน" คือโฟลเดอร์ที่เราจะสร้างและจัดเก็บปลั๊กอินทั้งหมดของเราและไดเรกทอรี "jw-community" เป็นที่เก็บซอร์สโค้ด Joget Workflow เรียกใช้คำสั่งต่อไปนี้เพื่อสร้างโครงการ maven ในไดเรกทอรี "ปลั๊กอิน"

Code Block
languagebash
cd joget/plugins/
~/joget/jw-community/5.0.0/wflow-plugin-archetype/create-plugin.sh org.joget.tutorial jdbc_load_binder 5.0.0

Then, the shell script will ask us to key in a version for your plugin and ask us for confirmation before generate the maven project.

Thai

จากนั้นเชลล์สคริปต์จะขอให้เราป้อนเวอร์ชันสำหรับปลั๊กอินของคุณและขอให้เรายืนยันก่อนที่จะสร้างโครงการ Maven

Code Block
languagebash
Define value for property 'version':  1.0-SNAPSHOT: : 5.0.0
[INFO] Using property: package = org.joget.tutorial
Confirm properties configuration:
groupId: org.joget.tutorial
artifactId: jdbc_load_binder
version: 5.0.0
package: org.joget.tutorial
Y: : y

We should get "BUILD SUCCESS" message shown in our terminal and a "jdbc_load_binder" folder created in "plugins" folder.

Open the maven project with your favour IDE. I will be using NetBeans.  

Thai

เราควรได้รับข้อความ "BUILD SUCCESS" ที่แสดงในเครื่องของเราและโฟลเดอร์ "jdbc_load_binder" ที่สร้างในโฟลเดอร์ "ปลั๊กอิน" เปิดโครงการ maven ด้วย IDE ที่คุณโปรดปราน ฉันจะใช้ NetBeans


7. Just code it!

Thai

เพียงแค่รหัส!

a. Extending the abstract class of a plugin type

Thai

การขยายคลาสนามธรรมของประเภทปลั๊กอิน

Create a "JdbcLoadBinder" class under "org.joget.tutorial" package. Then, extend the class with org.joget.apps.form.model.FormBinder abstract class.

To make it work as a Form Load Binder, we will need to implement org.joget.apps.form.model.FormLoadBinder interface. Then, we need to implement org.joget.apps.form.model.FormLoadElementBinder interface to make this plugin show as a selection in load binder select box and implement org.joget.apps.form.model.FormLoadMultiRowElementBinder interface to list it under the load binder select box of grid element. 

 Please refer to Form Load Binder Plugin.

Thai

สร้างคลาส "JdbcLoadBinder" ภายใต้แพคเกจ "org.joget.tutorial" จากนั้นขยายคลาสด้วย org.joget.apps.form.model.FormBinder คลาสนามธรรม เพื่อให้มันทำงานเป็น Form Load Binder เราจะต้องใช้อินเตอร์เฟส org.joget.apps.form.model.FormLoadBinder จากนั้นเราจำเป็นต้องใช้อินเตอร์เฟส org.joget.apps.form.model.FormLoadElementBinder เพื่อให้ปลั๊กอินนี้แสดงเป็นตัวเลือกในกล่องเลือกโหลด binder และใช้อินเตอร์เฟส org.joget.apps.form.model.FormLoadMultiRowElementBinder โหลด binder เลือกกล่องขององค์ประกอบกริด โปรดดูที่ Form Load Binder Plugin

b. Implement all the abstract methods

Thai

ใช้วิธีนามธรรมทั้งหมด

As usual, we have to implement all the abstract methods. We will using AppPluginUtil.getMessage method to support i18n and using constant variable MESSAGE_PATH for message resource bundle directory.

Thai

ตามปกติเราต้องใช้วิธีนามธรรมทั้งหมด เราจะใช้วิธี AppPluginUtil.getMessage เพื่อสนับสนุน i18n และใช้ตัวแปร MESSAGE_PATH คงที่สำหรับไดเรกทอรี

Code Block
languagejava
titleImplementation of all basic abstract methods
collapsetrue
package org.joget.tutorial;
 
import org.joget.apps.app.service.AppPluginUtil;
import org.joget.apps.app.service.AppUtil;
import org.joget.apps.form.model.Element;
import org.joget.apps.form.model.FormBinder;
import org.joget.apps.form.model.FormData;
import org.joget.apps.form.model.FormLoadBinder;
import org.joget.apps.form.model.FormLoadElementBinder;
import org.joget.apps.form.model.FormLoadMultiRowElementBinder;
import org.joget.apps.form.model.FormRowSet;
 
public class JdbcLoadBinder extends FormBinder implements FormLoadBinder, FormLoadElementBinder, FormLoadMultiRowElementBinder {
    
    private final static String MESSAGE_PATH = "messages/JdbcLoadBinder";
    
    public String getName() {
        return "JDBC Load Binder";
    }
 
    public String getVersion() {
        return "5.0.0";
    }
    
    public String getClassName() {
        return getClass().getName();
    }
 
    public String getLabel() {
        //support i18n
        return AppPluginUtil.getMessage("org.joget.tutorial.JdbcLoadBinder.pluginLabel", getClassName(), MESSAGE_PATH);
    }
    
    public String getDescription() {
        //support i18n
        return AppPluginUtil.getMessage("org.joget.tutorial.JdbcLoadBinder.pluginDesc", getClassName(), MESSAGE_PATH);
    }
 
    public String getPropertyOptions() {
        return AppUtil.readPluginResource(getClassName(), "/properties/jdbcLoadBinder.json", null, true, MESSAGE_PATH);
    }
 
    public FormRowSet load(Element element, String primaryKey, FormData formData) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
}

Then, we have to do a UI for admin user to provide inputs for our plugin. In getPropertyOptions method, we already specify our Plugin Properties Options definition file is locate at "/properties/jdbcLoadBinder.json". Let us create a directory "resources/properties" under "jdbc_load_binder/src/main" directory. After create the directory, create a file named "jdbcLoadBinder.json" in the "properties" folder.

In the properties definition options file, we will need to provide options as below. Please note that we can use "@@message.key@@" syntax to support i18n in our properties options.

Thai

จากนั้นเราต้องทำ UI สำหรับผู้ใช้ผู้ดูแลระบบเพื่อให้อินพุตสำหรับปลั๊กอินของเรา ในเมธอด getPropertyOptions เราได้ระบุไฟล์ข้อกำหนด Plugin Properties Options ไว้ที่ "/properties/jdbcLoadBinder.json" แล้ว ให้เราสร้างไดเรกทอรี "resources / properties" ภายใต้ไดเร็กทอรี "jdbc_load_binder / src / main" หลังจากสร้างไดเร็กทอรีให้สร้างไฟล์ชื่อ "jdbcLoadBinder.json" ในโฟลเดอร์ "properties" ในไฟล์ตัวเลือกคำจำกัดความของคุณสมบัติเราจะต้องระบุตัวเลือกดังต่อไปนี้ โปรดทราบว่าเราสามารถใช้ไวยากรณ์ "@@ message.key @@" เพื่อรองรับ i18n ในตัวเลือกคุณสมบัติของเรา

Code Block
languagejs
[{
    title : '@@form.jdbcLoadBinder.config@@',
    properties : [{
        name : 'jdbcDatasource',
        label : '@@form.jdbcLoadBinder.datasource@@',
        type : 'selectbox',
        options : [{
            value : 'custom',
            label : '@@form.jdbcLoadBinder.customDatasource@@'
        },{
            value : 'default',
            label : '@@form.jdbcLoadBinder.defaultDatasource@@'
        }],
        value : 'default'
    },{
        name : 'jdbcDriver',
        label : '@@form.jdbcLoadBinder.driver@@',
        description : '@@form.jdbcLoadBinder.driver.desc@@',
        type : 'textfield',
        value : 'com.mysql.jdbc.Driver',
        control_field: 'jdbcDatasource',
        control_value: 'custom',
        control_use_regex: 'false',
        required : 'true'
    },{
        name : 'jdbcUrl',
        label : '@@form.jdbcLoadBinder.url@@',
        type : 'textfield',
        value : 'jdbc:mysql://localhost/jwdb?characterEncoding=UTF8',
        control_field: 'jdbcDatasource',
        control_value: 'custom',
        control_use_regex: 'false',
        required : 'true'
    },{
        name : 'jdbcUser',
        label : '@@form.jdbcLoadBinder.username@@',
        type : 'textfield',
        control_field: 'jdbcDatasource',
        control_value: 'custom',
        control_use_regex: 'false',
        value : 'root',
        required : 'true'
    },{
        name : 'jdbcPassword',
        label : '@@form.jdbcLoadBinder.password@@',
        type : 'password',
        control_field: 'jdbcDatasource',
        control_value: 'custom',
        control_use_regex: 'false',
        value : ''
    },{
        name : 'sql',
        label : '@@form.jdbcLoadBinder.sql@@',
        description : '@@form.jdbcLoadBinder.sql.desc@@',
        type : 'codeeditor',
        mode : 'sql',
        required : 'true'
    }],
    buttons : [{
        name : 'testConnection',    
        label : '@@form.jdbcLoadBinder.testConnection@@',
        ajax_url : '[CONTEXT_PATH]/web/json/app[APP_PATH]/plugin/org.joget.tutorial.JdbcLoadBinder/service?action=testConnection',
        fields : ['jdbcDriver', 'jdbcUrl', 'jdbcUser', 'jdbcPassword'],
        control_field: 'jdbcDatasource',
        control_value: 'custom',
        control_use_regex: 'false'
    }]
}]

Same as JDBC Options Binder, we will need to add a test connection button for custom JDBC setting. Please refer to How to develop a JDBC Options Binder on the Web Service Plugin implementation.

Once we done the properties option to collect input and the web service to test the connection, we can work on the main method of the plugin which is load method.

Thai

เช่นเดียวกับ JDBC Options Binder เราจะต้องเพิ่มปุ่มทดสอบการเชื่อมต่อสำหรับการตั้งค่า JDBC ที่กำหนดเอง โปรดอ้างอิงถึง How to develop a JDBC Options Binderในการนำ Web Service Plugin ไปใช้ เมื่อเราทำตัวเลือกคุณสมบัติเพื่อรวบรวมอินพุตและบริการเว็บเพื่อทดสอบการเชื่อมต่อเราสามารถทำงานกับวิธีหลักของปลั๊กอินซึ่งเป็นวิธีโหลด

Code Block
languagejava
    public FormRowSet load(Element element, String primaryKey, FormData formData) {
        FormRowSet rows = new FormRowSet();
        rows.setMultiRow(true);
        //Check the sql. If require primary key and primary key is null, return empty result.
        String sql = getPropertyString("sql");
        if ((primaryKey == null || primaryKey.isEmpty()) && sql.contains("?")) {
            return rows;
        }
        
        Connection con = null;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        
        try {
            DataSource ds = createDataSource();
            con = ds.getConnection();
            
            pstmt = con.prepareStatement(sql);
            
            //set query parameters
            if (sql.contains("?") && primaryKey != null && !primaryKey.isEmpty()) {
                pstmt.setObject(1, primaryKey);
            }
            
            rs = pstmt.executeQuery();
            ResultSetMetaData rsmd = rs.getMetaData();
            int columnsNumber = rsmd.getColumnCount();
            
            // Set retrieved result to Form Row Set
            while (rs.next()) {
                FormRow row = new FormRow();
                
                //get the name of each column as field id 
                for (int i = 1; i <= columnsNumber; i++) {
                    String name = rsmd.getColumnName(i);
                    String value = rs.getString(name);
                    
                    if (FormUtil.PROPERTY_ID.equals(name)) {
                        row.setId(value);
                    } else {
                        row.setProperty(name, (value != null)?value:"");
                    }
                }
                
                rows.add(row);
            }
        } catch (Exception e) {
            LogUtil.error(getClassName(), e, "");
        } finally {
            try {
                if (rs != null) {
                    rs.close();
                }
                if (pstmt != null) {
                    pstmt.close();
                }
                if (con != null) {
                    con.close();
                }
            } catch (Exception e) {
                LogUtil.error(getClassName(), e, "");
            }
        }
        
        return rows;
    }
    
    /**
     * To creates data source based on setting
     * @return
     * @throws Exception 
     */
    protected DataSource createDataSource() throws Exception {
        DataSource ds = null;
        String datasource = getPropertyString("jdbcDatasource");
        if ("default".equals(datasource)) {
            // use current datasource
             ds = (DataSource)AppUtil.getApplicationContext().getBean("setupDataSource");
        } else {
            // use custom datasource
            Properties dsProps = new Properties();
            dsProps.put("driverClassName", getPropertyString("jdbcDriver"));
            dsProps.put("url", getPropertyString("jdbcUrl"));
            dsProps.put("username", getPropertyString("jdbcUser"));
            dsProps.put("password", getPropertyString("jdbcPassword"));
            ds = BasicDataSourceFactory.createDataSource(dsProps);
        }
        return ds;
    }

c. Manage the dependency libraries of your plugin

Thai

จัดการไลบรารีการพึ่งพาของปลั๊กอินของคุณ

Our plugin is using dbcp, javax.servlet.http.HttpServletRequest and javax.servlet.http.HttpServletResponse class, so we will need to add jsp-api and commons-dbcp library to our POM file.

Thai

ปลั๊กอินของเราใช้ dbcp, javax.servlet.http.HttpServletRequest และ javax.servlet.http.HttpServletResponse คลาสดังนั้นเราจะต้องเพิ่มไลบรารี jsp-api และ commons-dbcp ลงในไฟล์ POM ของเรา

Code Block
languagexml
<!-- Change plugin specific dependencies here -->
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jsp-api</artifactId>
    <version>2.0</version>
</dependency>
<dependency>
    <groupId>commons-dbcp</groupId>
    <artifactId>commons-dbcp</artifactId>
    <version>1.3</version>
</dependency>
<!-- End change plugin specific dependencies here -->

d. Make your plugin internationalization (i18n) ready

Thai

เตรียมปลั๊กอินสากลให้พร้อม (i18n)

We are using i18n message key in getLabel and getDescription method. We also used i18n message key in our properties options definition as well. So, we will need to create a message resource bundle properties file for our plugin.

Create directory "resources/messages" under "jdbc_load_binder/src/main" directory. Then, create a "JdbcLoadBinder.properties" file in the folder. In the properties file, let add all the message keys and its label as below.

Thai

เรากำลังใช้คีย์ข้อความ i18n ในวิธี getLabel และ getDescription นอกจากนี้เรายังใช้คีย์ข้อความ i18n ในการกำหนดตัวเลือกคุณสมบัติของเราเช่นกัน ดังนั้นเราจะต้องสร้างไฟล์คุณสมบัติมัดทรัพยากรสำหรับปลั๊กอินของเรา สร้างไดเรกทอรี "ทรัพยากร / ข้อความ" ภายใต้ไดเรกทอรี "jdbc_load_binder / src / main" จากนั้นสร้างไฟล์ "JdbcLoadBinder.properties" ในโฟลเดอร์ ในไฟล์คุณสมบัติให้เพิ่มคีย์ข้อความทั้งหมดและป้ายกำกับของมันดังต่อไปนี้

Code Block
org.joget.tutorial.JdbcLoadBinder.pluginLabel=JDBC Binder
org.joget.tutorial.JdbcLoadBinder.pluginDesc=Used to load form data using JDBC
form.jdbcLoadBinder.config=Configure JDBC Binder
form.jdbcLoadBinder.datasource=Datasource
form.jdbcLoadBinder.customDatasource=Custom Datasource
form.jdbcLoadBinder.defaultDatasource=Default Datasource
form.jdbcLoadBinder.driver=Custom JDBC Driver
form.jdbcLoadBinder.driver.desc=Eg. com.mysql.jdbc.Driver (MySQL), oracle.jdbc.driver.OracleDriver (Oracle), com.microsoft.sqlserver.jdbc.SQLServerDriver (Microsoft SQL Server)
form.jdbcLoadBinder.url=Custom JDBC URL
form.jdbcLoadBinder.username=Custom JDBC Username
form.jdbcLoadBinder.password=Custom JDBC Password
form.jdbcLoadBinder.sql=SQL SELECT Query
form.jdbcLoadBinder.sql.desc=Use question mark (?) in your query to represent primary key or foreign key
form.jdbcLoadBinder.testConnection=Test Connection
form.jdbcLoadBinder.connectionOk=Database connected
form.jdbcLoadBinder.connectionFail=Not able to establish connection.

e. Register your plugin to Felix Framework

Thai

ลงทะเบียนปลั๊กอินของคุณไปที่ Felix Framework

We will have to register our plugin class in Activator class (Auto generated in the same class package) to tell Felix Framework that this is a plugin.

Thai

เราจะต้องลงทะเบียนคลาสปลั๊กอินของเราในคลาส Activator (สร้างอัตโนมัติในแพ็คเกจคลาสเดียวกัน) เพื่อบอก Felix Framework ว่านี่คือปลั๊กอิน

Code Block
languagejava
    public void start(BundleContext context) {
        registrationList = new ArrayList<ServiceRegistration>();
        //Register plugin here
        registrationList.add(context.registerService(JdbcLoadBinder.class.getName(), new JdbcLoadBinder(), null));
    } 

f. Build it and testing

Thai

สร้างและทดสอบ

Let build our plugin. Once the building process is done, we will found a "jdbc_load_binder-5.0.0.jar" file is created under "jdbc_load_binder/target" directory.

Then, let upload the plugin jar to Manage Plugins. After upload the jar file, double check the plugin is uploaded and activated correctly.

Thai

ให้สร้างปลั๊กอินของเรา เมื่อกระบวนการสร้างเสร็จสิ้นเราจะพบไฟล์ "jdbc_load_binder-5.0.0.jar" ภายใต้ไดเรกทอรี "jdbc_load_binder / target"

จากนั้นให้อัปโหลด jar ปลั๊กอินไปที่ Manage Plugins หลังจากอัปโหลดไฟล์ jar ตรวจสอบอีกครั้งว่าปลั๊กอินถูกอัปโหลดและเปิดใช้งานอย่างถูกต้อง


Let create a form to load firstName, lastName and email from dir_user table based on username to test the load binder.

Thai

ให้สร้างแบบฟอร์มเพื่อโหลดชื่อ, นามสกุลและอีเมลจากตาราง dir_user ตามชื่อผู้ใช้เพื่อทดสอบเครื่องผูกการโหลด


Then, configure the load binder of the form to use JDBC Binder with the following query.

Thai

จากนั้นกำหนดค่าตัวโยงโหลดของฟอร์มเพื่อใช้ JDBC Binder กับแบบสอบถามต่อไปนี้

Code Block
languagesql
 select * from dir_user where username = ?

Let create an userview and drag a Form Menu element to display our form. Then, publish it and test our form with an "id" parameter.

Thai

ให้สร้าง userview และลากองค์ประกอบเมนูแบบฟอร์มเพื่อแสดงแบบฟอร์มของเรา จากนั้นเผยแพร่และทดสอบแบบฟอร์มของเราด้วยพารามิเตอร์ "id"


Next, let add a grid element and test with the following query.

Thai

จากนั้นให้เพิ่มองค์ประกอบตารางและทดสอบด้วยแบบสอบถามต่อไปนี้

Code Block
languagesql
select * from dir_group g 
join dir_user_group ug on ug.groupId = g.id
where ug.userId = ?


Let check our result again.

Thai

ลองตรวจสอบผลลัพธ์ของเราอีกครั้ง


It works! Please remember test the other features of the plugin as well. (big grin)

Thai

มันได้ผล! โปรดอย่าลืมทดสอบคุณสมบัติอื่น ๆ ของปลั๊กอินด้วย

8. Take a step further, share it or sell it

Thai

ก้าวไปอีกขั้นแบ่งปันหรือขายมัน

You can download the source code from jdbc_load_binder_src.zip.

To download the ready-to-use plugin jar, please find it in http://marketplace.joget.org/.

Thai

คุณสามารถดาวน์โหลดซอร์สโค้ดจาก jdbc_load_binder_src.zip

หากต้องการดาวน์โหลด jar ปลั๊กอินที่พร้อมใช้งานโปรดค้นหาได้ที่ http://marketplace.joget.org/