Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
...
Refer to the document of the plugin type listed in Plugin Types, find the abstract class and interface that need to extends and implements by your plugin.
Example: To develop a Userview Menu plugin, the plugin class need to extends the org.joget.apps.userview.model.UserviewMenu abstract class.
A plugin will has to implements the abstract method of Plugin Base Abstract Class and Interface and also the abstract method of the individual abstract class and interface for the plugin type.
Example: To develop a Userview Menu plugin, the following methods have to implemented by the plugin. Please refer to the plugin documents for the details of each methods.
...
The generated plugin folder by "wflow-plugin-archetype" module is a maven project. So, we will using the Dependency Mechanism provided by Maven.
To make the plugin i18n ready, we need to create a message resource bundle property file for the plugin.
Example: For a plugin named "GanttChartMenu", we need to create a "GanttChartMenu.properties" file under "[Plugin project directory]/src/main/resources/message" directory.
Sample content for GanttChartMenu.properties file
Code Block | ||
---|---|---|
| ||
org.joget.sample.GanttChartMenu.pluginLabel=Gantt Chart
org.joget.sample.GanttChartMenu.pluginDesc=To display form data in Gantt Chart layout
userview.ganttChart.label.title=Title
userview.ganttChart.label.week=Week |
Example: Use the getMessage method in getLabel and getDescription methods to return i18n label and description.
Code Block | ||
---|---|---|
| ||
public String getLabel() {
return AppPluginUtil.getMessage("org.joget.sample.GanttChartMenu.pluginLabel", getClassName(), "message/GanttChartMenu");
}
public String getDescription() {
return AppPluginUtil.getMessage("org.joget.sample.GanttChartMenu.pluginDesc", getClassName(), "message/GanttChartMenu");
} |
Example: For property options of a GanttChartMenu plugin, the following show the sample code implementation of getPropertyOptions method and the GanttChartMenu.json file
Code Block | ||
---|---|---|
| ||
public String getPropertyOptions() {
return AppUtil.readPluginResource(getClassName(), "/properties/GanttChartMenu.json", null, true, "message/GanttChartMenu");
} |
Code Block | ||
---|---|---|
| ||
[{
title : '@@userview.ganttChart.edit@@',
properties : [{
name : 'id',
label : 'Id',
type : 'hidden'
},
{
name : 'customId',
label : '@@userview.ganttChart.customId@@',
type : 'textfield',
regex_validation : '^[a-zA-Z0-9_]+$',
validation_message : '@@userview.ganttChart.invalidId@@'
},
{
name : 'label',
label : '@@userview.ganttChart.label@@',
type : 'textfield',
required : 'True',
value : '@@userview.ganttChart.label.value@@'
}]
}] |
Example: For getRenderPage method of a GanttChartMenu plugin, the following show the sample code implementation of getRenderPage method and the "GanttChartMenu.ftl" FreeMarker template.
Code Block | ||
---|---|---|
| ||
public String getRenderPage() {
Map model = new HashMap();
model.put("request", getRequestParameters());
model.put("element", this);
PluginManager pluginManager = (PluginManager)AppUtil.getApplicationContext().getBean("pluginManager");
String content = pluginManager.getPluginFreeMarkerTemplate(model, getClasstName(), "/templates/GanttChartMenu.ftl", "message/GanttChartMenu");
return content;
} |
Code Block | ||
---|---|---|
| ||
<div>
<h1>@@userview.ganttChart.label.title@@ : ${element.properties.title!}</h1>
</div> |
Example: GanttChartMenu_zh_CN.properties
e. Register your plugin to Felix Framework
You will found a class named "Activator.java" is auto generated in a package of your plugin maven project. The class is used to register your plugin class to Felix Framework. You do not need to do this if your plugin is not an OSGI Plugin.
In the start method of the activator class, add your plugin class to the "registrationList" variable.
Code Block | ||
---|---|---|
| ||
public void start(BundleContext context) {
registrationList = new ArrayList<ServiceRegistration>();
//Register plugin here
registrationList.add(context.registerService(MyPlugin.class.getName(), new MyPlugin(), null));
} |
Once you done all the steps above, you can build your project with your IDE using Maven. You can also run "mvn clean install" command in your project directory to build it. After building your project, a jar file is created under "target" folder in your plugin project folder. Upload the plugin jar to Manage Plugins to test your plugin.
Example: In NetBeans, click the "Clean and Build" after right click on the project name.
...