Versions Compared

Key

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

...

a. Extending the abstract class of a plugin type

Create a "MultiStoreBinderMultiStoreBinders" class under "org.joget.marketplace" 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.marketplace;
 
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 MultiStoreBinderMultiStoreBinders extends FormBinder implements FormStoreBinder, FormStoreElementBinder, FormStoreMultiRowElementBinder {
    
    private final static String MESSAGE_PATH = "messages/multiStoreBindermultiStoreBinders";
    
    public String getName() {
        return "multi store binders";
    }
 
    public String getVersion() {
        return "7.0.0";
    }
    
    public String getClassName() {
        return getClass().getName();
    }
 
    public String getLabel() {
        //support i18n
        return AppPluginUtil.getMessage("org.joget.marketplace.MultiStoreBinderMultiStoreBinders.pluginLabel", getClassName(), MESSAGE_PATH);
    }
    
    public String getDescription() {
        //support i18n
        return AppPluginUtil.getMessage("org.joget.marketplace.MultiStoreBinderMultiStoreBinders.pluginDesc", getClassName(), MESSAGE_PATH);
    }
 
    public String getPropertyOptions() {
        return AppUtil.readPluginResource(getClassName(), "/properties/multiStoreBindermultiStoreBinders.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.
    }
}

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 located at "/properties/multiStoreBindermultiStoreBinders.json". Let us create a directory "resources/properties" under "multi_store_binder/src/main" directory. After creating the directory, create a file named "multiStoreBindermultiStoreBinders.json" in the "properties" folder.

...

Code Block
languagejs
linenumberstrue
[
    {
        "title" : "@@org.joget.marketplace.MultiStoreBinderMultiStoreBinders.config@@",
        "properties" : [
            {
                "name" : "binders",
                "label" : "@@org.joget.marketplace.MultiStoreBinderMultiStoreBinders.storeBinder@@",
                "type" : "elementmultiselect",
                "options_ajax" : "[CONTEXT_PATH]/web/property/json/getElements?classname=org.joget.apps.form.model.FormStoreBinder&exclude=org.joget.sample.MultiStoreBinderMultiStoreBinders",
                "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" : "@@org.joget.marketplace.MultiStoreBinderMultiStoreBinders.comment@@",
                "type" : "codeeditor"
            }
        ]
    }
]

...

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

...

Code Block
linenumberstrue
org.joget.marketplace.MultiStoreBinderMultiStoreBinders.pluginLabel=multi store binders
org.joget.marketplace.MultiStoreBinderMultiStoreBinders.pluginDesc=Enable the use of multiple store binders
org.joget.marketplace.MultiStoreBinderMultiStoreBinders.config=Configure multi store binders
org.joget.marketplace.MultiStoreBinderMultiStoreBinders.storeBinder=Store Binders
org.joget.marketplace.MultiStoreBinderMultiStoreBinders.comment=Comment

e. Register your plugin to Felix Framework

...

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

f. Build it and testing

...