Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
import org.joget.apps.app.dao.FormDefinitionDao; import org.joget.apps.app.model.FormDefinition; import org.joget.apps.app.model.AppDefinition; import org.joget.apps.app.service.AppUtil; import org.joget.apps.form.model.Form; import org.joget.apps.form.service.FormService; import org.joget.apps.form.service.FormUtil; AppService appService = (AppService) AppUtil.getApplicationContext().getBean("appService"); FormDefinitionDao formDefinitionDao = (FormDefinitionDao) AppUtil.getApplicationContext().getBean("formDefinitionDao"); FormService formService = (FormService) AppUtil.getApplicationContext().getBean("formService"); String id = "crm_account"; String appId = "crm"; Long appVersion = appService.getPublishedVersion(appId); AppDefinition appDef = appService.getAppDefinition(appId, appVersion.toString()); FormDefinition formDef = formDefinitionDao.loadById(formId, appDef); if (formDef != null) { //create the form Form form = (Form) formService.createElementFromJson(formDef.getJson(), true); //Find an element by field id Element e = FormUtil.findElement("accountName", form, null); }
public static final java.lang.String FORM_BUILDER_ACTIVE = "formBuilderActive";
Key used to sets the request attribute to indicate the current request is from form builder.
public static final java.lang.String FORM_ERRORS_PARAM = "_FORM_ERRORS";
Key used to passes the form errors to the next submission for comparison.
public static final java.lang.String FORM_META_ORIGINAL_ID = "_FORM_META_ORIGINAL_ID";
Key used to stores the form record id in a hidden field of a form
public static final java.lang.String FORM_RESULT_LOAD_ALL_DATA = "FORM_RESULT_LOAD_ALL_DATA";
Key used by Multi Paged Form to loads all the data from child forms.
public static final java.lang.String PROPERTY_CLASS_NAME = "className";
Key used to retrieves class name from properties
public static final java.lang.String PROPERTY_CUSTOM_PROPERTIES = "customProperties";
Prefix for a form id used to builds Hibernate Query (HQL) conditions
public static final java.lang.String PROPERTY_DATE_CREATED = "dateCreated";
Key used to stores created data of a record
public static final java.lang.String PROPERTY_DATE_MODIFIED = "dateModified";
Key used to stores modified data of a record
public static final java.lang.String PROPERTY_ELEMENT_UNIQUE_KEY = "elementUniqueKey";
Key used to to store a unique running number for element in properties
public static final java.lang.String PROPERTY_ELEMENTS = "elements";
Key used to retrieves child elements for an element in json
public static final java.lang.String PROPERTY_FORM_DEF_ID = "formdefid";
Key used to retrieves form definition id from properties
public static final java.lang.String PROPERTY_GROUPING = "grouping";
Key used to retrieves grouping from properties
public static final java.lang.String PROPERTY_ID = "id";
Key used to retrieves id from properties
public static final java.lang.String PROPERTY_LABEL = "label";
Key used to retrieves label from properties
public static final java.lang.String PROPERTY_OPTIONS = "options";
Key used to retrieves options from properties
public static final java.lang.String PROPERTY_OPTIONS_DELIMITER = ";";
Delimiter used to separate options
public static final java.lang.String PROPERTY_POST_PROCESSOR = "postProcessor";
Key used to retrieves post processor tool from properties
public static final java.lang.String PROPERTY_POST_PROCESSOR_RUN_ON = "postProcessorRunOn";
Key used to retrieves running mode of a post processor from properties
public static final java.lang.String PROPERTY_PROPERTIES = "properties";
Key used to retrieves element properties from json
public static final java.lang.String PROPERTY_READONLY = "readonly";
Key used to retrieves readonly from properties
public static final java.lang.String PROPERTY_READONLY_LABEL = "readonlyLabel";
Key used to retrieves display readonly as label from properties
public static final java.lang.String PROPERTY_SELECTED = "selected";
Key used to retrieves selected from properties
public static final java.lang.String PROPERTY_TABLE_NAME = "tableName";
Key used to retrieves table name from json
public static final java.lang.String PROPERTY_TEMP_FILE_PATH = "_tempFilePathMap";
Key used to stores the paths of uploaded temporary files
public static final java.lang.String PROPERTY_VALIDATOR = "validator";
Key used to retrieves validator from json
public static final java.lang.String PROPERTY_VALUE = "value";
Key used to retrieves value from properties
public static void clearProcessedFormJson()
Used by system to clears the current processing form json in current thread
public static org.joget.apps.form.model.FormData executeActions(org.joget.apps.form.model.Form form, org.joget.apps.form.model.Element element, org.joget.apps.form.model.FormData formData)
Utility method to recursively find and invoke actions starting from an element.
public static org.joget.apps.form.model.FormData executeElementFormatData(org.joget.apps.form.model.Element element, org.joget.apps.form.model.FormData formData)
Utility method to recursively find and invoke the formatData method starting from an element.
Return a java.util.Map mapping a binder to FormRowSets containing formatted values from all elements.
public static org.joget.apps.form.model.FormData executeElementFormatDataForValidation(org.joget.apps.form.model.Element element, org.joget.apps.form.model.FormData formData)
Utility method to recursively find and invoke the formatDataForValidation method starting from an element.
public static org.joget.apps.form.model.FormData executeLoadBinders(org.joget.apps.form.model.Element element, org.joget.apps.form.model.FormData formData)
Utility method to recursively traverse and invoke load binders starting from an element.
public static org.joget.apps.form.model.FormData executeOptionBinders(org.joget.apps.form.model.Element element, org.joget.apps.form.model.FormData formData)
Utility method to recursively find and invoke option binders starting from an element.
public static void executePostFormSubmissionProccessor(org.joget.apps.form.model.Form form, org.joget.apps.form.model.FormData formData)
Utility methods to execute tool after form submission
public static boolean executeValidators(org.joget.apps.form.model.Element element, org.joget.apps.form.model.FormData formData)
Utility method to recursively find and invoke validators starting from an element.
public static org.joget.apps.form.model.Element findAndParseElement(java.lang.String json, java.lang.String fieldId)
Finds and parses the form field element from form json by field id
public static org.joget.apps.form.model.Element findAndParseElementFromJsonObject(org.json.JSONObject obj, java.lang.String fieldId) throws java.lang.Exception
Finds and parses the form field element from form json object by field id
public static org.joget.apps.form.model.Element findElement(java.lang.String id, org.joget.apps.form.model.Element rootElement, org.joget.apps.form.model.FormData formData)
Utility method to recursively find an element by ID.
public static org.joget.apps.form.model.Element findElement(java.lang.String id, org.joget.apps.form.model.Element rootElement, org.joget.apps.form.model.FormData formData, java.lang.Boolean includeSubForm)
Utility method to recursively find an element by ID.
public static org.joget.apps.form.model.FormLoadBinder findLoadBinder(org.joget.apps.form.model.Element element)
Utility method to recursively find the nearest ancestor load binder for an element.
public static org.joget.apps.form.model.FormLoadBinder findOptionsBinder(org.joget.apps.form.model.Element element)
Utility method to recursively find the nearest ancestor options binder for an element.
public static org.joget.apps.form.model.Form findRootForm(org.joget.apps.form.model.Element element)
Utility method to recursively find the parent Form for an element.
public static org.joget.apps.form.model.FormStoreBinder findStoreBinder(org.joget.apps.form.model.Element element)
Utility method to recursively find the nearest ancestor store binder for an element.
public static java.lang.String generateDefaultForm(java.lang.String formId, org.joget.apps.app.model.FormDefinition formDef)
Utility method used to creates a new form definition json
public static java.lang.String generateDefaultForm(java.lang.String formId, org.joget.apps.app.model.FormDefinition formDef, org.joget.apps.app.model.FormDefinition copyFormDef)
Utility method used to creates a new form definition json based on another form definition
public static java.util.Map generateDefaultTemplateDataModel(org.joget.apps.form.model.Element element, org.joget.apps.form.model.FormData formData)
Generates a standard map of data to be used within an element template.
public static java.lang.String generateElementHtml(final org.joget.apps.form.model.Element element, final org.joget.apps.form.model.FormData formData, final java.lang.String templatePath, java.util.Map dataModel)
Generates HTML output using a FreeMarker template.
public static java.lang.String generateElementJson(org.joget.apps.form.model.Element element) throws java.lang.Exception
Generates JSON representing an element.
public static org.json.JSONObject generateElementJsonObject(org.joget.apps.form.model.Element element) throws java.lang.Exception
Generates a JSONObject to represent an element
public static java.lang.String generateElementMetaData(org.joget.apps.form.model.Element element)
Generates the HTML tag meta data for the element that is used by the form builder.
public static java.lang.String generateElementPropertyJson(org.joget.apps.form.model.Element element)
Generates JSON representing the properties of an element.
public static java.lang.String generateElementPropertyValues(java.lang.String[] values)
Generates a delimited string from an array of Strings.
public static org.json.JSONObject generatePropertyJsonObject(Map<java.lang.String, java.lang.Object> properties) throws org.json.JSONException
Generates a org.json.JSONObject to represent the properties of an element
public static org.joget.apps.form.model.FormRowSet getAjaxOptionsBinderData(java.lang.String dependencyValue, org.joget.apps.app.model.AppDefinition appDef, java.lang.String nonce, java.lang.String binderData)
Gets data from Options Binder for AJAX call
public static org.springframework.context.ApplicationContext getApplicationContext()
Utility method to retrieve the ApplicationContext of the system
public static java.lang.String getElementError(org.joget.apps.form.model.Element element, org.joget.apps.form.model.FormData formData)
Retrieve the error attached to the element
public static java.lang.String getElementParameterName(org.joget.apps.form.model.Element element)
Returns the parameter name for the element.
public static java.lang.String getElementProcessedJson(org.joget.apps.form.model.Element element)
Utility method to convert an element to json
public static java.util.Collection<java.util.Map> getElementPropertyOptionsMap(org.joget.apps.form.model.Element element, org.joget.apps.form.model.FormData formData)
Retrieves the property options for an element, first from the element's options binder. If no binder is available, the default options are used.
public static java.lang.String getElementPropertyValue(org.joget.apps.form.model.Element element, org.joget.apps.form.model.FormData formData)
Retrieves the property value for an element, first from the element's load binder. If no binder is available, the default value is used.
Overrides the binder/default value when value from request parameter is available.
public static java.lang.String[] getElementPropertyValues(org.joget.apps.form.model.Element element, org.joget.apps.form.model.FormData formData)
Retrieves the property value for an element, first from the element's load binder. If no binder is available, the default value is used.
Overrides the binder/default value when value from request parameter is available.
This method supports multiple values for a property.
public static java.lang.String getElementValidatorDecoration(org.joget.apps.form.model.Element element, org.joget.apps.form.model.FormData formData)
Retrieve a decoration on an element by any attached validator, e.g. marking a required field.
public static java.util.Collection<java.util.Map<java.lang.String, java.lang.String>> getFormColumns(org.joget.apps.app.model.AppDefinition appDef, java.lang.String formId)
Retrieve all form fields id & label in form data table
public static java.lang.String getProcessedFormJson()
Used by system to gets the current processing form json in current thread
public static java.lang.String getRequestParameter(org.joget.apps.form.model.Element element, org.joget.apps.form.model.FormData formData)
Returns the request parameter value for an element
public static java.lang.String[] getRequestParameterValues(org.joget.apps.form.model.Element element, org.joget.apps.form.model.FormData formData)
Returns the request parameter value for an element
public static java.lang.String getUniqueKey()
Gets a running number a unique key
public static boolean isAjaxOptionsSupported(org.joget.apps.form.model.Element element, org.joget.apps.form.model.FormData formData)
Check the element is using Ajax to load options
public static boolean isElementPropertyValuesChanges(org.joget.apps.form.model.Element element, org.joget.apps.form.model.FormData formData, java.lang.String[] updatedValues)
Utility methods to check the value of an element is changed
public static boolean isFormBuilderActive()
Check whether request is currently in the form builder.
public static boolean isFormSubmitted(org.joget.apps.form.model.Element element, org.joget.apps.form.model.FormData formData)
Check a form is submitted or not
public static boolean isReadonly(org.joget.apps.form.model.Element element, org.joget.apps.form.model.FormData formData)
Check an element is readonly or not
public static java.util.Map<java.lang.String, java.lang.Object> loadFormData(final java.lang.String appId, final java.lang.String appVersion, final java.lang.String formDefId, final java.lang.String primaryKeyValue, final boolean includeSubformData, final boolean includeReferenceElements, final boolean flatten, final org.joget.workflow.model.WorkflowAssignment assignment)
Utility method to fetch submitted form data values including data from subforms, and reference fields.
Returns a key-value pair (optionally flattened) for all the data that is part of a form submission.
The returned data includes top level form data, subform data (including recursive subforms), and data pointed by reference fields (like SelectBox pointing to a datalist item)
Parameters:
includeSubformData - true to recursively include subform data
includeReferenceElements - true to include data from reference elements e.g. selectbox, etc.
flatten - true to flatten data into a one level key-value map
assignment - Optional workflow assignment (for assignment hash variables)
Return a java.util.Map<java.lang.String,Object> representing the form data. The key is the element ID, and the value is either a java.lang.String for an element value, java.util.Map<java.lang.String,Object> representing subform data, or java.util.Collection<java.util.Map<java.lang.String,Object>> for reference fields.
public static java.lang.String loadFormDataJson(java.lang.String appId, java.lang.String appVersion, java.lang.String formDefId, java.lang.String primaryKeyValue, boolean includeSubformData, boolean includeReferenceElements, boolean flatten, org.joget.workflow.model.WorkflowAssignment assignment) throws org.json.JSONException
Similar to loadFormData, returns results in JSON format.
public static org.joget.apps.form.model.FormBinder parseBinderFromJsonObject(org.json.JSONObject obj, org.joget.apps.form.model.Element element, java.lang.String binderType) throws java.lang.Exception
Parse binder object from element json object
public static void parseChildElementsFromJsonObject(org.json.JSONObject obj, org.joget.apps.form.model.Element parent) throws java.lang.Exception
Parse child elements from element json object
public static org.joget.apps.form.model.Element parseElementFromJson(java.lang.String json) throws java.lang.Exception
Parses form field element from the element json string
public static org.joget.apps.form.model.Element parseElementFromJsonObject(org.json.JSONObject obj, org.joget.apps.form.model.Element parent) throws java.lang.Exception
Parses form field element from the element json object
public static java.util.Map<java.lang.String, java.lang.Object> parsePropertyFromJsonObject(org.json.JSONObject obj) throws org.json.JSONException
Parses the properties attribute from a JSON object into a Map
public static org.joget.apps.form.model.Validator parseValidatorFromJsonObject(org.json.JSONObject obj) throws java.lang.Exception
Parse validator object from element json object
public static void setAjaxOptionsElementProperties(org.joget.apps.form.model.Element element, org.joget.apps.form.model.FormData formData)
Sets security data for multi options element which using Ajax call to load options
public static void setFormBuilderActive(java.lang.Boolean active)
Sets flag in request to indicate whether is currently in the form builder.
public static void setProcessedFormJson(java.lang.String json)
Used by system to sets the current processing form json in current thread
public static void setReadOnlyProperty(org.joget.apps.form.model.Element element)
Recursively set the readonly property for all descendent elements.
public static void setReadOnlyProperty(org.joget.apps.form.model.Element element, java.lang.Boolean readonly, java.lang.Boolean label)
Recursively set the readonly property for all descendent elements.