Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
package org.joget.tutorial; import org.joget.apps.app.service.AppPluginUtil; import org.joget.apps.app.service.AppUtil; import org.joget.apps.generator.model.GeneratorPlugin; import org.joget.apps.generator.model.GeneratorResult; public class FormSubmissionStatisticsGenerator extends GeneratorPlugin { private final static String MESSAGE_PATH = "messages/FormSubmissionStatisticsGenerator"; public String getName() { return "File Link Datalist Formatter"; } public String getVersion() { return "5.0.0"; } public String getClassName() { return getClass().getName(); } public String getLabel() { //support i18n return AppPluginUtil.getMessage("org.joget.tutorial.FormSubmissionStatisticsGenerator.pluginLabel", getClassName(), MESSAGE_PATH); } public String getDescription() { //support i18n return AppPluginUtil.getMessage("org.joget.tutorial.FormSubmissionStatisticsGenerator.pluginDesc", getClassName(), MESSAGE_PATH); } public String getPropertyOptions() { return AppUtil.readPluginResource(getClassName(), "/properties/formSubmissionStatisticsGenerator.json", null, true, MESSAGE_PATH); } @Override public String getExplanation() { //support i18n return AppPluginUtil.getMessage("generator.formSubmissionStatistics.explanation", getClassName(), MESSAGE_PATH); } @Override public GeneratorResult generate() { throw new UnsupportedOperationException("Not supported yet."); } } |
Then, we have to do a UI for admin user to provide inputs for our plugin. In getPropertyOptions method, we already specify our Plugin Properties Options definition file is locate at "/properties/formSubmissionStatisticsGenerator.json". Let us create a directory "resources/properties" under "form_submission_statistics_generator/src/main" directory. After create the directory, create a file named "formSubmissionStatisticsGenerator.json" in the "properties" folder.
In the properties definition options file, we will need to provide options as below. Please note that we can use "@@message.key@@" syntax to support i18n in our properties options.
Code Block | ||
---|---|---|
| ||
[{
title : '@@generator.formSubmissionStatistics.config@@',
properties : [
{
name : 'userviewId',
label : '@@generator.formSubmissionStatistics.userview@@',
type : 'selectbox',
value: '[default_userviewId]',
options_ajax : '[CONTEXT_PATH]/web/json/console/app[APP_PATH]/userview/options'
},
{
name : 'categoryLabel',
label : '@@generator.formSubmissionStatistics.categoryLabel@@',
type : 'textfield',
required : 'true',
value : '@@generator.formSubmissionStatistics.categoryLabel.value@@'
},
{
name : 'monthlyMenuLabel',
label : '@@generator.formSubmissionStatistics.monthlyMenuLabel@@',
type : 'textfield',
required : 'true',
value : '@@generator.formSubmissionStatistics.monthlyMenuLabel.value@@'
},
{
name : 'monthlyChartTitle',
label : '@@generator.formSubmissionStatistics.monthlyChartTitle@@',
type : 'textfield',
required : 'true',
value : '@@generator.formSubmissionStatistics.monthlyChartTitle.value@@'
},
{
name : 'monthlyXAxisLabel',
label : '@@generator.formSubmissionStatistics.monthlyXAxisLabel@@',
type : 'textfield',
required : 'true',
value : '@@generator.formSubmissionStatistics.monthlyXAxisLabel.value@@'
},
{
name : 'dailyMenuLabel',
label : '@@generator.formSubmissionStatistics.dailyMenuLabel@@',
type : 'textfield',
required : 'true',
value : '@@generator.formSubmissionStatistics.dailyMenuLabel.value@@'
},
{
name : 'dailyChartTitle',
label : '@@generator.formSubmissionStatistics.dailyChartTitle@@',
type : 'textfield',
required : 'true',
value : '@@generator.formSubmissionStatistics.dailyChartTitle.value@@'
},
{
name : 'dailyXAxisLabel',
label : '@@generator.formSubmissionStatistics.dailyXAxisLabel@@',
type : 'textfield',
required : 'true',
value : '@@generator.formSubmissionStatistics.dailyXAxisLabel.value@@'
},
{
name : 'yAxisLabel',
label : '@@generator.formSubmissionStatistics.yAxisLabel@@',
type : 'textfield',
required : 'true',
value : '@@generator.formSubmissionStatistics.yAxisLabel.value@@'
}]
}] |
Code Block | ||
---|---|---|
| ||
public String getPropertyOptions() {
String options = AppUtil.readPluginResource(getClassName(), "/properties/formSubmissionStatisticsGenerator.json", null, true, MESSAGE_PATH);
//populate value like [formName]
options = GeneratorUtil.populateFormMeta(options, getFormId(), getAppDefinition());
//populate value of [default_userviewId]
options = options.replace("[default_userviewId]", GeneratorUtil.getFirstAvailableUserviewId(getAppDefinition()));
return options;
} |