Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
This is the excerpt of the file that is responsible to generate such dropdown selection.
You will need to include such definition in your plugin's property definition file.
{ name: 'postProcessor', label:'@@form.form.postProcessor@@', type:'elementselect', options_ajax:'[CONTEXT_PATH]/web/property/json/getElements?classname=org.joget.plugin.base.ApplicationPlugin', url:'[CONTEXT_PATH]/web/property/json[APP_PATH]/getPropertyOptions', default_property_values_url: '[CONTEXT_PATH]/web/property/json[APP_PATH]/getDefaultProperties' }
Line 5 - Attribute "options_ajax" with the service URL set is responsible to load all the plugin tied to "org.joget.plugin.base.ApplicationPlugin" (Process Tool) into the selection. You may change the value to load the appropriate type of plugin you want.
[CONTEXT_PATH] is a special variable that will be replaced automatically at runtime with the Joget web app context information. (e.g. http://localhost:8080/jw )
Line 6 - With the value in Line 4 set, the property editor will make a call to this URL, passing along the selection made. (e.g. http://localhost:8080/jw/web/property/json/expenseclaim/1/getPropertyOptions?value=org.joget.apps.app.lib.EmailTool)
[CONTEXT_PATH] is a special variable that will be replaced automatically at runtime with the Joget webapp context information. (e.g. http://localhost:8080/jw )
[APP_PATH] is a special variable that will be replaced automatically at runtime with the Joget App context information. (e.g. /expenseclaim/1)
Line 7 - Attribute "default_property_values_url" is optional but recommended to be included. When a new tab is created for the configurations of the selected plugin, default values will be loaded to ease and shorten the time in configuring.
Essentially, we will just need these few lines in our own plugin to get it to work.
Object binderData = getProperty("postProcessor"); PluginManager pluginManager = (PluginManager) AppUtil.getApplicationContext().getBean("pluginManager"); if (binderData != null && binderData instanceof Map) { Map bdMap = (Map) binderData; if (bdMap != null && bdMap.containsKey("className") && !bdMap.get("className").toString().isEmpty()) { String className = bdMap.get("className").toString(); Plugin p = pluginManager.getPlugin(className); Map propertiesMap = (Map) bdMap.get("properties"); ApplicationPlugin appPlugin = (ApplicationPlugin) p; if (appPlugin instanceof PropertyEditable) { ((PropertyEditable) appPlugin).setProperties(propertiesMap); } appPlugin.execute(propertiesMap); } }
If we need to grab the plugin's default properties or to inject appDef, request object, etc then these excerpts from the method "executePostFormSubmissionProccessor" becomes necessary.
Map propertiesMap = null; //get form json again to retrieve plugin properties FormDefinitionDao formDefinitionDao = (FormDefinitionDao) FormUtil.getApplicationContext().getBean("formDefinitionDao"); FormDefinition formDefinition = formDefinitionDao.loadById(form.getPropertyString(FormUtil.PROPERTY_ID), appDef); if (formDefinition != null) { String json = formDefinition.getJson(); JSONObject obj = new JSONObject(json); JSONObject objProperty = obj.getJSONObject(FormUtil.PROPERTY_PROPERTIES); if (objProperty.has(FormUtil.PROPERTY_POST_PROCESSOR)) { JSONObject objProcessor = objProperty.getJSONObject(FormUtil.PROPERTY_POST_PROCESSOR); json = objProcessor.getString(FormUtil.PROPERTY_PROPERTIES); propertiesMap = AppPluginUtil.getDefaultProperties(p, json, appDef, ass); } } if (propertiesMap == null) { propertiesMap = AppPluginUtil.getDefaultProperties(p, (Map) temp.get(FormUtil.PROPERTY_PROPERTIES), appDef, ass); } if (ass != null) { propertiesMap.put("workflowAssignment", ass); } propertiesMap.put("recordId", formData.getPrimaryKeyValue()); propertiesMap.put("pluginManager", pluginManager); propertiesMap.put("appDef", appDef); // add HttpServletRequest into the property map try { HttpServletRequest request = WorkflowUtil.getHttpServletRequest(); if (request != null) { propertiesMap.put("request", request); } } catch (Exception e) { // ignore if class is not found }