Versions Compared

Key

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

...

In this tutorial, we will following the guideline of developing a plugin to develop our Multi Store Binder plugin. Please also refer to the very first tutorial How to develop a Bean Shell Hash Variable and also the following store binder related plugin for more details detailed steps.

...

We would like to run multiple store binders plugins in a single store binder selection. This would open up more use cases with the ability to store form data into multiple destinations without the need for relying on other approaches such as JSON Tool or SOAP Tool.

2. What is your idea to solve the problem?

Joget Workflow has provided a plugin type called Form Store Binder Plugin. We will develop one based on this plugin category to support multiple selections and execution of store binders to store form data.

...

All submitted data will store accordingly based on the multiple selections configuration of each of the store binders selected.

5. Is there any resources/API that can be reuse?

...

The following of this tutorial is prepared with Joget Source Code version 7.0.0. Please refer to Guideline for developing a plugin for other platform commands.

Let said our folder directory as following's use the following folder structure


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

...

Code Block
languagebash
cd joget/plugins/
~/joget/jw-community/57.0.0/wflow-plugin-archetype/create-plugin.sh org.joget.tutorialmarketplace multi_store_binder 57.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.

...

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

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

Open the maven project with your favor favorite IDE. I We will be using NetBeans.  

7. Just code it!

a. Extending the abstract class of a plugin type

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

...

Code Block
languagejava
titleImplementation of all basic abstract methods
linenumberstrue
collapsetrue
package org.joget.tutorialmarketplace;
 
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.FormRowSet;
import org.joget.apps.form.model.FormStoreBinder;
import org.joget.apps.form.model.FormStoreElementBinder;
import org.joget.apps.form.model.FormStoreMultiRowElementBinder;
 
public class MultiStoreBinder extends FormBinder implements FormStoreBinder, FormStoreElementBinder, FormStoreMultiRowElementBinder {
    
    private final static String MESSAGE_PATH = "messages/multiStoreBinder";
    
    public String getName() {
        return "Multi Store Binder";
    }
 
    public String getVersion() {
        return "7.0.0";
    }
    
    public String getClassName() {
        return getClass().getName();
    }
 
    public String getLabel() {
        //support i18n
        return AppPluginUtil.getMessage("org.joget.tutorialmarketplace.MultiStoreBinder.pluginLabel", getClassName(), MESSAGE_PATH);
    }
    
    public String getDescription() {
        //support i18n
        return AppPluginUtil.getMessage("org.joget.tutorialmarketplace.MultiStoreBinder.pluginDesc", getClassName(), MESSAGE_PATH);
    }
 
    public String getPropertyOptions() {
        return AppUtil.readPluginResource(getClassName(), "/properties/multiStoreBinder.json", null, true, MESSAGE_PATH);
    }
 
    public FormRowSet store(Element element, FormRowSet rows, FormData formData) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
}

...

Code Block
languagejs
linenumberstrue
[
    {
        "title" : "@@plugin.multistorebinder@@org.joget.marketplace.MultiStoreBinder.config@@",
        "properties" : [
            {
                "name" : "binders",
                "label" : "@@plugin.multistorebinder@@org.joget.marketplace.MultiStoreBinder.storeBinder@@",
                "type" : "elementmultiselect",
                "options_ajax" : "[CONTEXT_PATH]/web/property/json/getElements?classname=org.joget.apps.form.model.FormStoreBinder&exclude=org.joget.sample.MultiStoreBinder",
                "url" : "[CONTEXT_PATH]/web/property/json[APP_PATH]/getPropertyOptions",
                "default_property_values_url" : "[CONTEXT_PATH]/web/property/json[APP_PATH]/getDefaultProperties",
                "required" : "true"
            },{
                "name" : "comment",
                "label" : "@@plugin.multistorebinder@@org.joget.marketplace.MultiStoreBinder.comment@@",
                "type" : "codeeditor"
            }
        ]
    }
]

Same as Similar to the Multi Tool plugin, we will need a multi selector to list the available store binders excluding the multi store binder. Refer to Plugin Properties Options#MultiselectinGridInterface(New)

...

Code Block
linenumberstrue
org.joget.marketplace.MultiStoreBinder.pluginLabel=Multi Store Binder
org.joget.marketplace.MultiStoreBinder.pluginDesc=Enable the use of multiple store binders
plugin.multistorebinderorg.joget.marketplace.MultiStoreBinder.config=Configure Multi Store Binder
plugin.multistorebinderorg.joget.marketplace.MultiStoreBinder.storeBinder=Store Binder
plugin.multistorebinderorg.joget.marketplace.MultiStoreBinder.comment=Comment

e. Register your plugin to Felix Framework

...