Date: Thu, 28 Mar 2024 21:07:37 +0000 (UTC) Message-ID: <1407767281.140218.1711660057473@ip-10-0-0-39.us-west-2.compute.internal> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_140217_1349616394.1711660057469" ------=_Part_140217_1349616394.1711660057469 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
A useable Form Field Element plugin must extends org.joget.apps.form= .model.Element abstract class and implements org.joge= t.apps.form.model.FormBuilderPaletteElement interface.
Under wflow-core module
Extended org.joget.plugin.base.ExtDefaultPlugin. Please refer t= o Plugin Base Abstract Class and Interface.
Implemented org.joget.plugin.property.model.PropertyEditable. P= lease refer to Plugin Base Abstract Class and Interface.
A base abstract class to develop a Form Field Element plugin. <= /p>
All forms, containers and form fields must extend this class.
public abstract java.lang.String render= Template(org.joget.apps.form.model.FormData formData, java.util.Map dataMod= el)
HTML template for front-end UI.
Parameters:
dataModel - Model contai= ning values to be displayed in the template.
public org.joget.apps.form.model.FormRo= wSet formatData(org.joget.apps.form.model.FormData formData)
Method that retrieves loaded or submitted= form data, and formats it for a store binder. The formatted data is t= o be stored and returned in a FormRowSet.
public org.joget.apps.form.model.FormDa= ta formatDataForValidation(org.joget.apps.form.model.FormData formData)Method for override to perform format dat= a in request parameter before execute validation
selfValidate
public java.lang.Boolean selfValidate(o= rg.joget.apps.form.model.FormData formData)Method for override to perform specify va= lidation for this field.
Error message can display with following = code:
String id =3D FormUtil.getElementParame= terName(this);formData.addFormError(id, "Error!!");= pre>ren= der
public java.lang.String render(org.joge= t.apps.form.model.FormData formData, java.lang.Boolean includeMetaData)Render HTML template for UI, with option = for form builder design mode. This method will call abstract method&nb= sp;renderTemplate for rendering.
Parameters:
includeMetaData - set true to re= nder additional meta required for the Form Builder.
renderErrorTemplate
public java.lang.String renderErrorTemp= late(org.joget.apps.form.model.FormData formData, java.util.Map dataModel)<= /pre>HTML template with errors for front-end U= I. This method will call abstract method renderTemplate= strong> for rendering.
Parameters:
dataModel - Model containing values t= o be displayed in the template.
renderReadOnlyTemplate
public java.lang.String renderReadOnlyT= emplate(org.joget.apps.form.model.FormData formData, java.util.Map dataMode= l)Read-only HTML template for front-end UI = (Not used at the moment)
Parameters:
dataModel - Model containing values t= o be displayed in the template.
continueValidation
public boolean continueValidation(org.j= oget.apps.form.model.FormData formData)Flag to indicate whether or not continue = validating descendent elements.
getDynamicFieldNames
public Collection<java.lang.String&g= t; getDynamicFieldNames()Used to create multiple form data column = in database by returning extra column names.
h= asError
public java.lang.Boolean hasError(org.j= oget.apps.form.model.FormData formData)Flag to indicate whether or not this fiel= d has fail the validation process
isAuthorize
public java.lang.Boolean isAuthorize(or= g.joget.apps.form.model.FormData formData)Flag to indicate whether or not the curre= nt logged in user is authorized to view this field in the form.
It used property key "permission" to retr= ieve Form Permission plugin.
Utility Methods
getChildren
public java.util.Collection<org.joge= t.apps.form.model.Element> getChildren()Retrieves all children form field element= under this field
getChildren
public void setChildren(java.util.Colle= ction<org.joget.apps.form.model.Element> children)Retrieves all children form field element= under this field
setChildren
public void setChildren(java.util.Colle= ction<org.joget.apps.form.model.Element> children)Sets form fields as children of this fiel= d
= getParent
public org.joget.apps.form.model.Elemen= t getParent()Returns the immediate parent for this ele= ment.
= setParent
public void setParent(org.joget.apps.fo= rm.model.Element parent)Sets the immediate parent for this elemen= t.
getPrimaryKeyValue
public java.lang.String getPrimaryKeyVa= lue(org.joget.apps.form.model.FormData formData)Returns the primary key value for the cur= rent element. Defaults to the primary key value of the form.
getLoadBinder
public org.joget.apps.form.model.FormLo= adBinder getLoadBinder()Get load binder
setLoadBinder
public void setLoadBinder(org.joget.app= s.form.model.FormLoadBinder loadBinder)Set load binder
getOptionsBinder
public org.joget.apps.form.model.FormLo= adBinder getOptionsBinder()Gets an Options Binder
setOptionsBinder
public void setOptionsBinder(org.joget.= apps.form.model.FormLoadBinder optionsBinder)Sets an Options Binder
getStoreBinder
public org.joget.apps.form.model.FormSt= oreBinder getStoreBinder()Gets a Store Binder
setStoreBinder
public void setStoreBinder(org.joget.ap= ps.form.model.FormStoreBinder storeBinder)Sets a Store Binder
getValidator
public org.joget.apps.form.model.Valida= tor getValidator()Gets a validator
setValidator
public void setValidator(org.joget.apps= .form.model.Validator validator)Sets a validator
getCustomParameterName
public java.lang.String getCustomParame= terName()If non-null, this is to be used as the HT= ML input name for the element.
setCustomParameterName
public void setCustomParameterName(java= .lang.String customParameterName)Sets a custom parameter name for the HTML= input name of the element.
getDefaultPropertyValues
public java.lang.String getDefaultPrope= rtyValues()Set default Plugin Properties Options val= ue to a new added Field in Form Builder.
org.joget.apps.form.model.AbstractSubForm
Under wflow-core module
Extended org.joget.apps.form.model.Element.
Implemented org.joget.apps.form.model.FormContainer.
Use to develop a Form Field element which embed a Form as its child.=
Field Detail
Constants
PROPERTY_PARENT_SUBFORM_ID
public static final String PROPERTY_PAR= ENT_SUBFORM_ID =3D "parentSubFormId";Property key that use to retrieve the fie= ld id in parent form used to store subform primary key as reference key.&nb= sp;
PROPERTY_SUBFORM_PARENT_ID
public static final String PROPERTY_SUB= FORM_PARENT_ID =3D "subFormParentId";Property key that use to retrieve the field id in subform used to store = parent form primary key as foreign key.
Method Detail
Overridable Methods<= /h5>
loadSubForm
protected org.joget.apps.form.model.For= m loadSubForm(org.joget.apps.form.model.FormData parentFormData) throws org= .springframework.beans.BeansExceptionRetrieve a Form object a= s subform. This method will use either value from property key "formDefId" or "json" to construct th= e Form object.
updateElementParameterNames
protected void updateElementParameterNa= mes(org.joget.apps.form.model.Element element, java.lang.String prefix)Update all the parameter name of field el= ements in subform with a prefix
populateParentWithSubFormKey
protected void populateParentWithSubFor= mKey(org.joget.apps.form.model.FormData formData)Update parent form field value with prima= ry key of subform based on property key of this constant PROPERTY_PARENT_SUBFORM_ID.
populateSubFormWithParentKey
protected void populateSubFormWithParen= tKey(org.joget.apps.form.model.FormData formData)Update subform field value with primary k= ey of parent form based on property key of this constant PROPERTY_SUBFORM_PARENT_ID.
checkForRecursiveForm
protected boolean checkForRecursiveForm= (org.joget.apps.form.model.Element e, java.lang.String id)Check the subform is not exist in the par= ent elements tree.
getSubForm
protected org.joget.apps.form.model.For= m getSubForm(org.joget.apps.form.model.FormData formData)Get From object from its children.
Interface
org.joget.apps.form.model.FormBuilderPaletteElement
Under wflow-core module
Extends interface org.joget.apps.form.model.FormBuilderEditable= .
Interface that describes meta information used for adding an element= into the Form Builder palette.
Method Detail
Interface Methods
getFormBuilderCategory
public java.lang.String getFormBuilderC= ategory()Category for the element in the Form Buil= der palette
getFormBuilderPosition
public int getFormBuilderPosition()Ordering position. Palette to display bas= ed on the position value in ascending order for a category.
getFormBuilderIcon
public java.lang.String getFormBuilderI= con()Path to icon for the element in the Form = Builder palette. This path is relative to the context path. Return NULL&nbs= p;to use the default icon.
getDefaultPropertyValues
public jva.lang.String getDefaultProper= tyValues()Set default Plugin Properties Options val= ue to a new added Field in Form Builder. This method is implemented in org.joget= .apps.form.model.Element.
getFormBuilderTemplate
public java.lang.String getFormBuilderT= emplate()HTML template used for display a new adde= d field in the Form Builder
o= rg.joget.apps.form.model.FormContainer
Under wflow-core module
This interface indicate that a Form Field Element is a container and= should not create a form data column in database.
No interface method is available in this interface
org.joget.apps.form.model.FormOptionsElement
Under wflow-core module
This interface indicate that a Form Field Element is a multi options= field such as Select Box, Check Box & Radio Button. It can use Form Options Binder to pop= ulate its options.
No interface method is available in this interface
org.joget.apps.form.model.FormAjaxOptionsElement
Under wflow-core module
Extends interface org.joget.apps.form.model.FormOptionsEl= ement.
This interface indicate that a Form Field Element is a multi options= field such as Select Box, Check Box & Radio Button. It can use Form Options Binder= which implemented org.joget.apps.f= orm.model.FormAjaxOptionsBinder to populate its options using AJAX= .
Method Detail
Interface Methods
getControlElement
public org.joget.apps.form.model.Elemen= t getControlElement(org.joget.apps.form.model.FormData formData)Get dependent field element which use to = control the options of this field
org.joget.apps.form.model.FormReferenceDataRetriever
Under wflow-core module
Indicate that this field hold the primary keys for other form data r= ecords. The reference records can be retrieve using its interface method.= p>
This interface is used by org.joget.apps.form.service.FormUtil.loadFormData() and org.joget.apps.form.service.FormUt= il.loadFormDataJson() method to fetch submitted form data values includ= ing data from subforms, and reference fields.
Method Detail
Interface Methods
loadFormRows
public org.joget.apps.form.model.FormRo= wSet loadFormRows(String[] primaryKeyValues, org.joget.apps.form.model.Form= Data formData)Retrieve form data rows for an array of s= pecified primary key values.
Plugin Properties= Options
The following are some mandatory properties and system predefined pr= operties can be used in your Plugin Properties Options JSON file. Plea= se refer to Plugin Properties Options for more information.
Mandatory Property
id = ;
All Form Element Field must has this property appear in the Properti= es Options JSON.
This is used as unique identifier of a field in a form.
{ name : 'id', label : '@@form.textfield.id@@', type : 'textfield', required : 'True', regex_validation : '^[a-zA-Z0-9_]+$', validation_message : '@@form.textfield.invalidId@@' }Predefined Property &n= bsp;
loadBinder
If this property appear in the P= roperties Options JSON, admin user is able to choose a Form Load Binder.
The value of this property will auto = convert into Form Load Binder Plugin and the plugin can be retrieved by
getLoadBinder method. { name:'loadBinder', label:'@@form.subform.loadBinder@@', type:'elementselect', options_ajax:'[CONTEXT_PATH]/web/property/json/getElements?classnam= e=3Dorg.joget.apps.form.model.FormLoadElementBinder', url:'[CONTEXT_PATH]/web/property/json[APP_PATH]/getPropertyOptions'= , value:'org.joget.apps.form.lib.WorkflowFormBinder', required:'True' }optionsBinder
If this property appear in the P= roperties Options JSON, admin user is able to choose a Form Options Binder.=
The value of this property will auto = convert into Form Options Binder Plugin and the plugin can be retrieved by&= nbsp;getOptionsBinder method.
{ name : 'optionsBinder', label : '@@form.checkbox.chooseOptionsBinder@@', type : 'elementselect', options_ajax : '[CONTEXT_PATH]/web/property/json/getElements?classn= ame=3Dorg.joget.apps.form.model.FormLoadOptionsBinder', url : '[CONTEXT_PATH]/web/property/json[APP_PATH]/getPropertyOption= s' }permission
If this property appear in the P= roperties Options JSON, admin user is able to choose a Form Permission.
The value of this property will auto = convert into Form Permission Plugin and the plugin is used by isAuthorize method.
{ name:'permission', label:'@@form.form.permission@@', type:'elementselect', options_ajax:'[CONTEXT_PATH]/web/property/json/getElements?classnam= e=3Dorg.joget.apps.form.model.FormPermission', url:'[CONTEXT_PATH]/web/property/json[APP_PATH]/getPropertyOptions' }storeBinder
If this property appear in the P= roperties Options JSON, admin user is able to choose a Form Store Binder.= p>
The value of this property will auto = convert into Form Store Binder Plugin and the plugin can be retrieved by&nb= sp;getSoreBinder
method .{ name:'storeBinder', label:'@@form.form.storeBinder@@', type:'elementselect', options_ajax:'[CONTEXT_PATH]/web/property/json/getElements?classnam= e=3Dorg.joget.apps.form.model.FormStoreElementBinder', url:'[CONTEXT_PATH]/web/property/json[APP_PATH]/getPropertyOptions' }r= eadonly
System use this property to flag a fi= eld a readonly.
If this property appear in the&n= bsp;Properties Options JSON, admin user can force this field to display as = readonly.
This value is ignored if the parent f= orm is set to readonly
{ name : 'readonly', label : '@@form.checkbox.readonly@@', type : 'checkbox', value : 'false', options : [{ value : 'true', label : '' }] }readonlyLabel
System use this property to flag a fi= eld a readonly field should display as label or not.
If this property appear in the&n= bsp;Properties Options JSON, admin user can force this field to display as = label when it is readonly.
This value is ignored if the parent f= orm is set to display as label when it is readonly
{ name : 'readonlyLabel', label : '@@form.checkbox.readonlyLabel@@', type : 'checkbox', value : 'false', options : [{ value : 'true', label : '' }] }workflowVariable
If this property appear in the P= roperties Options JSON, admin user is set to store this field value to a wo= rkflow variable.
The value of this field will auto set= to the mentioned workflow variable if the Form Store Binder is set to = ;Default.
{ name : 'workflowVariable', label : '@@form.checkbox.workflowVariable@@', type : 'textfield' }valu= e
If this property appear in the P= roperties Options JSON, admin user is able to set a default value for this = field.
{ name : 'value', description : '@@form.checkbox.value.desc@@', label : 'Default @@form.checkbox.value@@', type : 'textfield' }= validator
If this property appear in the P= roperties Options JSON, admin user is able to choose a Form Validator.
The value of this property will auto = convert into Form Validator Plugin and the plugin can be retrieved by = getValidator method.
Form Field= Element Template Sample
Following is a sample Form Field Template of a Text Field element. It is constructed using F= reeMarker syntax. This template will be used and returned by renderTemplate method.@Ov= erride public String renderTemplate(FormData formData, Map dataModel) { String templateName =3D "textField.ftl"; // set value String value =3D FormUtil.getElementPropertyValue(this, formData); dataModel.put("value", value); String html =3D FormUtil.generateElementHtml(this, formData, templa= teName, dataModel); return html; }
<div = class=3D"form-cell" ${elementMetaData!}> <label class=3D"label"> ${element.properties.label} <span class=3D"form-cell-validator"&= gt;${decoration}</span> <#if error??> <span class=3D"form-error-message">${error}</span> </#if> </label> <#if (element.properties.readonly! =3D=3D 'true' && element.= properties.readonlyLabel! =3D=3D 'true') > <div class=3D"form-cell-value"><span>${value!?html}<= /span></div> <input id=3D"${elementParamName!}" name=3D"${elementParamName!}"= type=3D"hidden" value=3D"${value!?html}" /> <#else> <input id=3D"${elementParamName!}" name=3D"${elementParamName!}"= type=3D"text" size=3D"${element.properties.size!}" value=3D"${value!?html}= " maxlength=3D"${element.properties.maxlength!}" <#if error??>class= =3D"form-error-cell"</#if> <#if element.properties.readonly! =3D= =3D 'true'>readonly</#if> /> </#if> </div>Explanations
A form field element template should be wrapped under a div with "fo= rm-cell" class.
${elementMetaData!} need to put in the ".form-cell" div. It is used = by Form Builder.
A useable field element template must handle the following states of= a field.
- Has errors
- Readonly
- Readonly and needed to display as label
- Normal display
Tutorials
- Gu= ideline for developing a plugin
- File Upload Form Element Integrated with Amazon S3
- How to develop a Mood Rating Form Field
Related Community= Plugins
------=_Part_140217_1349616394.1711660057469--
- Check Box
org.joget.apps.form.lib.CheckBox (wflow-core)- Custom HTML
org.joget.apps.form.lib.CustomHTML (wflow-core)- Date Picker
org.joget.apps.form.lib.DatePicker (wflow-core)- File Upload
org.joget.apps.form.lib.FileUpload (wflow-core)- Grid
org.joget.apps.form.lib.Grid (wflow-core)- Hidden Field
org.joget.apps.form.lib.HiddenField (wflow-core)- Id Generator Field
org.joget.apps.form.lib.IdGeneratorField (wflow-core)- Password Field
org.joget.apps.form.lib.PasswordField (wflow-core)- Radio Button
org.joget.apps.form.lib.Radio (wflow-core)- Select Box
org.joget.apps.form.lib.SelectBox (wflow-core)- Subform
org.joget.apps.form.lib.SubForm (wflow-core)- Text Area
org.joget.apps.form.lib.TextArea (wflow-core)- Text Field
org.joget.apps.form.lib.TextField (wflow-core)