Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
...
Using back the sample, we can refer to the code at https://github.com/jogetworkflow/jw-community/blob/6.0-SNAPSHOT/wflow-core/src/main/java/org/joget/apps/form/service/FormUtil.java#L1932. Refer to the whole code of the method "executePostFormSubmissionProccessor".
Essentially, we will just need these few lines in our own plugin to get it to work.
Code Block | ||
---|---|---|
| ||
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 = tempbdMap.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(bdMap.get("className").toString())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" is becomes necessary.
Code Block | ||
---|---|---|
| ||
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 } |