SlideShare a Scribd company logo
All Rights Reserved © Joget Inc
Joget Workflow v5
Building Plugins
http://facebook.com/jogetworkflow
http://twitter.com/jogetworkflow
Last Revised on May 2016Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Prerequisites
1. Basic web application development knowledge.
2. Java web application programming knowledge.
3. Understanding on Joget Workflow plugin architecture
and plugin types.
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Content
1. Introduction
2. Creating a Process Tool Plugin
3. Creating a Userview Theme Plugin
4. Creating a Form Field Element Plugin
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Chapter 1
Introduction
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Introduction
• In this module, we will be learning on how to create:-
– Process Tool / Post Form Submission Processing plugin
– Userview plugin
– Form Field Element plugin
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Plugin Types
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Each plugin is different
• Before 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 Interface
• Deadline Plugins
extends org.joget.workflow.model.DefaultDeadlinePlugin
• Process Participant Plugins
extends org.joget.workflow.model.DefaultParticipantPlugin
• Process Tool / Post Form Submission Processing Plugins
extends org.joget.plugin.base.DefaultApplicationPlugin
• Form Field Element Plugins
extends org.joget.apps.form.model.Element
implements org.joget.apps.form.model.FormBuilderPaletteElement
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Plugin Abstract Classes and Interface
• Form Load Binder Plugins
extends org.joget.apps.form.model.FormBinder
implements org.joget.apps.form.model.FormLoadBinder,
org.joget.apps.form.model.FormLoadElementBinder
• Form Options Binder Plugins
extends org.joget.apps.form.model.FormBinder
implements org.joget.apps.form.model.FormLoadOptionsBinder
• Form Store Binder Plugins
extends org.joget.apps.form.model.FormBinder
implements 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 Interface
• Form Validator Plugins
extends org.joget.apps.form.model.FormValidator
• Datalist Action Plugins
extends org.joget.apps.datalist.model.DataListActionDefault
• Datalist Binder Plugins
extends org.joget.apps.datalist.model.DataListBinderDefault
• Datalist Column Formatter Plugins
extends org.joget.apps.datalist.model.DataListColumnFormatDefault
• Userview Menu Plugins
extends org.joget.apps.userview.model.UserviewMenu
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Plugin Abstract Classes and Interface
• Userview Permission Plugins
extends org.joget.apps.userview.model.UserviewPermission
• Userview Theme Plugins
extends org.joget.apps.userview.model.UserviewTheme
• Audit Trail Plugins
extends org.joget.plugin.base.DefaultAuditTrailPlugin
• Hash Variable Plugins
extends org.joget.apps.app.model.DefaultHashVariablePlugin
• Directory Manager Plugins
extends org.joget.plugin.base.ExtDefaultPlugin
implements 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 Options
• Each 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 Options
• JSON format
[
{
title : 'Page Title',
properties : [
{
name : 'Property Name',
label : 'Property Label',
description : 'Property Description', //optional, default is NULL
type : 'Property Type',
value : 'Property Value', //optional, default is null
required : '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 Types
• From V4
– Check Box– CheckBox
– Element Select Box – ElementSelect
– Grid – Grid
– Hidden Field– Hidden
– HTML Editor– HtmlEditor
– Multi Select Box– MultiSelect
– Password Field – Password
– Radio Button – Radio
– Readonly Text Field– Readonly
– Select Box– SelectBox
– Text Area – TextArea
– Text Field – TextField
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Property Options Types
• New in V5
– Code Editor – CodeEditor
– Combine Grid – GridCombine
– Fixed Row Grid – GridFixedRow
– Header – Header
– Label – 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 Types
• Currently 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 Support
• You may localise your plugin.
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
1. In the getPropertyOptions() method of your plugin,
make reference to the message key properties file
Example:
2. Create the corresponding file (e.g.
formDataUpdateTool.properties) in
“src/main/resources/messages” folder.
Internationalization Support
return AppUtil.readPluginResource(getClass().getName(),
"/properties/formDataUpdateTool.json", null, true,
"/messages/formDataUpdateTool");
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Common Plugin Utility Methods
• Get 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/pluginResouseBundle");
Bean Name
Argument used for
String.format()
Remove new line char
Plugin Class NamePath to resource file in
resources folderPath to message bundle
in resources folder,
without .properties file
extension
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Common Plugin Utility Methods
• Processing Hash Variable to a String
content = AppUtil.processHashVariable(content, workflowAssignment,
StringUtil.TYPE_REGEX, replaceMap);
• Get a i18n message from message bundle
String message = AppPluginUtil.getMessage(“Label”, getClass().getName(),
"message/pluginResouseBundle")
Content to be process Workflow Assignment ObjectString escape type,
TYPE_REGEX,
TYPE_JSON or null
A map contains Strings to be replace
Path to message bundle in resources
folder, without .properties file extension
Message Key Plugin Class Name
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Common Plugin Utility Methods
• Get parameter name of Form Element
String param = FormUtil.getElementParameterName(this);
• Get value of Form Element
String value = FormUtil.getElementPropertyValue(this, formData);
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Common Plugin Utility Methods
• More at
http://dev.joget.org/community/pages/viewpage.action?pageId=19103970
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Plugin Web Support
• implements org.joget.plugin.base.PluginWebSupport
• Implement webService method
• Example:
public void webService(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//get request parameter
String param = request.getParameter("param");
//print json response
JSONArray jsonArray = new JSONArray();
Map<String, String> option1 = new HashMap<String, String>();
option1.put("value", "value1"); option1.put("label", "Value 1");
jsonArray.put(option1);
Map<String, String> option2 = new HashMap<String, String>();
option2.put("value", "value2"); option2.put("label", "Value 2");
jsonArray.put(option2);
jsonArray.write(response.getWriter());
}
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Chapter 2
Creating a Process Tool Plugin
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Building Your First Plugin
• No, we are not going to build a “Hello World”
• Build a simple tool to update form data in a process
• Scenario:
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Simple Form Data Update Tool
1. Create a maven project.
2. Open the maven project in NetBeans.
3. Create a class and extend DefaultApplicationPlugin
abstract class.
4. Implement all the standard plugin method.
5. Register plugin class in Activator class.
6. Decide the property options for the plugin.
7. Implement execute method to update form data.
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Creating a Maven Project for Your Plugin
• Using Joget Workflow subproject “wflow-plugin-archetype” to create a Maven
project for your plugin.
• For Windows:
1. Create a directory to contain your plugins. (E.g. “C:joget-projects”)
2. In Command Prompt, navigate to the newly created directory.
3. Run “…wflow-plugin-archetypecreate-plugin.bat" org.joget.sample sample-
plugin-pack 5.0-SNAPSHOT”
4. Key in “5.0-SNAPSHOT” for version and “y” to confirm all the information
• For Linux:
1. Create a directory at home directory to contain your plugins.
(E.g. “~joget-projects”)
2. In Command Terminal, go to the created directory.
3. Run “…wflow-plugin-archetypecreate-plugin.bat" org.joget.sample sample-
plugin-pack 5.0-SNAPSHOT
4. Key in “5.0-SNAPSHOT” for version and “y” to confirm all the information
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Creating a Maven Project for Your Plugin
• Windows
Joget Inc Internal Use Only
C:joget-projects>“C:jw-communitybranches5.0-SNAPSHOTwflow-plugin-archetypecreate-plugin.bat" org.joget.sample
sample-plugin-pack 5.0-SNAPSHOT
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[WARNING] Archetype not found in any catalog. Falling back to central repository (http://repo1.maven.org/maven2).
[WARNING] Use -DarchetypeRepository=<your repository> if archetype's repository is elsewhere.
Downloading: http://repo1.maven.org/maven2/org/joget/wflow-plugin-archetype/5.0-SNAPSHOT/maven-metadata.xml
Downloading: http://dev.joget.org/archiva/repository/snapshots2/org/joget/wflow-plugin-archetype/5.0-SNAPSHOT/maven-
metadata.xml
All Rights Reserved © Joget Inc
Creating a Maven Project for Your Plugin
• Windows
Joget Inc Internal Use Only
[INFO] Using property: groupId = org.joget.sample
[INFO] Using property: artifactId = sample-plugin-pack
Define value for property 'version': 1.0-SNAPSHOT: : 5.0-SNAPSHOT
[INFO] Using property: package = org.joget.sample
Confirm properties configuration:
groupId: org.joget.sample
artifactId: sample-plugin-pack
version: 5.0-SNAPSHOT
package: org.joget.sample
Y: : Y
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: wflow-plugin-archetype:5.0-SNAPSHOT
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.joget.sample
[INFO] Parameter: packageName, Value: org.joget.sample
[INFO] Parameter: package, Value: org.joget.sample
[INFO] Parameter: artifactId, Value: sample-plugin-pack
[INFO] Parameter: version, Value: 5.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: C:joget-projectssample-plugin-pack
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
All Rights Reserved © Joget Inc
What is Inside The Maven Project
• Open the newly created project in your IDE (i.e. Netbeans).
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
What is Inside The Maven Project
• pom.xml
– POM stands for "Project Object Model“, an XML representation
of a Maven project
– Used to manage your plugin dependencies jar
• Activator.java
– Bundle Activator for OSGi framework
– The activator class is the bundle's hook to the lifecycle layer for
management.
– Used to register your plugin class in start method
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Creating a Plugin Class
1. In your Maven project, create a plugin class call
“SimpleFormDataUpdateTool”.
2. Extends org.joget.plugin.base.DefaultApplicationPlugin
3. Import required class file
4. Implement all abstract methods
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Standard Plugin Methods
public String getClassName() {
return getClass().getName(); //plugin class name, MUST be the exact class name of the plugin
}
public String getName() {
return "Plugin Name"; //Unique indentifier of plugin, override plugin with same name, used to display in Manage Plugin
}
public String getDescription() {
return "Plugin Description"; //Used to display in Manage Plugin
}
public String getVersion() {
return “1.0.0"; //Plugin Version, used to display in Manage Plugin
}
public String getLabel() {
return "Plugin Label"; //Short Label, used to display in plugin select box
}
public String getPropertyOptions() {
return ""; //Plugin property options, in JSON format
}
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Update Plugin Information
public String getName() {
return “Simple Form Data Update Tool";
}
public String getVersion() {
return “1.0.0";
}
public String getDescription() {
return “Update form data in a Process.";
}
public String getLabel() {
return “Simple Form Data Update Tool";
}
public String getClassName() {
return getClass().getName();
}
public String getPropertyOptions() {
return "";
}
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Register Your Plugin Class
1. Open Activator.java
2. Add the code below to start method
//Register plugin here
registrationList.add(context.registerService(SimpleFormDataUpdateTool.class
.getName(), new SimpleFormDataUpdateTool(), null));
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Decide Your Plugin Property Options
• What kind of information needed from user?
– Which form to update?
– Which record in the form data?
– Which fields to modify?
– What is the value need to set to the particular field?
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Decide Your Plugin Property Options
• What kind of information needed from user?
– Q: Which form to update?
A: a select box with all available form listed
– Q: Which record in the form data?
A: Use process’s record id if not specify (in the grid)
– Q: Which fields to modify?
A: A grid with all the field ids and it’s value to update
– Q: What is the value need to set to the particular field?
A: Answer as above
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Create Your Plugin Properties
1. In your Maven project, right and create new folder
2. Key in “src/main/resources/properties” and press Finish
3. Under “Other Sources” > “src/main/resources” >
“properties”, create a new Empty File named
“simpleFormDataUpdateTool.json”
4. Put the following code in your public String
getPropertyOptions() method
5. Construct your plugin properties in
“simpleFormDataUpdateTool.json”.
return AppUtil.readPluginResource(getClass().getName(),
"/properties/simpleFormDataUpdateTool.json", null, true, null);
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
formDataUpdateTool.json
[{
title : 'Configure Simple Form Data Update Tool',
properties : [{
name : 'formDefId',
label : 'Form',
type : 'SelectBox',
options_ajax : '[CONTEXT_PATH]/web/json/console/app[APP_PATH]/forms/options',
required : 'true'
},{
name : 'fields',
label : 'Update Fields',
type : 'Grid',
columns : [{
key : 'field',
label : 'Field Id'
},
{
key : 'value',
label : 'Value'
}],
required : 'true'
}]
}]
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Implement Execute Method
1. Get FormDefId from properties
2. Get record Id from process
3. Check whether record Id is configured to different value
in properties grid
4. Load the original Form Data record
5. Set the updated fields and it’s value to the loaded data
6. Store the updated data
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Implement Execute Method
//Get FormDefId from properties
String formDefId = (String) props.get("formDefId");
//Get record Id from process
WorkflowAssignment wfAssignment = (WorkflowAssignment)
props.get("workflowAssignment");
AppService appService = (AppService)
AppUtil.getApplicationContext().getBean("appService");
String id = appService.getOriginProcessId(wfAssignment.getProcessId());
//Check whether record Id is configured to different value in properties grid
Object[] fields = (Object[]) props.get("fields");
for (Object o : fields) {
Map mapping = (HashMap) o;
String fieldName = mapping.get("field").toString();
if (FormUtil.PROPERTY_ID.equals(fieldName)) {
String fieldValue = mapping.get("value").toString();
id = fieldValue;
break;
}
}
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Implement Execute Method
//Load the original Form Data record
AppDefinition appDef = (AppDefinition) props.get("appDef");
FormRow row = new FormRow();
FormRowSet rowSet = appService.loadFormData(appDef.getAppId(),
appDef.getVersion().toString(), formDefId, id);
if (!rowSet.isEmpty()) {
row = rowSet.get(0);
}
//Set the updated fields and it’s value to the loaded data
for (Object o : fields) {
Map mapping = (HashMap) o;
String fieldName = mapping.get("field").toString();
String fieldValue = mapping.get("value").toString();
row.setProperty(fieldName, fieldValue);
}
//Store the updated data
rowSet.set(0, row);
appService.storeFormData(appDef.getAppId(), appDef.getVersion().toString(),
formDefId, rowSet, id);
return null;
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
1. In your Maven project, right and create new folder
2. Key in “src/main/resources/messages” and press Finish
3. Under “Other Sources” > “src/main/resources” > “messages”,
create a new Properties File (eg “simpleFormDataUpdateTool”)
4. Modify code in your public String getPropertyOptions() method
5. Modify label to key in your plugin properties file.
6. Create keys and messages in your
simpleFormDataUpdateTool.properties file
i18n your Plugin Properties
return AppUtil.readPluginResource(getClass().getName(),
"/properties/simpleFormDataUpdateTool.json", null, true,
"/messages/simpleFormDataUpdateTool");
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
New simpleFormDataUpdateTool.json
with message key
[{
title : '@@sfdut.config@@',
properties : [{
name : 'formDefId',
label : '@@sfdut.form@@',
type : 'selectbox',
options_ajax : '[CONTEXT_PATH]/web/json/console/app[APP_PATH]/forms/options',
required : 'true'
},{
name : 'fields',
label : '@@sfdut.fields@@',
type : 'grid',
columns : [{
key : 'field',
label : '@@sfdut.fieldId@@'
},
{
key : 'value',
label : '@@sfdut.value@@'
}],
required : 'true'
}]
}]
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
simpleFormDataUpdateTool.properties
sfdut.config=Configure Simple Form Data Update Tool
sfdut.form=Form
sfdut.fields=Update Fields
sfdut.fieldId=Field Id
sfdut.value=Value
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Test and Run Your Plugin
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Materials
• Completed project files can be obtained at
17-2-sample-plugin-pack.zip
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Chapter Review
• Be able to prepare a new Maven project.
• Be able to build a plugin and run it in Joget.
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Chapter 3
Creating a Userview Theme
Plugin
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Creating a Userview Theme Plugin
• Study the existing implementation of other existing
Userview Themes.
– Open “DefaultTheme.java”
– Locate relevant files that made up of the plugin.
Joget Inc Internal Use Only
@Override
public String getCss() {
String css = AppUtil.readPluginResource(getClassName(),
"/resources/themes/default/default.css");
css += getPropertyString("css");
css = css.replaceAll("@@contextPath@@",
getRequestParameterString("contextPath"));
return css;
}
public String getPropertyOptions() {
return AppUtil.readPluginResource(getClass().getName(),
"/properties/userview/defaultTheme.json", null, true,
"message/userview/defaultTheme");
}
All Rights Reserved © Joget Inc
Study the file structure
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Creating a Maven Project for Your Plugin
• Using Joget Workflow subproject “wflow-plugin-archetype” to create a Maven
project for your plugin.
• For Windows:
1. Create a directory to contain your plugins. (E.g. “C:joget-projects”)
2. In Command Prompt, navigate to the newly created directory.
3. Run “…wflow-plugin-archetypecreate-plugin.bat" org.joget.sample theme-
plugin-pack 5.0-SNAPSHOT”
4. Key in “5.0-SNAPSHOT” for version and “y” to confirm all the information
• For Linux:
1. Create a directory at home directory to contain your plugins.
(E.g. “~joget-projects”)
2. In Command Terminal, go to the created directory.
3. Run “…wflow-plugin-archetypecreate-plugin.bat" org.joget.sample theme-
plugin-pack 5.0-SNAPSHOT
4. Key in “5.0-SNAPSHOT” for version and “y” to confirm all the information
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Creating a Maven Project for Your Plugin
• Windows
Joget Inc Internal Use Only
C:joget-projects>C:jw-communitytrunkwflow-plugin-archetypecreate-plugin.bat org.joget.sample theme-pack 5.0-
SNAPSHOT
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread
count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[WARNING] Archetype not found in any catalog. Falling back to central repository (http://repo1.maven.org/maven2).
[WARNING] Use -DarchetypeRepository=<your repository> if archetype's repository is elsewhere.
Downloading: http://repo1.maven.org/maven2/org/joget/wflow-plugin-archetype/5.0-SNAPSHOT/maven-metadata.xml
Downloading: http://repo1.maven.org/org/joget/wflow-plugin-archetype/5.0-SNAPSHOT/maven-metadata.xml
All Rights Reserved © Joget Inc
Creating a Maven Project for Your Plugin
• Windows
Joget Inc Internal Use Only
[INFO] Using property: groupId = org.joget.sample
[INFO] Using property: artifactId = theme-pack
Define value for property 'version': 1.0-SNAPSHOT: 5.0-SNAPSHOT
[INFO] Using property: package = org.joget.sample
Confirm properties configuration:
groupId: org.joget.sample
artifactId: theme-pack
version: 5.0-SNAPSHOT
package: org.joget.sample
Y: : Y
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: wflow-plugin-archetype:5.0-SNAPSHOT
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.joget.sample
[INFO] Parameter: packageName, Value: org.joget.sample
[INFO] Parameter: package, Value: org.joget.sample
[INFO] Parameter: artifactId, Value: theme-pack
[INFO] Parameter: version, Value: 5.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: C:joget-projectstheme-pack
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
All Rights Reserved © Joget Inc
What is Inside The Maven Project
• Open the newly created project in your IDE (i.e. Netbeans).
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
What is Inside The Maven Project
• pom.xml
– POM stands for "Project Object Model“, an XML representation
of a Maven project
– Used to manage your plugin dependencies jar
• Activator.java
– Bundle Activator for OSGi framework
– The activator class is the bundle's hook to the lifecycle layer for
management.
– Used to register your plugin class in start method
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Creating a Plugin Class
1. In your Maven project, create a plugin class call
“EnhancedTheme”.
2. Extends UserviewTheme
3. Import required class file
4. Implement all abstract methods
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Register Your Plugin Class
1. Open Activator.java
2. Add the code below to start method
//Register plugin here
registrationList.add(context.registerService(EnhancedTheme.class.getName(),
new EnhancedTheme(), null));
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Implementing the methods
• You may copy the existing implementations of
DefaultTheme.
• Replace where applicable.
Joget Inc Internal Use Only
public String getCss() {
String css = AppUtil.readPluginResource(getClassName(),
"/resources/themes/enhanced/enhanced.css");
public String getName() {
return "Enhanced Theme";
public String getPropertyOptions() {
return AppUtil.readPluginResource(getClass().getName(),
"/properties/userview/enhancedTheme.json", null, true,
"/messages/userview/enhancedTheme");
}
public String getLabel() {
return "Enhanced Theme";
All Rights Reserved © Joget Inc
Creating the supporting files
• resources/themes/enhanced/enhanced.css
• resources/themes/enhanced/header.png
• properties/userview/enhancedTheme.json
• messages/userview/enhancedTheme.properties
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Get Creative
• Get Creative! Create your theme accordingly by tweaking
the CSS.
• You may also add in your own scripting if required.
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Build and upload
• When you are ready, build the plugin and upload to your
Joget and test out the theme in actual Userview.
• Repeat as many times as needed too until you achieve
what you want.
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Original Theme
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
New Theme
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Materials
• You may obtain project source code of the sample new
theme showcased in this chapter from the file
17-3-theme-pack.zip
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Chapter Review
• Be able to create a Userview Theme plugin.
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Chapter 4
Creating a Form Field
Element Plugin
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
What are we going to build?
• We are going to build a Form Field Element that works
very similarly like a Text Field but…
– By incorporating the use of a jQuery plugin that automatically
formats currency and numbers as you type on form inputs.
– Reference: http://www.decorplanit.com/plugin/
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Creating a Form Field Element Plugin
• Study the existing implementation of other existing form
field elements.
– Open “TextField.java”, locate relevant files that made up of the plugin.
Joget Inc Internal Use Only
@Override
public String getPropertyOptions() {
...
return AppUtil.readPluginResource(getClass().getName(),
"/properties/form/textField.json", new Object[]{encryption}, true,
"message/form/TextField");
}
@Override
public String getFormBuilderIcon() {
return
"/plugin/org.joget.apps.form.lib.TextField/images/textField_icon.gif";
}
@Override
public String renderTemplate(FormData formData, Map dataModel) {
String template = "textField.ftl";
All Rights Reserved © Joget Inc
Creating a Maven Project for Your Plugin
• Using Joget Workflow subproject “wflow-plugin-archetype” to create a Maven
project for your plugin.
• For Windows:
1. Create a directory to contain your plugins. (E.g. “C:joget-projects”)
2. In Command Prompt, navigate to the newly created directory.
3. Run “…wflow-plugin-archetypecreate-plugin.bat" org.joget.sample currency-
pack 5.0-SNAPSHOT”
4. Key in “5.0-SNAPSHOT” for version and “y” to confirm all the information
• For Linux:
1. Create a directory at home directory to contain your plugins.
(E.g. “~joget-projects”)
2. In Command Terminal, go to the created directory.
3. Run “…wflow-plugin-archetypecreate-plugin.bat" org.joget.sample currency-
pack 5.0-SNAPSHOT
4. Key in “5.0-SNAPSHOT” for version and “y” to confirm all the information
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Creating a Maven Project for Your Plugin
• Windows
Joget Inc Internal Use Only
C:joget-projects>C:jw-communitytrunkwflow-plugin-archetypecreate-plugin.bat org.joget.sample currency-pack 5.0-
SNAPSHOT
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread
count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[WARNING] Archetype not found in any catalog. Falling back to central repository (http://repo1.maven.org/maven2).
[WARNING] Use -DarchetypeRepository=<your repository> if archetype's repository is elsewhere.
Downloading: http://repo1.maven.org/maven2/org/joget/wflow-plugin-archetype/5.0-SNAPSHOT/maven-metadata.xml
Downloading: http://repo1.maven.org/org/joget/wflow-plugin-archetype/5.0-SNAPSHOT/maven-metadata.xml
All Rights Reserved © Joget Inc
Creating a Maven Project for Your Plugin
• Windows
Joget Inc Internal Use Only
[INFO] Using property: groupId = org.joget.sample
[INFO] Using property: artifactId = currency-pack
Define value for property 'version': 1.0-SNAPSHOT: 5.0-SNAPSHOT
[INFO] Using property: package = org.joget.sample
Confirm properties configuration:
groupId: org.joget.sample
artifactId: currency-pack
version: 5.0-SNAPSHOT
package: org.joget.sample
Y: : Y
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: wflow-plugin-archetype:5.0-SNAPSHOT
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.joget.sample
[INFO] Parameter: packageName, Value: org.joget.sample
[INFO] Parameter: package, Value: org.joget.sample
[INFO] Parameter: artifactId, Value: currency-pack
[INFO] Parameter: version, Value: 5.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: C:joget-projectscurrency-pack
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
All Rights Reserved © Joget Inc
What is Inside The Maven Project
• Open the newly created project in your IDE (i.e. Netbeans).
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
What is Inside The Maven Project
• pom.xml
– POM stands for "Project Object Model“, an XML representation
of a Maven project
– Used to manage your plugin dependencies jar
• Activator.java
– Bundle Activator for OSGi framework
– The activator class is the bundle's hook to the lifecycle layer for
management.
– Used to register your plugin class in start method
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Creating a Plugin Class
1. In your Maven project, create a plugin class call
“CurrencyField”.
2. Extends Element implements
FormBuilderPaletteElement
3. Import required class file
4. Implement all abstract methods
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Register Your Plugin Class
1. Open Activator.java
2. Add the code below to start method
//Register plugin here
registrationList.add(context.registerService(CurrencyField.class.getName(),
new CurrencyField(), null));
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Implementing the methods
• You may copy the existing implementations of TextField.
• Replace where applicable.
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Property Options
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Property Options
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Creating the supporting files
• resources/message/form/currencyField.properties
• resources/properties/form/currencyField.json
• resources/resources/images/currencyField_icon.gif
• resources/resources/js/autoNumeric.js
• resources/templates/currencyField.ftl
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Build and upload
• When you are ready, build the plugin and upload to your
Joget and test out the form element field in actual form
view.
• Repeat as many times as needed too until you achieve
what you want.
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Materials
• You may obtain project source code of the sample new
theme showcased in this chapter from the file
17-4-currency-pack.zip
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Chapter Review
• Be able to create a Form Field Element plugin.
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Module Review
1. Introduction
2. Creating a Process Tool Plugin
3. Creating a Userview Theme Plugin
4. Creating a Form Field Element Plugin
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Recommended Further Learning
• Study on how other plugin types are implemented.
– Check out the Joget Marketplace at
http://marketplace.joget.org/
– Check out the Joget Knowledge Base – Developer Guide
http://dev.joget.org/community/display/KBv5/Extending+Functionality+-+Developing+Plugins
Joget Inc Internal Use Only
All Rights Reserved © Joget Inc
Stay Connected with Joget Workflow
• http://www.joget.org
• http://community.joget.org
• http://twitter.com/jogetworkflow
• http://facebook.com/jogetworkflow
• http://youtube.com/jogetworkflow
• http://slideshare.net/joget
Joget Inc Internal Use Only

More Related Content

PPTX
Joget Workflow v5 Training Slides - Module 19 - Doing More With Your Process ...
PPTX
Joget Workflow v6 Training Slides - 17 - Building Plugins
PPTX
Joget Workflow v5 Training Slides - Module 15 - Introduction to Plugin Archit...
PPTX
Joget Workflow v5 Training Slides - Module 4 - Localizing your Joget Workflow
PPTX
Joget Workflow v5 Training Slides - Module 9 - Hash variable
PPTX
Joget Workflow v6 Training Slides - 9 - Hash Variable
PPTX
Joget Workflow v5 Training Slides - Module 13 - Improving your form design an...
PPTX
Joget Workflow v5 Training Slides - Module 20 - Basic System Administration
Joget Workflow v5 Training Slides - Module 19 - Doing More With Your Process ...
Joget Workflow v6 Training Slides - 17 - Building Plugins
Joget Workflow v5 Training Slides - Module 15 - Introduction to Plugin Archit...
Joget Workflow v5 Training Slides - Module 4 - Localizing your Joget Workflow
Joget Workflow v5 Training Slides - Module 9 - Hash variable
Joget Workflow v6 Training Slides - 9 - Hash Variable
Joget Workflow v5 Training Slides - Module 13 - Improving your form design an...
Joget Workflow v5 Training Slides - Module 20 - Basic System Administration

What's hot (20)

PPTX
Joget Workflow v6 Training Slides - 18 - Integrating with External System
PPTX
Joget Workflow v4 Training - Module 14 - Introduction to Reporting
PPTX
Joget Workflow v5 Training Slides - Module 10 - Participant Mapping and Permi...
PPTX
Joget Workflow v6 Training Slides - 21 - Userview Key
PPTX
Joget Workflow v6 Training Slides - 19 - Doing More with your Process Design
PPTX
Joget Workflow v5 Training Slides - Module 14 - Introduction to reporting
PPTX
Joget Workflow v6 Training Slides - 15 - Introduction to Plugin Architecture
PPTX
Joget Workflow v6 Training Slides - 20 - Basic System Administration
PPTX
Joget Workflow v4 Training - Module 2 - Setting up Joget Workflow
PPTX
Joget Workflow v6 Training Slides - 14 - Introduction to Reporting
PDF
Joget Workflow Training – Basic & Advance for v3.1 – Module 1 – Introduction
PPTX
Joget Workflow v5 Training Slides - Module 16 - Preparing Development Environ...
PPTX
Joget Workflow v6 Training Slides - 22 - Best Practices on Application Building
PPTX
Joget Workflow v6 Training Slides - 3 - Designing your First Process
PPTX
Joget Workflow v6 Training Slides - 7 - Designing your First Datalist
PPTX
Joget Workflow v5 Training Slides - Module 8 - Designing your first Userview
PPTX
Joget Workflow v6 Training Slides - 13 - Improving your Form Design and Prese...
PPTX
Joget Workflow v5 Training Slides - Module 7 - Designing your first Datalist
PPTX
Joget Workflow v5 Training Slides - Module 12 - Version Control
PDF
Joget Workflow Training – Basic & Advance for v3.1 – Module 11 – A Revision -...
Joget Workflow v6 Training Slides - 18 - Integrating with External System
Joget Workflow v4 Training - Module 14 - Introduction to Reporting
Joget Workflow v5 Training Slides - Module 10 - Participant Mapping and Permi...
Joget Workflow v6 Training Slides - 21 - Userview Key
Joget Workflow v6 Training Slides - 19 - Doing More with your Process Design
Joget Workflow v5 Training Slides - Module 14 - Introduction to reporting
Joget Workflow v6 Training Slides - 15 - Introduction to Plugin Architecture
Joget Workflow v6 Training Slides - 20 - Basic System Administration
Joget Workflow v4 Training - Module 2 - Setting up Joget Workflow
Joget Workflow v6 Training Slides - 14 - Introduction to Reporting
Joget Workflow Training – Basic & Advance for v3.1 – Module 1 – Introduction
Joget Workflow v5 Training Slides - Module 16 - Preparing Development Environ...
Joget Workflow v6 Training Slides - 22 - Best Practices on Application Building
Joget Workflow v6 Training Slides - 3 - Designing your First Process
Joget Workflow v6 Training Slides - 7 - Designing your First Datalist
Joget Workflow v5 Training Slides - Module 8 - Designing your first Userview
Joget Workflow v6 Training Slides - 13 - Improving your Form Design and Prese...
Joget Workflow v5 Training Slides - Module 7 - Designing your first Datalist
Joget Workflow v5 Training Slides - Module 12 - Version Control
Joget Workflow Training – Basic & Advance for v3.1 – Module 11 – A Revision -...
Ad

Viewers also liked (14)

PPTX
Joget Workflow v5 Training Slides - Module 18 - Integrating with External System
PPTX
Joget Workflow v5 Training Slides - Module 5 - Designing your First Form
PPTX
Joget Workflow v5 Training Slides - Module 6 - Using your first Process Tool
PPTX
Joget Workflow v5 Training Slides - Module 3 - Designing your first Process
PPTX
Joget Workflow v5 Training Slides - Module 11 - SLA and Deadlines
PPTX
Joget Workflow v5 Training Slides - Module 21 - Userview Key
PPTX
Joget Workflow v5 Training Slides - Module 2 - Setting up Joget Workflow
PPTX
Joget Workflow v4 Training - Module 3 - Designing your First Process
PDF
Easy joget v3 for the absolute beginner
PDF
Joget v5 Getting Started Guide
PPTX
Joget Workflow v4 Training - Module 7 - Designing your first Datalist
PPTX
Joget Workflow v5 Training - Module 1 - Introduction to Joget Workflow
PDF
Joget Workflow Training – Basic & Advance for v3.1 – Module 10 – Hash Variables
PDF
Automate workflows with leading open-source BPM
Joget Workflow v5 Training Slides - Module 18 - Integrating with External System
Joget Workflow v5 Training Slides - Module 5 - Designing your First Form
Joget Workflow v5 Training Slides - Module 6 - Using your first Process Tool
Joget Workflow v5 Training Slides - Module 3 - Designing your first Process
Joget Workflow v5 Training Slides - Module 11 - SLA and Deadlines
Joget Workflow v5 Training Slides - Module 21 - Userview Key
Joget Workflow v5 Training Slides - Module 2 - Setting up Joget Workflow
Joget Workflow v4 Training - Module 3 - Designing your First Process
Easy joget v3 for the absolute beginner
Joget v5 Getting Started Guide
Joget Workflow v4 Training - Module 7 - Designing your first Datalist
Joget Workflow v5 Training - Module 1 - Introduction to Joget Workflow
Joget Workflow Training – Basic & Advance for v3.1 – Module 10 – Hash Variables
Automate workflows with leading open-source BPM
Ad

Similar to Joget Workflow v5 Training Slides - Module 17 - Building Plugins (17)

PPTX
Joget Workflow v4 Training - Module 9 - Hash Variable
PPTX
Joget Workflow v6 Training Slides - 4 - Localizing your Joget Workflow
PDF
Joget Workflow Training – Basic & Advance for v3.1 – Module 7 – Creating Data...
PPTX
Joget Workflow v4 Training - Module 15 - Introduction to Plugin Architecture
PDF
Writing Gadgets with the WSO2 Gadget Server
PPTX
Joget Workflow v6 Training Slides - 8 - Designing your First Userview
PPTX
Joget Workflow v4 Training - Module 8 - Designing your first Userview
PDF
Joget Workflow Training – Basic & Advance for v3.1 – Module 5 – Creating your...
PPTX
Joget Workflow v6 Training Slides - 2 - Setting Up Joget Workflow
PPT
OpenSocial Intro
PPTX
Joget Workflow v4 Training - Module 13 -Improving your Form Design and Presen...
ODP
JMP103 : Extending Your App Arsenal With OpenSocial
ODP
IBM Connect 2014 - JMP103: Extending Your Application Arsenal With OpenSocial
PPTX
Joget Workflow v4 Training - Module 6 - Using your First Process Tool - Email
PPTX
Joget Workflow v4 Training - Module 4 - Localizing your Joget
PDF
Developing for LinkedIn's Application Platform
PDF
Top100summit 谷歌-scott-improve your automated web application testing
Joget Workflow v4 Training - Module 9 - Hash Variable
Joget Workflow v6 Training Slides - 4 - Localizing your Joget Workflow
Joget Workflow Training – Basic & Advance for v3.1 – Module 7 – Creating Data...
Joget Workflow v4 Training - Module 15 - Introduction to Plugin Architecture
Writing Gadgets with the WSO2 Gadget Server
Joget Workflow v6 Training Slides - 8 - Designing your First Userview
Joget Workflow v4 Training - Module 8 - Designing your first Userview
Joget Workflow Training – Basic & Advance for v3.1 – Module 5 – Creating your...
Joget Workflow v6 Training Slides - 2 - Setting Up Joget Workflow
OpenSocial Intro
Joget Workflow v4 Training - Module 13 -Improving your Form Design and Presen...
JMP103 : Extending Your App Arsenal With OpenSocial
IBM Connect 2014 - JMP103: Extending Your Application Arsenal With OpenSocial
Joget Workflow v4 Training - Module 6 - Using your First Process Tool - Email
Joget Workflow v4 Training - Module 4 - Localizing your Joget
Developing for LinkedIn's Application Platform
Top100summit 谷歌-scott-improve your automated web application testing

More from Joget Workflow (7)

PPTX
Joget Workflow v6 Training Slides - 16 - Preparing Development Environment
PPTX
Joget Workflow v6 Training Slides - 12 - Version Control
PPTX
Joget Workflow v6 Training Slides - 11 - SLA and Deadlines
PPTX
Joget Workflow v6 Training Slides - 10 - Participant Mapping and Permission C...
PPTX
Joget Workflow v6 Training Slides - 6 - Using your First Process Tool
PPTX
Joget Workflow v6 Training Slides - 5 - Designing your First Form
PPTX
Joget Workflow v6 Training Slides - 1 - Introduction to Joget Workflow
Joget Workflow v6 Training Slides - 16 - Preparing Development Environment
Joget Workflow v6 Training Slides - 12 - Version Control
Joget Workflow v6 Training Slides - 11 - SLA and Deadlines
Joget Workflow v6 Training Slides - 10 - Participant Mapping and Permission C...
Joget Workflow v6 Training Slides - 6 - Using your First Process Tool
Joget Workflow v6 Training Slides - 5 - Designing your First Form
Joget Workflow v6 Training Slides - 1 - Introduction to Joget Workflow

Recently uploaded (20)

PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
AI in Product Development-omnex systems
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Introduction to Artificial Intelligence
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
System and Network Administration Chapter 2
PDF
top salesforce developer skills in 2025.pdf
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
Which alternative to Crystal Reports is best for small or large businesses.pdf
AI in Product Development-omnex systems
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Wondershare Filmora 15 Crack With Activation Key [2025
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Navsoft: AI-Powered Business Solutions & Custom Software Development
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Introduction to Artificial Intelligence
Reimagine Home Health with the Power of Agentic AI​
Adobe Illustrator 28.6 Crack My Vision of Vector Design
System and Network Administration Chapter 2
top salesforce developer skills in 2025.pdf
VVF-Customer-Presentation2025-Ver1.9.pptx
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
How to Choose the Right IT Partner for Your Business in Malaysia
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PTS Company Brochure 2025 (1).pdf.......
2025 Textile ERP Trends: SAP, Odoo & Oracle

Joget Workflow v5 Training Slides - Module 17 - Building Plugins

  • 1. All Rights Reserved © Joget Inc Joget Workflow v5 Building Plugins http://facebook.com/jogetworkflow http://twitter.com/jogetworkflow Last Revised on May 2016Joget Inc Internal Use Only
  • 2. All Rights Reserved © Joget Inc Prerequisites 1. Basic web application development knowledge. 2. Java web application programming knowledge. 3. Understanding on Joget Workflow plugin architecture and plugin types. Joget Inc Internal Use Only
  • 3. All Rights Reserved © Joget Inc Content 1. Introduction 2. Creating a Process Tool Plugin 3. Creating a Userview Theme Plugin 4. Creating a Form Field Element Plugin Joget Inc Internal Use Only
  • 4. All Rights Reserved © Joget Inc Chapter 1 Introduction Joget Inc Internal Use Only
  • 5. All Rights Reserved © Joget Inc Introduction • In this module, we will be learning on how to create:- – Process Tool / Post Form Submission Processing plugin – Userview plugin – Form Field Element plugin Joget Inc Internal Use Only
  • 6. All Rights Reserved © Joget Inc Plugin Types Joget Inc Internal Use Only
  • 7. All Rights Reserved © Joget Inc Each plugin is different • Before 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
  • 8. All Rights Reserved © Joget Inc Plugin Abstract Classes and Interface • Deadline Plugins extends org.joget.workflow.model.DefaultDeadlinePlugin • Process Participant Plugins extends org.joget.workflow.model.DefaultParticipantPlugin • Process Tool / Post Form Submission Processing Plugins extends org.joget.plugin.base.DefaultApplicationPlugin • Form Field Element Plugins extends org.joget.apps.form.model.Element implements org.joget.apps.form.model.FormBuilderPaletteElement Joget Inc Internal Use Only
  • 9. All Rights Reserved © Joget Inc Plugin Abstract Classes and Interface • Form Load Binder Plugins extends org.joget.apps.form.model.FormBinder implements org.joget.apps.form.model.FormLoadBinder, org.joget.apps.form.model.FormLoadElementBinder • Form Options Binder Plugins extends org.joget.apps.form.model.FormBinder implements org.joget.apps.form.model.FormLoadOptionsBinder • Form Store Binder Plugins extends org.joget.apps.form.model.FormBinder implements org.joget.apps.form.model.FormStoreBinder, org.joget.apps.form.model.FormStoreElementBinder Joget Inc Internal Use Only
  • 10. All Rights Reserved © Joget Inc Plugin Abstract Classes and Interface • Form Validator Plugins extends org.joget.apps.form.model.FormValidator • Datalist Action Plugins extends org.joget.apps.datalist.model.DataListActionDefault • Datalist Binder Plugins extends org.joget.apps.datalist.model.DataListBinderDefault • Datalist Column Formatter Plugins extends org.joget.apps.datalist.model.DataListColumnFormatDefault • Userview Menu Plugins extends org.joget.apps.userview.model.UserviewMenu Joget Inc Internal Use Only
  • 11. All Rights Reserved © Joget Inc Plugin Abstract Classes and Interface • Userview Permission Plugins extends org.joget.apps.userview.model.UserviewPermission • Userview Theme Plugins extends org.joget.apps.userview.model.UserviewTheme • Audit Trail Plugins extends org.joget.plugin.base.DefaultAuditTrailPlugin • Hash Variable Plugins extends org.joget.apps.app.model.DefaultHashVariablePlugin • Directory Manager Plugins extends org.joget.plugin.base.ExtDefaultPlugin implements org.joget.directory.model.service.DirectoryManagerPlugin, org.joget.plugin.property.model.PropertyEditable Joget Inc Internal Use Only
  • 12. All Rights Reserved © Joget Inc Introduction to Property Options • Each 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
  • 13. All Rights Reserved © Joget Inc Property Options • JSON format [ { title : 'Page Title', properties : [ { name : 'Property Name', label : 'Property Label', description : 'Property Description', //optional, default is NULL type : 'Property Type', value : 'Property Value', //optional, default is null required : '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
  • 14. All Rights Reserved © Joget Inc Property Options Types • From V4 – Check Box– CheckBox – Element Select Box – ElementSelect – Grid – Grid – Hidden Field– Hidden – HTML Editor– HtmlEditor – Multi Select Box– MultiSelect – Password Field – Password – Radio Button – Radio – Readonly Text Field– Readonly – Select Box– SelectBox – Text Area – TextArea – Text Field – TextField Joget Inc Internal Use Only
  • 15. All Rights Reserved © Joget Inc Property Options Types • New in V5 – Code Editor – CodeEditor – Combine Grid – GridCombine – Fixed Row Grid – GridFixedRow – Header – Header – Label – Label Joget Inc Internal Use Only
  • 16. 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
  • 17. 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
  • 18. 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
  • 19. All Rights Reserved © Joget Inc Attributes for Hidden Field { name : ‘Property Name’, type : ‘hidden’, value : ‘Property Value’ } Joget Inc Internal Use Only
  • 20. 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
  • 21. 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
  • 22. All Rights Reserved © Joget Inc Property Validator Types • Currently 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
  • 23. All Rights Reserved © Joget Inc Internationalization Support • You may localise your plugin. Joget Inc Internal Use Only
  • 24. All Rights Reserved © Joget Inc 1. In the getPropertyOptions() method of your plugin, make reference to the message key properties file Example: 2. Create the corresponding file (e.g. formDataUpdateTool.properties) in “src/main/resources/messages” folder. Internationalization Support return AppUtil.readPluginResource(getClass().getName(), "/properties/formDataUpdateTool.json", null, true, "/messages/formDataUpdateTool"); Joget Inc Internal Use Only
  • 25. All Rights Reserved © Joget Inc Common Plugin Utility Methods • Get 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/pluginResouseBundle"); Bean Name Argument used for String.format() Remove new line char Plugin Class NamePath to resource file in resources folderPath to message bundle in resources folder, without .properties file extension Joget Inc Internal Use Only
  • 26. All Rights Reserved © Joget Inc Common Plugin Utility Methods • Processing Hash Variable to a String content = AppUtil.processHashVariable(content, workflowAssignment, StringUtil.TYPE_REGEX, replaceMap); • Get a i18n message from message bundle String message = AppPluginUtil.getMessage(“Label”, getClass().getName(), "message/pluginResouseBundle") Content to be process Workflow Assignment ObjectString escape type, TYPE_REGEX, TYPE_JSON or null A map contains Strings to be replace Path to message bundle in resources folder, without .properties file extension Message Key Plugin Class Name Joget Inc Internal Use Only
  • 27. All Rights Reserved © Joget Inc Common Plugin Utility Methods • Get parameter name of Form Element String param = FormUtil.getElementParameterName(this); • Get value of Form Element String value = FormUtil.getElementPropertyValue(this, formData); Joget Inc Internal Use Only
  • 28. All Rights Reserved © Joget Inc Common Plugin Utility Methods • More at http://dev.joget.org/community/pages/viewpage.action?pageId=19103970 Joget Inc Internal Use Only
  • 29. All Rights Reserved © Joget Inc Plugin Web Support • implements org.joget.plugin.base.PluginWebSupport • Implement webService method • Example: public void webService(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //get request parameter String param = request.getParameter("param"); //print json response JSONArray jsonArray = new JSONArray(); Map<String, String> option1 = new HashMap<String, String>(); option1.put("value", "value1"); option1.put("label", "Value 1"); jsonArray.put(option1); Map<String, String> option2 = new HashMap<String, String>(); option2.put("value", "value2"); option2.put("label", "Value 2"); jsonArray.put(option2); jsonArray.write(response.getWriter()); } Joget Inc Internal Use Only
  • 30. All Rights Reserved © Joget Inc Chapter 2 Creating a Process Tool Plugin Joget Inc Internal Use Only
  • 31. All Rights Reserved © Joget Inc Building Your First Plugin • No, we are not going to build a “Hello World” • Build a simple tool to update form data in a process • Scenario: Joget Inc Internal Use Only
  • 32. All Rights Reserved © Joget Inc Simple Form Data Update Tool 1. Create a maven project. 2. Open the maven project in NetBeans. 3. Create a class and extend DefaultApplicationPlugin abstract class. 4. Implement all the standard plugin method. 5. Register plugin class in Activator class. 6. Decide the property options for the plugin. 7. Implement execute method to update form data. Joget Inc Internal Use Only
  • 33. All Rights Reserved © Joget Inc Creating a Maven Project for Your Plugin • Using Joget Workflow subproject “wflow-plugin-archetype” to create a Maven project for your plugin. • For Windows: 1. Create a directory to contain your plugins. (E.g. “C:joget-projects”) 2. In Command Prompt, navigate to the newly created directory. 3. Run “…wflow-plugin-archetypecreate-plugin.bat" org.joget.sample sample- plugin-pack 5.0-SNAPSHOT” 4. Key in “5.0-SNAPSHOT” for version and “y” to confirm all the information • For Linux: 1. Create a directory at home directory to contain your plugins. (E.g. “~joget-projects”) 2. In Command Terminal, go to the created directory. 3. Run “…wflow-plugin-archetypecreate-plugin.bat" org.joget.sample sample- plugin-pack 5.0-SNAPSHOT 4. Key in “5.0-SNAPSHOT” for version and “y” to confirm all the information Joget Inc Internal Use Only
  • 34. All Rights Reserved © Joget Inc Creating a Maven Project for Your Plugin • Windows Joget Inc Internal Use Only C:joget-projects>“C:jw-communitybranches5.0-SNAPSHOTwflow-plugin-archetypecreate-plugin.bat" org.joget.sample sample-plugin-pack 5.0-SNAPSHOT [INFO] Scanning for projects... [INFO] [INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Stub Project (No POM) 1 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom >>> [INFO] [INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom <<< [INFO] [INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom --- [INFO] Generating project in Interactive mode [WARNING] Archetype not found in any catalog. Falling back to central repository (http://repo1.maven.org/maven2). [WARNING] Use -DarchetypeRepository=<your repository> if archetype's repository is elsewhere. Downloading: http://repo1.maven.org/maven2/org/joget/wflow-plugin-archetype/5.0-SNAPSHOT/maven-metadata.xml Downloading: http://dev.joget.org/archiva/repository/snapshots2/org/joget/wflow-plugin-archetype/5.0-SNAPSHOT/maven- metadata.xml
  • 35. All Rights Reserved © Joget Inc Creating a Maven Project for Your Plugin • Windows Joget Inc Internal Use Only [INFO] Using property: groupId = org.joget.sample [INFO] Using property: artifactId = sample-plugin-pack Define value for property 'version': 1.0-SNAPSHOT: : 5.0-SNAPSHOT [INFO] Using property: package = org.joget.sample Confirm properties configuration: groupId: org.joget.sample artifactId: sample-plugin-pack version: 5.0-SNAPSHOT package: org.joget.sample Y: : Y [INFO] ---------------------------------------------------------------------------- [INFO] Using following parameters for creating project from Old (1.x) Archetype: wflow-plugin-archetype:5.0-SNAPSHOT [INFO] ---------------------------------------------------------------------------- [INFO] Parameter: groupId, Value: org.joget.sample [INFO] Parameter: packageName, Value: org.joget.sample [INFO] Parameter: package, Value: org.joget.sample [INFO] Parameter: artifactId, Value: sample-plugin-pack [INFO] Parameter: version, Value: 5.0-SNAPSHOT [INFO] project created from Old (1.x) Archetype in dir: C:joget-projectssample-plugin-pack [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------
  • 36. All Rights Reserved © Joget Inc What is Inside The Maven Project • Open the newly created project in your IDE (i.e. Netbeans). Joget Inc Internal Use Only
  • 37. All Rights Reserved © Joget Inc What is Inside The Maven Project • pom.xml – POM stands for "Project Object Model“, an XML representation of a Maven project – Used to manage your plugin dependencies jar • Activator.java – Bundle Activator for OSGi framework – The activator class is the bundle's hook to the lifecycle layer for management. – Used to register your plugin class in start method Joget Inc Internal Use Only
  • 38. All Rights Reserved © Joget Inc Creating a Plugin Class 1. In your Maven project, create a plugin class call “SimpleFormDataUpdateTool”. 2. Extends org.joget.plugin.base.DefaultApplicationPlugin 3. Import required class file 4. Implement all abstract methods Joget Inc Internal Use Only
  • 39. All Rights Reserved © Joget Inc Standard Plugin Methods public String getClassName() { return getClass().getName(); //plugin class name, MUST be the exact class name of the plugin } public String getName() { return "Plugin Name"; //Unique indentifier of plugin, override plugin with same name, used to display in Manage Plugin } public String getDescription() { return "Plugin Description"; //Used to display in Manage Plugin } public String getVersion() { return “1.0.0"; //Plugin Version, used to display in Manage Plugin } public String getLabel() { return "Plugin Label"; //Short Label, used to display in plugin select box } public String getPropertyOptions() { return ""; //Plugin property options, in JSON format } Joget Inc Internal Use Only
  • 40. All Rights Reserved © Joget Inc Update Plugin Information public String getName() { return “Simple Form Data Update Tool"; } public String getVersion() { return “1.0.0"; } public String getDescription() { return “Update form data in a Process."; } public String getLabel() { return “Simple Form Data Update Tool"; } public String getClassName() { return getClass().getName(); } public String getPropertyOptions() { return ""; } Joget Inc Internal Use Only
  • 41. All Rights Reserved © Joget Inc Register Your Plugin Class 1. Open Activator.java 2. Add the code below to start method //Register plugin here registrationList.add(context.registerService(SimpleFormDataUpdateTool.class .getName(), new SimpleFormDataUpdateTool(), null)); Joget Inc Internal Use Only
  • 42. All Rights Reserved © Joget Inc Decide Your Plugin Property Options • What kind of information needed from user? – Which form to update? – Which record in the form data? – Which fields to modify? – What is the value need to set to the particular field? Joget Inc Internal Use Only
  • 43. All Rights Reserved © Joget Inc Decide Your Plugin Property Options • What kind of information needed from user? – Q: Which form to update? A: a select box with all available form listed – Q: Which record in the form data? A: Use process’s record id if not specify (in the grid) – Q: Which fields to modify? A: A grid with all the field ids and it’s value to update – Q: What is the value need to set to the particular field? A: Answer as above Joget Inc Internal Use Only
  • 44. All Rights Reserved © Joget Inc Create Your Plugin Properties 1. In your Maven project, right and create new folder 2. Key in “src/main/resources/properties” and press Finish 3. Under “Other Sources” > “src/main/resources” > “properties”, create a new Empty File named “simpleFormDataUpdateTool.json” 4. Put the following code in your public String getPropertyOptions() method 5. Construct your plugin properties in “simpleFormDataUpdateTool.json”. return AppUtil.readPluginResource(getClass().getName(), "/properties/simpleFormDataUpdateTool.json", null, true, null); Joget Inc Internal Use Only
  • 45. All Rights Reserved © Joget Inc formDataUpdateTool.json [{ title : 'Configure Simple Form Data Update Tool', properties : [{ name : 'formDefId', label : 'Form', type : 'SelectBox', options_ajax : '[CONTEXT_PATH]/web/json/console/app[APP_PATH]/forms/options', required : 'true' },{ name : 'fields', label : 'Update Fields', type : 'Grid', columns : [{ key : 'field', label : 'Field Id' }, { key : 'value', label : 'Value' }], required : 'true' }] }] Joget Inc Internal Use Only
  • 46. All Rights Reserved © Joget Inc Implement Execute Method 1. Get FormDefId from properties 2. Get record Id from process 3. Check whether record Id is configured to different value in properties grid 4. Load the original Form Data record 5. Set the updated fields and it’s value to the loaded data 6. Store the updated data Joget Inc Internal Use Only
  • 47. All Rights Reserved © Joget Inc Implement Execute Method //Get FormDefId from properties String formDefId = (String) props.get("formDefId"); //Get record Id from process WorkflowAssignment wfAssignment = (WorkflowAssignment) props.get("workflowAssignment"); AppService appService = (AppService) AppUtil.getApplicationContext().getBean("appService"); String id = appService.getOriginProcessId(wfAssignment.getProcessId()); //Check whether record Id is configured to different value in properties grid Object[] fields = (Object[]) props.get("fields"); for (Object o : fields) { Map mapping = (HashMap) o; String fieldName = mapping.get("field").toString(); if (FormUtil.PROPERTY_ID.equals(fieldName)) { String fieldValue = mapping.get("value").toString(); id = fieldValue; break; } } Joget Inc Internal Use Only
  • 48. All Rights Reserved © Joget Inc Implement Execute Method //Load the original Form Data record AppDefinition appDef = (AppDefinition) props.get("appDef"); FormRow row = new FormRow(); FormRowSet rowSet = appService.loadFormData(appDef.getAppId(), appDef.getVersion().toString(), formDefId, id); if (!rowSet.isEmpty()) { row = rowSet.get(0); } //Set the updated fields and it’s value to the loaded data for (Object o : fields) { Map mapping = (HashMap) o; String fieldName = mapping.get("field").toString(); String fieldValue = mapping.get("value").toString(); row.setProperty(fieldName, fieldValue); } //Store the updated data rowSet.set(0, row); appService.storeFormData(appDef.getAppId(), appDef.getVersion().toString(), formDefId, rowSet, id); return null; Joget Inc Internal Use Only
  • 49. All Rights Reserved © Joget Inc 1. In your Maven project, right and create new folder 2. Key in “src/main/resources/messages” and press Finish 3. Under “Other Sources” > “src/main/resources” > “messages”, create a new Properties File (eg “simpleFormDataUpdateTool”) 4. Modify code in your public String getPropertyOptions() method 5. Modify label to key in your plugin properties file. 6. Create keys and messages in your simpleFormDataUpdateTool.properties file i18n your Plugin Properties return AppUtil.readPluginResource(getClass().getName(), "/properties/simpleFormDataUpdateTool.json", null, true, "/messages/simpleFormDataUpdateTool"); Joget Inc Internal Use Only
  • 50. All Rights Reserved © Joget Inc New simpleFormDataUpdateTool.json with message key [{ title : '@@sfdut.config@@', properties : [{ name : 'formDefId', label : '@@sfdut.form@@', type : 'selectbox', options_ajax : '[CONTEXT_PATH]/web/json/console/app[APP_PATH]/forms/options', required : 'true' },{ name : 'fields', label : '@@sfdut.fields@@', type : 'grid', columns : [{ key : 'field', label : '@@sfdut.fieldId@@' }, { key : 'value', label : '@@sfdut.value@@' }], required : 'true' }] }] Joget Inc Internal Use Only
  • 51. All Rights Reserved © Joget Inc simpleFormDataUpdateTool.properties sfdut.config=Configure Simple Form Data Update Tool sfdut.form=Form sfdut.fields=Update Fields sfdut.fieldId=Field Id sfdut.value=Value Joget Inc Internal Use Only
  • 52. All Rights Reserved © Joget Inc Test and Run Your Plugin Joget Inc Internal Use Only
  • 53. All Rights Reserved © Joget Inc Materials • Completed project files can be obtained at 17-2-sample-plugin-pack.zip Joget Inc Internal Use Only
  • 54. All Rights Reserved © Joget Inc Chapter Review • Be able to prepare a new Maven project. • Be able to build a plugin and run it in Joget. Joget Inc Internal Use Only
  • 55. All Rights Reserved © Joget Inc Chapter 3 Creating a Userview Theme Plugin Joget Inc Internal Use Only
  • 56. All Rights Reserved © Joget Inc Creating a Userview Theme Plugin • Study the existing implementation of other existing Userview Themes. – Open “DefaultTheme.java” – Locate relevant files that made up of the plugin. Joget Inc Internal Use Only @Override public String getCss() { String css = AppUtil.readPluginResource(getClassName(), "/resources/themes/default/default.css"); css += getPropertyString("css"); css = css.replaceAll("@@contextPath@@", getRequestParameterString("contextPath")); return css; } public String getPropertyOptions() { return AppUtil.readPluginResource(getClass().getName(), "/properties/userview/defaultTheme.json", null, true, "message/userview/defaultTheme"); }
  • 57. All Rights Reserved © Joget Inc Study the file structure Joget Inc Internal Use Only
  • 58. All Rights Reserved © Joget Inc Creating a Maven Project for Your Plugin • Using Joget Workflow subproject “wflow-plugin-archetype” to create a Maven project for your plugin. • For Windows: 1. Create a directory to contain your plugins. (E.g. “C:joget-projects”) 2. In Command Prompt, navigate to the newly created directory. 3. Run “…wflow-plugin-archetypecreate-plugin.bat" org.joget.sample theme- plugin-pack 5.0-SNAPSHOT” 4. Key in “5.0-SNAPSHOT” for version and “y” to confirm all the information • For Linux: 1. Create a directory at home directory to contain your plugins. (E.g. “~joget-projects”) 2. In Command Terminal, go to the created directory. 3. Run “…wflow-plugin-archetypecreate-plugin.bat" org.joget.sample theme- plugin-pack 5.0-SNAPSHOT 4. Key in “5.0-SNAPSHOT” for version and “y” to confirm all the information Joget Inc Internal Use Only
  • 59. All Rights Reserved © Joget Inc Creating a Maven Project for Your Plugin • Windows Joget Inc Internal Use Only C:joget-projects>C:jw-communitytrunkwflow-plugin-archetypecreate-plugin.bat org.joget.sample theme-pack 5.0- SNAPSHOT [INFO] Scanning for projects... [INFO] [INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Stub Project (No POM) 1 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom >>> [INFO] [INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom <<< [INFO] [INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom --- [INFO] Generating project in Interactive mode [WARNING] Archetype not found in any catalog. Falling back to central repository (http://repo1.maven.org/maven2). [WARNING] Use -DarchetypeRepository=<your repository> if archetype's repository is elsewhere. Downloading: http://repo1.maven.org/maven2/org/joget/wflow-plugin-archetype/5.0-SNAPSHOT/maven-metadata.xml Downloading: http://repo1.maven.org/org/joget/wflow-plugin-archetype/5.0-SNAPSHOT/maven-metadata.xml
  • 60. All Rights Reserved © Joget Inc Creating a Maven Project for Your Plugin • Windows Joget Inc Internal Use Only [INFO] Using property: groupId = org.joget.sample [INFO] Using property: artifactId = theme-pack Define value for property 'version': 1.0-SNAPSHOT: 5.0-SNAPSHOT [INFO] Using property: package = org.joget.sample Confirm properties configuration: groupId: org.joget.sample artifactId: theme-pack version: 5.0-SNAPSHOT package: org.joget.sample Y: : Y [INFO] ---------------------------------------------------------------------------- [INFO] Using following parameters for creating project from Old (1.x) Archetype: wflow-plugin-archetype:5.0-SNAPSHOT [INFO] ---------------------------------------------------------------------------- [INFO] Parameter: groupId, Value: org.joget.sample [INFO] Parameter: packageName, Value: org.joget.sample [INFO] Parameter: package, Value: org.joget.sample [INFO] Parameter: artifactId, Value: theme-pack [INFO] Parameter: version, Value: 5.0-SNAPSHOT [INFO] project created from Old (1.x) Archetype in dir: C:joget-projectstheme-pack [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS
  • 61. All Rights Reserved © Joget Inc What is Inside The Maven Project • Open the newly created project in your IDE (i.e. Netbeans). Joget Inc Internal Use Only
  • 62. All Rights Reserved © Joget Inc What is Inside The Maven Project • pom.xml – POM stands for "Project Object Model“, an XML representation of a Maven project – Used to manage your plugin dependencies jar • Activator.java – Bundle Activator for OSGi framework – The activator class is the bundle's hook to the lifecycle layer for management. – Used to register your plugin class in start method Joget Inc Internal Use Only
  • 63. All Rights Reserved © Joget Inc Creating a Plugin Class 1. In your Maven project, create a plugin class call “EnhancedTheme”. 2. Extends UserviewTheme 3. Import required class file 4. Implement all abstract methods Joget Inc Internal Use Only
  • 64. All Rights Reserved © Joget Inc Register Your Plugin Class 1. Open Activator.java 2. Add the code below to start method //Register plugin here registrationList.add(context.registerService(EnhancedTheme.class.getName(), new EnhancedTheme(), null)); Joget Inc Internal Use Only
  • 65. All Rights Reserved © Joget Inc Implementing the methods • You may copy the existing implementations of DefaultTheme. • Replace where applicable. Joget Inc Internal Use Only public String getCss() { String css = AppUtil.readPluginResource(getClassName(), "/resources/themes/enhanced/enhanced.css"); public String getName() { return "Enhanced Theme"; public String getPropertyOptions() { return AppUtil.readPluginResource(getClass().getName(), "/properties/userview/enhancedTheme.json", null, true, "/messages/userview/enhancedTheme"); } public String getLabel() { return "Enhanced Theme";
  • 66. All Rights Reserved © Joget Inc Creating the supporting files • resources/themes/enhanced/enhanced.css • resources/themes/enhanced/header.png • properties/userview/enhancedTheme.json • messages/userview/enhancedTheme.properties Joget Inc Internal Use Only
  • 67. All Rights Reserved © Joget Inc Get Creative • Get Creative! Create your theme accordingly by tweaking the CSS. • You may also add in your own scripting if required. Joget Inc Internal Use Only
  • 68. All Rights Reserved © Joget Inc Build and upload • When you are ready, build the plugin and upload to your Joget and test out the theme in actual Userview. • Repeat as many times as needed too until you achieve what you want. Joget Inc Internal Use Only
  • 69. All Rights Reserved © Joget Inc Original Theme Joget Inc Internal Use Only
  • 70. All Rights Reserved © Joget Inc New Theme Joget Inc Internal Use Only
  • 71. All Rights Reserved © Joget Inc Materials • You may obtain project source code of the sample new theme showcased in this chapter from the file 17-3-theme-pack.zip Joget Inc Internal Use Only
  • 72. All Rights Reserved © Joget Inc Chapter Review • Be able to create a Userview Theme plugin. Joget Inc Internal Use Only
  • 73. All Rights Reserved © Joget Inc Chapter 4 Creating a Form Field Element Plugin Joget Inc Internal Use Only
  • 74. All Rights Reserved © Joget Inc What are we going to build? • We are going to build a Form Field Element that works very similarly like a Text Field but… – By incorporating the use of a jQuery plugin that automatically formats currency and numbers as you type on form inputs. – Reference: http://www.decorplanit.com/plugin/ Joget Inc Internal Use Only
  • 75. All Rights Reserved © Joget Inc Creating a Form Field Element Plugin • Study the existing implementation of other existing form field elements. – Open “TextField.java”, locate relevant files that made up of the plugin. Joget Inc Internal Use Only @Override public String getPropertyOptions() { ... return AppUtil.readPluginResource(getClass().getName(), "/properties/form/textField.json", new Object[]{encryption}, true, "message/form/TextField"); } @Override public String getFormBuilderIcon() { return "/plugin/org.joget.apps.form.lib.TextField/images/textField_icon.gif"; } @Override public String renderTemplate(FormData formData, Map dataModel) { String template = "textField.ftl";
  • 76. All Rights Reserved © Joget Inc Creating a Maven Project for Your Plugin • Using Joget Workflow subproject “wflow-plugin-archetype” to create a Maven project for your plugin. • For Windows: 1. Create a directory to contain your plugins. (E.g. “C:joget-projects”) 2. In Command Prompt, navigate to the newly created directory. 3. Run “…wflow-plugin-archetypecreate-plugin.bat" org.joget.sample currency- pack 5.0-SNAPSHOT” 4. Key in “5.0-SNAPSHOT” for version and “y” to confirm all the information • For Linux: 1. Create a directory at home directory to contain your plugins. (E.g. “~joget-projects”) 2. In Command Terminal, go to the created directory. 3. Run “…wflow-plugin-archetypecreate-plugin.bat" org.joget.sample currency- pack 5.0-SNAPSHOT 4. Key in “5.0-SNAPSHOT” for version and “y” to confirm all the information Joget Inc Internal Use Only
  • 77. All Rights Reserved © Joget Inc Creating a Maven Project for Your Plugin • Windows Joget Inc Internal Use Only C:joget-projects>C:jw-communitytrunkwflow-plugin-archetypecreate-plugin.bat org.joget.sample currency-pack 5.0- SNAPSHOT [INFO] Scanning for projects... [INFO] [INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Stub Project (No POM) 1 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom >>> [INFO] [INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom <<< [INFO] [INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom --- [INFO] Generating project in Interactive mode [WARNING] Archetype not found in any catalog. Falling back to central repository (http://repo1.maven.org/maven2). [WARNING] Use -DarchetypeRepository=<your repository> if archetype's repository is elsewhere. Downloading: http://repo1.maven.org/maven2/org/joget/wflow-plugin-archetype/5.0-SNAPSHOT/maven-metadata.xml Downloading: http://repo1.maven.org/org/joget/wflow-plugin-archetype/5.0-SNAPSHOT/maven-metadata.xml
  • 78. All Rights Reserved © Joget Inc Creating a Maven Project for Your Plugin • Windows Joget Inc Internal Use Only [INFO] Using property: groupId = org.joget.sample [INFO] Using property: artifactId = currency-pack Define value for property 'version': 1.0-SNAPSHOT: 5.0-SNAPSHOT [INFO] Using property: package = org.joget.sample Confirm properties configuration: groupId: org.joget.sample artifactId: currency-pack version: 5.0-SNAPSHOT package: org.joget.sample Y: : Y [INFO] ---------------------------------------------------------------------------- [INFO] Using following parameters for creating project from Old (1.x) Archetype: wflow-plugin-archetype:5.0-SNAPSHOT [INFO] ---------------------------------------------------------------------------- [INFO] Parameter: groupId, Value: org.joget.sample [INFO] Parameter: packageName, Value: org.joget.sample [INFO] Parameter: package, Value: org.joget.sample [INFO] Parameter: artifactId, Value: currency-pack [INFO] Parameter: version, Value: 5.0-SNAPSHOT [INFO] project created from Old (1.x) Archetype in dir: C:joget-projectscurrency-pack [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS
  • 79. All Rights Reserved © Joget Inc What is Inside The Maven Project • Open the newly created project in your IDE (i.e. Netbeans). Joget Inc Internal Use Only
  • 80. All Rights Reserved © Joget Inc What is Inside The Maven Project • pom.xml – POM stands for "Project Object Model“, an XML representation of a Maven project – Used to manage your plugin dependencies jar • Activator.java – Bundle Activator for OSGi framework – The activator class is the bundle's hook to the lifecycle layer for management. – Used to register your plugin class in start method Joget Inc Internal Use Only
  • 81. All Rights Reserved © Joget Inc Creating a Plugin Class 1. In your Maven project, create a plugin class call “CurrencyField”. 2. Extends Element implements FormBuilderPaletteElement 3. Import required class file 4. Implement all abstract methods Joget Inc Internal Use Only
  • 82. All Rights Reserved © Joget Inc Register Your Plugin Class 1. Open Activator.java 2. Add the code below to start method //Register plugin here registrationList.add(context.registerService(CurrencyField.class.getName(), new CurrencyField(), null)); Joget Inc Internal Use Only
  • 83. All Rights Reserved © Joget Inc Implementing the methods • You may copy the existing implementations of TextField. • Replace where applicable. Joget Inc Internal Use Only
  • 84. All Rights Reserved © Joget Inc Property Options Joget Inc Internal Use Only
  • 85. All Rights Reserved © Joget Inc Property Options Joget Inc Internal Use Only
  • 86. All Rights Reserved © Joget Inc Creating the supporting files • resources/message/form/currencyField.properties • resources/properties/form/currencyField.json • resources/resources/images/currencyField_icon.gif • resources/resources/js/autoNumeric.js • resources/templates/currencyField.ftl Joget Inc Internal Use Only
  • 87. All Rights Reserved © Joget Inc Build and upload • When you are ready, build the plugin and upload to your Joget and test out the form element field in actual form view. • Repeat as many times as needed too until you achieve what you want. Joget Inc Internal Use Only
  • 88. All Rights Reserved © Joget Inc Materials • You may obtain project source code of the sample new theme showcased in this chapter from the file 17-4-currency-pack.zip Joget Inc Internal Use Only
  • 89. All Rights Reserved © Joget Inc Chapter Review • Be able to create a Form Field Element plugin. Joget Inc Internal Use Only
  • 90. All Rights Reserved © Joget Inc Module Review 1. Introduction 2. Creating a Process Tool Plugin 3. Creating a Userview Theme Plugin 4. Creating a Form Field Element Plugin Joget Inc Internal Use Only
  • 91. All Rights Reserved © Joget Inc Recommended Further Learning • Study on how other plugin types are implemented. – Check out the Joget Marketplace at http://marketplace.joget.org/ – Check out the Joget Knowledge Base – Developer Guide http://dev.joget.org/community/display/KBv5/Extending+Functionality+-+Developing+Plugins Joget Inc Internal Use Only
  • 92. All Rights Reserved © Joget Inc Stay Connected with Joget Workflow • http://www.joget.org • http://community.joget.org • http://twitter.com/jogetworkflow • http://facebook.com/jogetworkflow • http://youtube.com/jogetworkflow • http://slideshare.net/joget Joget Inc Internal Use Only