Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
...
In this tutorial, we will follow the guideline for developing a plugin to develop our Mood Rating Form Field plugin. Please also refer to the very first tutorial วิธีการพัฒนา Bean Shell Hash Variable for more details steps.
We would like to have a rating field with some smiley images which can be reuse for other form.
We will develop a Form Field Element Plugin to render our mood rating field.
To develop a Mood Rating Form Field plugin, we will need to provide some standard inputs for a Form Field element.
A form field shown selection of smiley images and its radio button.
To develop the Mood Rating Form Field plugin, we can extends the Radio field in core product then replace its template and plugin properties options.
We need to always have our Joget Workflow Source Code ready and builded by following this guideline.
...
Open the maven project with your favourite IDE. I will be using NetBeans.
Create a "MoodRatingField" class under "org.joget" package. Then, extend the class with org.joget.apps.form.lib.Radio class. The org.joget.apps.form.lib.Radio class is an implementation of org.joget.apps.form.model.Element abstract class. Please refer to Form Field Element Plugin.
As usual, we have to implement all the abstract methods. We will using AppPluginUtil.getMessage method to support i18n and using constant variable MESSAGE_PATH for message resource bundle directory.
...
There are some smiley image files will be used by the template, let put those image files under "mood_rating/src/main/resources/resources/image" directory.
There are no additional library needed.
We are using i18n message key in getLabel and getDescription method. We will use i18n message key in our properties options definition as well. Then, we will need to create a message resource bundle properties file for our plugin.
...
Code Block |
---|
org.joget.MoodRatingField.pluginLabel=Mood Rating org.joget.MoodRatingField.pluginDesc=Form Field for rating mood form.moodRating.config=Edit Mood Rating |
Next, we will have to register our plugin class in the Activator class (Auto generated in the same class package) to tell the Felix Framework that this is a plugin.
Code Block | ||
---|---|---|
| ||
public void start(BundleContext context) { registrationList = new ArrayList<ServiceRegistration>(); //Register plugin here registrationList.add(context.registerService(MoodRatingField.class.getName(), new MoodRatingField(), null)); } |
Let's build our plugin. Once the building process is done, we will find a "mood_rating-5.0.0.jar" file created under "mood_rating/target" directory.
...
Check and test the field in form.
You can download the source code from mood_rating_src.zip.
...