Usages

Abstract Class

org.joget.apps.app.model.CustomBuilderAbstract

Method Detail

Abstract Methods
getIcon
public String getIcon();

The unique font awesome icon of the builder. Eg. "fas fa-key".

getColor
public String getColor();

The unique color code of the builder. Eg. "#85ea2d".

getObjectName
public String getObjectName();

The unique shortname of the output definition of the builder. Eg. "api", "report", etc.

getObjectLabel
public String getObjectLabel();

The unique label of the output definition of the builder. Eg. "API", "Report", etc.

getIdPrefix
public String getIdPrefix();

The prefix for created output definition ID.  Eg. "API-", "rp-", etc.

getResourceBundlePath
public String getResourceBundlePath();

The resource bundle file path. The resource bundle message key can be retrieved in the builder javascript using 'get_cbuilder_msg(String key)'.  

getBuilderConfig
public String getBuilderConfig();

The builder configuration in JSON format. Used to configure the builder callback event and the advanced tools available for the builder. Full available configuration as below. Please refer to Sample Plugins on how to use this config.

{
    builder : {
        callbacks : { //methods name to call
            initBuilder : "", //call after initialized the builder. 
            load : "", //Call to load the definition JSON
            saveEditProperties : "", //Call after save edit properties event is trigger 
            cancelEditProperties : "" //Call after cancel edit properties event is trigger
        }
    },
    advanced_tools : { //configure the advanced tools available 
        tree_viewer : { //tree viewer to view the tree structure of the definition
            disabled : false, //to disable this tool
            childs_properties : ["elements"], //the property name which hold editable plugins
            matchers : { //matchers to customize the tree viewer
                'sample' : { //sample matcher
                    match : function (viewer, deferreds, node, jsonObj, refObj) {
                        //do something

                        return false;
                    }
                }
            }
        },
        usage : { //to check usage of the definition of this builder
            disabled : false  //to disable this tool
        },
        i18n : { //to provide i18n editor for this builder
            disabled : false, //to disable this tool
            keywords : [ //The property names which allowed for i18n 
                "label"
            ]
        },
        permission : { //to provide permission editor for this builder
            disabled : false, //to disable this tool
            permission_plugin : "org.joget.apps.form.model.FormPermission", //the permission plugin class used for this builder
            authorized : { //configure the authorized section
                property : "", //the property name to store the authorized section value
                default_value : "", //the default value for authorized property
                options : [ //the sample option for authorized section
                    {
                        key : "vissible",
                        value : "",
                        label : get_cbuilder_msg("ubuilder.visible")
                    },
                    {
                        key : "hidden",
                        value : "true",
                        label : get_cbuilder_msg("ubuilder.hidden")
                    }
                ]
            },
            unauthorized : { //configure the unauthorized section
                property : "", //the property name to store the unauthorized section value
                default_value : "", //the default value for unauthorized property
                options : [ //the sample option for unauthorized section
                    {
                        key : "vissible",
                        value : "",
                        label : get_cbuilder_msg("ubuilder.visible")
                    },
                    {
                        key : "hidden",
                        value : "true",
                        label : get_cbuilder_msg("ubuilder.hidden")
                    }
                ]
            },
            element_label_callback : "", //Method name to call for customize the element label
            element_support_plugin : [], //Plugin class name which support permission plugin configuration
            display_element_id : false, //to enable/disable to display the element id beside the element label
            childs_properties : ["elements"], //The property name to loop the child elements(plugins)
            ignore_classes : [], //The plugin class name to skip in the loop of child elements(plugins)
            render_elements_callback : "" //The method name to call to customize the rendering of child elements(plugins)
        },
        customTabsCallback : "" //Method name to call to render additional tabs in Advanced Tools. 
    }
}


getBuilderJS
public String getBuilderJS(String contextPath, String buildNumber);

The JS files used in the builder. Please refer to Sample Plugins on how to implement this method.

Parameters:

contextPath - the http request context path.

buildNumber - Joget platform build number

getBuilderCSS
public String getBuilderCSS(String contextPath, String buildNumber);

The CSS files used in the builder. Please refer to Sample Plugins on how to implement this method.

getBuilderHTML
public String getBuilderHTML(BuilderDefinition def, String json, HttpServletRequest request, HttpServletResponse response);

The HTML of builder. Please refer to Sample Plugins on how to implement this method.

Parameters:

def - the definition object to edit/load

json - the JSON definition to edit/load

getBuilderResult
public Object getBuilderResult(String json, Map<String, Object> config);

Retrieve the builder end result based on json definition. The end result can be a report PDF/HTML, an API document etc. Please refer to Sample Plugins on how to implement this method.

Parameters:

json - the JSON definition to generate the builder result.

config - the additional configuration/parameters use for generate the result.

Overridable Methods
createNewJSON
public String createNewJSON(String id, String name, String description, BuilderDefinition copyDef);

Used to create the JSON definition of new object

getNameFromJSON
public String getNameFromJSON(String json);

Retrieve name from the JSON definition

getDescriptionFromJSON
public String getDescriptionFromJSON(String json);

Retrieve description from the JSON definition

getCreateNewPageHtml
public String getCreateNewPageHtml();

HTML to add to the create new page

Plugin Properties Options

Custom Builder Javascript Object

Utility methods and fields to use in the builder javascript. 
Fields
appId 

The app id of current editing

appVersion 

The app version of current editing

builderType 

The builder object name return by the custom builder plugin

builderLabel 

The builder object label return by the custom builder plugin

json 

The JSON definition of current canvas

data 

The dataobject of current canvas

paletteElements 

The list of palette elements and its properties option and data.

Methods
CustomBuilder.callback(name, args)

To call a method by name

Parameters

CustomBuilder.initConfig(config)

To initialize the builder configuration by the platform

Parameters

CustomBuilder.initPropertiesOptions(options)

To initialize the builder properties tab  by the platform

Parameters

CustomBuilder.initBuilder(callback)

To initialize the builder by the platform

Parameters

CustomBuilder.showPopUpBuilderProperties()

To show the builder properties in a popup editor.

CustomBuilder.saveBuilderProperties(container, properties)

To save the builder properties

Parameters

CustomBuilder.initPaletteElement(category, className, label, icon, propertyOptions, defaultPropertiesValues, render, css, metaData)

To populate elements(plugins) in the side palette.

Parameters

CustomBuilder.loadJson(json)

To load a json to the builder

Parameters

CustomBuilder.update(addToUndo)

Update the CustomBuilder.json based on the data stored in CustomBuilder.data

Parameters

CustomBuilder.updateJson(json, addToUndo)

Update CustomBuilder.json to the pass in JSON.

Parameters

CustomBuilder.getJson()

Get the value in CustomBuilder.json.

CustomBuilder.mergeAndSave()

To save the builder JSON definition.

CustomBuilder.preview()

Preview the builder result of CustomBuilder.json in a new browser tab.

CustomBuilder.updateFromJson()

Update the CustomBuilder.json based on edited JSON in advance tool definition tab.

CustomBuilder.undo()

Load the latest stored JSON definition from undo stack and add current JSON definition to redo stack.

CustomBuilder.redo()

Load the latest stored JSON definition from redo stack and add current JSON definition to undo stack.

CustomBuilder.addToUndo(json)

Add JSON definition to undo stack.

Parameters

CustomBuilder.adjustJson()

To trigger change event to update advance tools

CustomBuilder.updateSaveStatus(mode)

To update the save button status by the undo/redo function

Parameters

CustomBuilder.showMessage(message)

To fade in a message on top center of the builder

Parameters

CustomBuilder.getCopiedElement()

To retrieve the current copied element.

Return a object with "type" and "object" attribute. The "object" is the element object.

CustomBuilder.copy(element, type)

To copy an element object to local storage.

Parameters

CustomBuilder.updatePasteIcon(type)

To enable/disable all paste icons based on the type

Parameters

CustomBuilder.editProperties(elementClass, elementProperties)

To edit the properties of an element

Parameters

CustomBuilder.uuid()

To generate uuid.

Create Custom Plugin Interface/Abstract Class for Custom Builder

  1. Create a maven project contains only plugin interface, abstract class and APIs. This maven project will share with other developers who want to extend the feature of a custom builder.
  2. Include the maven project as a dependency of the custom builder project.
  3. Modify the custom builder project POM file to adding the package of plugin interface, abstract class and APIs to the <Export-Package>.

    <Export-Package>org.joget.pbuilder,org.joget.pbuilder.api.*</Export-Package>
  4. Register the plugin interface and abstract class in Activator class

    PluginManager.registerCustomPluginInterface(new CustomPluginInterface(PageWidget.class, "pageBuilder.pageWidget", PageBuilder.MESSAGE_PATH));

Sample Plugins