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 Options Binder plugin. Please also refer to the very first tutorial How to develop a Bean Shell Hash Variable for more details steps.

Thai


1. What is the problem?

Thai


Sometime, we may need to write some custom query to populate the options for our multi options field.

Thai


2. How to solve the problem?

Thai


Joget Workflow has provided a plugin type called Form Options Binder Plugin. We will develop one to support JDBC connection and custom query.

Thai


3. What is the input needed for your plugin?

Thai


To develop a JDBC Options binder, we will need the JDBC connection setting and also the custom query to populate the options.

Thai


  1. Datasource: Using custom datasource or Joget default datasource

    Thai


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

    Thai


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

    Thai


  4. Custom JDBC Username: The username for custom datasource

    Thai


  5. Custom JDBC Password: The password for custom datasource

    Thai


  6. SQL Query: The query to populate options. 

    Thai


  7. Use Ajax: A checkbox to decide whether or not it is using AJAX to load options. (For AJAX Cascading Drop-Down List)

    Thai


The query should also support a syntax to inject dependency values when using AJAX.

Thai


Example:

Thai


  1. SELECT id, name from app_fd_sample where group = ?

    Thai


  2. SELECT id, name from app_fd_sample where group in (?)

    Thai


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

Thai


The first column of returned JDBC result will be the value of the option and second column is the label of the option. There will be another optional third column for grouping when not using AJAX for cascading drop-down list.

Thai


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

Thai


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

Thai


6. Prepare your development environment

Thai


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

...

Let's say our folder directory is as follows. 

Thai


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

...

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