Joget Workflow v5 Training Slides - Module 17 - Building Plugins

  • View
    184

  • Download
    5

Embed Size (px)

Text of Joget Workflow v5 Training Slides - Module 17 - Building Plugins

Joget Workflow v4 - Training

Joget Workflow v5

Building Plugins

http://facebook.com/jogetworkflowhttp://twitter.com/jogetworkflow

Last Revised on May 2016Joget Inc Internal Use Only

All Rights Reserved Joget Inc

1

Joget Inc Internal Use OnlyJoget Inc Internal Use Only

PrerequisitesBasic web application development knowledge.Java web application programming knowledge.Understanding on Joget Workflow plugin architecture and plugin types.Joget Inc Internal Use Only

All Rights Reserved Joget Inc

ContentIntroductionCreating a Process Tool PluginCreating a Userview Theme PluginCreating a Form Field Element Plugin

Joget Inc Internal Use Only

All Rights Reserved Joget Inc

Chapter 1IntroductionJoget Inc Internal Use Only

All Rights Reserved Joget Inc

IntroductionIn this module, we will be learning on how to create:-Process Tool / Post Form Submission Processing pluginUserview pluginForm Field Element pluginJoget Inc Internal Use Only

All Rights Reserved Joget Inc

Plugin TypesJoget Inc Internal Use Only

All Rights Reserved Joget Inc

Each plugin is differentBefore you embark on your journey to build a new plugin, be sure to:-Each plugin may be implemented and configured (very) differently.Check out existing implementation of the kind of plugin.Extend the necessary classes for each implementation.Joget Inc Internal Use Only

All Rights Reserved Joget Inc

Plugin Abstract Classes and InterfaceDeadline Plugins extends org.joget.workflow.model.DefaultDeadlinePluginProcess Participant Plugins extends org.joget.workflow.model.DefaultParticipantPlugin Process Tool / Post Form Submission Processing Pluginsextends org.joget.plugin.base.DefaultApplicationPluginForm Field Element Pluginsextends org.joget.apps.form.model.Elementimplements org.joget.apps.form.model.FormBuilderPaletteElement

Joget Inc Internal Use Only

All Rights Reserved Joget Inc

Plugin Abstract Classes and InterfaceForm Load Binder Plugins extends org.joget.apps.form.model.FormBinderimplements org.joget.apps.form.model.FormLoadBinder, org.joget.apps.form.model.FormLoadElementBinderForm Options Binder Plugins extends org.joget.apps.form.model.FormBinderimplements org.joget.apps.form.model.FormLoadOptionsBinderForm Store Binder Plugins extends org.joget.apps.form.model.FormBinderimplements org.joget.apps.form.model.FormStoreBinder, org.joget.apps.form.model.FormStoreElementBinder

Joget Inc Internal Use Only

All Rights Reserved Joget Inc

Plugin Abstract Classes and InterfaceForm Validator Plugins extends org.joget.apps.form.model.FormValidatorDatalist Action Plugins extends org.joget.apps.datalist.model.DataListActionDefault Datalist Binder Pluginsextends org.joget.apps.datalist.model.DataListBinderDefaultDatalist Column Formatter Pluginsextends org.joget.apps.datalist.model.DataListColumnFormatDefaultUserview Menu Pluginsextends org.joget.apps.userview.model.UserviewMenu

Joget Inc Internal Use Only

All Rights Reserved Joget Inc

Plugin Abstract Classes and InterfaceUserview Permission Plugins extends org.joget.apps.userview.model.UserviewPermissionUserview Theme Plugins extends org.joget.apps.userview.model.UserviewTheme Audit Trail Pluginsextends org.joget.plugin.base.DefaultAuditTrailPluginHash Variable Pluginsextends org.joget.apps.app.model.DefaultHashVariablePluginDirectory Manager Pluginsextends org.joget.plugin.base.ExtDefaultPluginimplements org.joget.directory.model.service.DirectoryManagerPlugin, org.joget.plugin.property.model.PropertyEditable

Joget Inc Internal Use Only

All Rights Reserved Joget Inc

Introduction to Property OptionsEach plugin uses the Property Options template scheme to provide an interface for end user to configure the eventual plugin.

Reference: http://dev.joget.org/community/display/KBv5/Plugin+Properties+Options Joget Inc Internal Use Only

All Rights Reserved Joget Inc

Property OptionsJSON format

[{title :'Page Title',properties : [{name :'Property Name',label :'Property Label',description :'Property Description',//optional, default is NULLtype :'Property Type',value :'Property Value',//optional, default is nullrequired :'Mandatory or Not',//optional, 'true' or 'false', default is 'false'// more attributes },// more fields ],validators : [//optional// properties custom validators ],buttons : [//optional// custom properties page buttons ]},// more properties page ]Joget Inc Internal Use Only

All Rights Reserved Joget Inc

Property Options TypesFrom V4Check Box CheckBoxElement Select Box ElementSelectGrid GridHidden Field HiddenHTML Editor HtmlEditorMulti Select Box MultiSelectPassword Field PasswordRadio Button RadioReadonly Text Field ReadonlySelect Box SelectBoxText Area TextAreaText Field TextFieldJoget Inc Internal Use Only

All Rights Reserved Joget Inc

Property Options TypesNew in V5Code Editor CodeEditorCombine Grid GridCombineFixed Row Grid GridFixedRowHeader HeaderLabel Label

Joget Inc Internal Use Only

All Rights Reserved Joget Inc

Common Attributes for All Property Options Type except Hidden Field and Grid{ name : Property Name, label : Property Label, description : Property Description, //optional, default is NULL type : readonly, value : Property Value, //optional , default is empty string required : true, //optional, boolean value, default is false }Joget Inc Internal Use Only

All Rights Reserved Joget Inc

Extra Attributes for Text Field, Password Field, Text Area and HTML Editor{ size : 50, //optional , integer value, default is NULL, only for text field and password field maxlength : 50, //optional, integer value, default is NULL, only for text field and password field rows : 50, //optional, integer value, default is NULL, only for text area and html editor cols : 50, //optional, integer value, default is NULL , only for text area and html editor regex_validation : ^[a-zA-Z0-9_]+$, //optional, default is NULL validation_message : Error!! //optional, default is NULL}Joget Inc Internal Use Only

All Rights Reserved Joget Inc

Extra Attributes for Checkbox, Radio Button, Select Box and Multi Select Box{ size : 10, //optional, integer value, default is 4, only for multi select box options : [ //is optional to use this attribute or options_ajax {value: value1, label : Value 1}, {value: value2, label : Value 2}, {value: value3, label : Value 3} ], options_ajax_on_change : property1, //optional, value of this property name will passed over to load options from ajax, only for select box and multi select box options_ajax : URL to load options JSON //optional, URL return JSON Array of a set of Objects that have value & label attribute}Joget Inc Internal Use Only

All Rights Reserved Joget Inc

Attributes for Hidden Field{ name : Property Name, type : hidden, value : Property Value}Joget Inc Internal Use Only

All Rights Reserved Joget Inc

Attributes for Grid{ name : Property Name, label : Property Label, description : Property Description, //optional, default is NULL type : grid, columns : [ // 2 type of column, with and without options attribute {key : col1, label : Col 1}, {key : col2, label : Col 2, options:[ {value :option1, label : Option 1}, {value :option2, label : Option 2} ] }, ] value : [ //optional, default is NULL {col1 : abc, col2 : option1}, {col1 : def, col2 : option2} ], required : true, //optional, boolean value, default is false}Joget Inc Internal Use Only

All Rights Reserved Joget Inc

Extra Attributes for Element Select Field{ options_ajax_on_change : property1, //optional, value of this property name will passover to load options from ajax options_ajax : [CONTEXT_PATH]/web/property/json/getElements?classname= org.joget.apps.form.model.FormLoadElementBinder, //Load plugin list based on class name given url : [CONTEXT_PATH]/web/property/json/getPropertyOptions //Load plugin properties}Joget Inc Internal Use Only

All Rights Reserved Joget Inc

Property Validator TypesCurrently only one validator type supported - AJAX{ type : AJAX, url : URL to validate properties page value , // All properties in the same page will send to this url to validate, URL return a JSON Object with status (success or fail) & message (JSONArray of String) attribute default_error_message : Error in this page!! //optional, default is null}Joget Inc Internal Use Only

All Rights Reserved Joget Inc

Internationalization SupportYou may localise your plugin.

Joget Inc Internal Use Only

All Rights Reserved Joget Inc

In the getPropertyOptions() method of your plugin, make reference to the message key properties fileExample:

Create the corresponding file (e.g. formDataUpdateTool.properties) in src/main/resources/messages folder.

Internationalization Supportreturn AppUtil.readPluginResource(getClass().getName(), "/properties/formDataUpdateTool.json", null, true, "/messages/formDataUpdateTool"); Joget Inc Internal Use Only

All Rights Reserved Joget Inc

Common Plugin Utility MethodsGet a bean from application context

DirectoryManager dm = (DirectoryManager) AppUtil.getApplicationContext().getBean(directoryManager);Read a resource file as String from resources folder

String resource = AppUtil.readPluginResource(getClass().getName(), "/properties/plugin.json", new String[]{value 1, value 2}, true, "message/pl