| Package | org.servebox.toolbox.form |
| Class | public class SmartForm |
| Inheritance | SmartForm mx.containers.Form |
SmartForm is designed for creating and maintaining Form.
SmartForm control provides the following features:
- Bind all property of an DictionaryTable on form elements ( ISmartFormElement ) on the id property, for editing purpose
- Bind all property of an DictionaryTable on form elements ( ISmartFormElement) on the id property, for reading purpose
- Make a DictionaryTable reading all property from form elements.
- Clear all values in form
For using the SmartForm, all form elements must be place in FormItems, all form elements
must implements ISmartFormElements ( such as SFTextInput, SFComboBox , etc... )
eg:
<mx:FormItem label="Comments">
<elements:SFTextArea id="comment" width="300" height="100"/>
</mx:FormItem>
<mx:FormItem label="Birthday">
<elements:SFDateField id="birthDate" dateFormatter="{frdf}"/>
</mx:FormItem>
The Following code sample shows a SmartForm implementation
<form:SmartForm
id="smartForm"
width="100%"
height="100%"
mode="{SmartForm.READ_MODE}"
source="{formSource}"
backgroundColor="#FFFFFF"
borderColor="#000000"
borderThickness="1"
validators="{vl}"
borderStyle="solid">
See also
org.servebox.commons.map.DictionaryTable
org.servebox.toolbox.form.elements
org.servebox.toolbox.form.elements.ISmartFormElement
| Property | Defined by | ||
|---|---|---|---|
| handleNotMappedValues : Boolean = true
When handleNotMappedValues is set to true, all key-value pairs in the source dictionary table
that have not been mapped to a form element are stored in notMappedValues.
| SmartForm | ||
| isAllFieldsValid : Boolean [read-only]
Returns true if all validators in form are VALID
| SmartForm | ||
| isRead : Boolean [read-only]
Returns true if the form is in READ_MODE.
| SmartForm | ||
| isUpdate : Boolean [read-only]
Returns true is the form is in UPDATE_MODE.
| SmartForm | ||
| keepObjectInSource : Boolean = true
Specify this if you want to keep subObjet
| SmartForm | ||
| matchProperty : String [read-only]
| SmartForm | ||
| mode : String
Returns the SmartForm current mode ( default is UPDATE_MODE ).
| SmartForm | ||
| notMappedValues : DictionaryTable
[read-only]
Gets all values that have not been mapped to ISmartFormElement on fillSmartFormElementsCatalog.
| SmartForm | ||
| renderers : Array
An array of visual renderers for ISmartFormElements
| SmartForm | ||
| smartFormElementsCatalog : Dictionary [read-only]
Gets all smartFormElements inside the form.
| SmartForm | ||
| source : DictionaryTable
Sets/Gets the values for form filling / reading / updating.
| SmartForm | ||
| toHideOnRead : Array
Element to hide on readMode
| SmartForm | ||
| useNameAsMatchProperty : Boolean
Use the name property in the SFElement istead of id
Fix a common problem, where one of value objet property is "label"
| SmartForm | ||
| validators : Array
An array of Validator for the SmartForm.
| SmartForm | ||
| Property | Defined by | ||
|---|---|---|---|
| _requiredIndicatorManager : RequiredIndicatorManager | SmartForm | ||
| Method | Defined by | ||
|---|---|---|---|
|
Creates a new SmartForm object.
| SmartForm | ||
|
clear():void
Clears all values in the SmartForm.
| SmartForm | ||
|
dispatchEvent(event:Event):Boolean
Dispatches an event.
| SmartForm | ||
|
getSourceAsBasicObject(clazz:Class, subtypeMappingArray:Dictionary = null):IBasicObject
| SmartForm | ||
|
refreshReadSmartFormElements():void
Refreshes simple and complex renderers in read mode.
| SmartForm | ||
|
resetForm():void
Resets the form with original data.
| SmartForm | ||
|
smartFormElementChangeHandler(e:Event):void
| SmartForm | ||
|
switchToRead():void
Switches to read mode.
| SmartForm | ||
|
switchToUpdate():void
Switches to update mode.
| SmartForm | ||
| Method | Defined by | ||
|---|---|---|---|
|
bindValuesInRenderer(complexRenderer:Container):void
Bindes all value in specific renderer.
| SmartForm | ||
|
buildRendererElementsCatalog(rendererElementsCatalog:Dictionary, container:Container = null):Dictionary
Retrieves all IsmartFormRenderer with id in the specific renderer.
| SmartForm | ||
|
buildSmartFormElementsCatalog(container:Container = null):void
Recursively loops over all formElements and builds the _smartFormElementsCatalog.
| SmartForm | ||
|
childrenCreated():void
| SmartForm | ||
|
fillSmartFormElementsCatalog(source:DictionaryTable):void
Fills the smartForm with the source.
| SmartForm | ||
|
Extracts value inside the source by smartFormElement[matchProperty] ( should be a key of the source IBasicObject ).
| SmartForm | ||
|
hideElements():void
Hides components wehn entering read mode.
| SmartForm | ||
|
modeChangeHandler(event:Event = null):void
Handles the change of the mode
| SmartForm | ||
|
Loops over all form elements and builds the new DictionaryTable.
| SmartForm | ||
|
showElements():void
Shows components when exiting read mode.
| SmartForm | ||
|
storeNotMappedValues(filledKeys:Array):void
Stores NotMappedValues.
| SmartForm | ||
|
Switches to "read" mode :
- append renderers into the form, - hide FormItem instances to let complex renderers display correctly or hide the form to place a simple renderer | SmartForm | ||
|
Switches the form to update Mode.
| SmartForm | ||
|
validationChange(e:Event):void
Forwards VALID/INVALID validator event to SmartForm.
| SmartForm | ||
| Event | Summary | Defined by | ||
|---|---|---|---|---|
| dispatch when a sub SmartFormElement change | SmartForm | |||
| dispacth when form state change | SmartForm | |||
| dispatched when source to forms elements mapping is done | SmartForm | |||
| dispatched when all ISmartFormElement are referenced | SmartForm | |||
| dispatched when user clear the form | SmartForm | |||
| dispacth when renderers are refreshed | SmartForm | |||
| Constant | Defined by | ||
|---|---|---|---|
| READ_MODE : String = "READ_MODE" [static]
| SmartForm | ||
| UPDATE_MODE : String = "UPDATE_MODE" [static]
| SmartForm | ||
| handleNotMappedValues | property |
public var handleNotMappedValues:Boolean = trueWhen handleNotMappedValues is set to true, all key-value pairs in the source dictionary table that have not been mapped to a form element are stored in notMappedValues. //TODO : When retrieving sources, the initial notMappedValues dictionary is appended to the source dictionary table
| isAllFieldsValid | property |
isAllFieldsValid:Boolean [read-only]Returns true if all validators in form are VALID
This property can be used as the source for data binding.
Implementation public function get isAllFieldsValid():Boolean
| isRead | property |
isRead:Boolean [read-only]Returns true if the form is in READ_MODE.
This property can be used as the source for data binding.
Implementation public function get isRead():Boolean
| isUpdate | property |
isUpdate:Boolean [read-only]Returns true is the form is in UPDATE_MODE.
This property can be used as the source for data binding.
Implementation public function get isUpdate():Boolean
| keepObjectInSource | property |
public var keepObjectInSource:Boolean = trueSpecify this if you want to keep subObjet
| matchProperty | property |
matchProperty:String [read-only]Implementation
public function get matchProperty():String
| mode | property |
mode:String [read-write]Returns the SmartForm current mode ( default is UPDATE_MODE ).
Implementation public function get mode():String
public function set mode(value:String):void
| notMappedValues | property |
notMappedValues:DictionaryTable [read-only]Gets all values that have not been mapped to ISmartFormElement on fillSmartFormElementsCatalog.
Implementation public function get notMappedValues():DictionaryTable
| renderers | property |
renderers:Array [read-write]An array of visual renderers for ISmartFormElements
Implementation public function get renderers():Array
public function set renderers(value:Array):void
| _requiredIndicatorManager | property |
protected var _requiredIndicatorManager:RequiredIndicatorManager
| smartFormElementsCatalog | property |
smartFormElementsCatalog:Dictionary [read-only]Gets all smartFormElements inside the form.
Implementation public function get smartFormElementsCatalog():Dictionary
| source | property |
source:DictionaryTable [read-write]Sets/Gets the values for form filling / reading / updating.
Implementation public function get source():DictionaryTable
public function set source(value:DictionaryTable):void
| toHideOnRead | property |
public var toHideOnRead:ArrayElement to hide on readMode
| useNameAsMatchProperty | property |
public var useNameAsMatchProperty:BooleanUse the name property in the SFElement istead of id Fix a common problem, where one of value objet property is "label"
| validators | property |
validators:Array [read-write]An array of Validator for the SmartForm.
This property can be used as the source for data binding.
Implementation public function get validators():Array
public function set validators(value:Array):void
| SmartForm | () | constructor |
public function SmartForm()Creates a new SmartForm object.
| bindValuesInRenderer | () | method |
protected function bindValuesInRenderer(complexRenderer:Container):voidBindes all value in specific renderer.
ParameterscomplexRenderer:Container |
| buildRendererElementsCatalog | () | method |
protected function buildRendererElementsCatalog(rendererElementsCatalog:Dictionary, container:Container = null):DictionaryRetrieves all IsmartFormRenderer with id in the specific renderer.
ParametersrendererElementsCatalog:Dictionary |
|
container:Container (default = null) |
Dictionary |
| buildSmartFormElementsCatalog | () | method |
protected function buildSmartFormElementsCatalog(container:Container = null):voidRecursively loops over all formElements and builds the _smartFormElementsCatalog. TODO : check for form structure alteration ( addChild / removeChild ), for relaunch buildSmartFormElementCatalog
Parameterscontainer:Container (default = null) |
| childrenCreated | () | method |
protected override function childrenCreated():void
| clear | () | method |
public function clear():voidClears all values in the SmartForm.
| dispatchEvent | () | method |
public override function dispatchEvent(event:Event):BooleanDispatches an event. Debug purpose
Parametersevent:Event |
Boolean |
| fillSmartFormElementsCatalog | () | method |
protected function fillSmartFormElementsCatalog(source:DictionaryTable):voidFills the smartForm with the source. All non mapped values are stored in notMappedValues.
Parameterssource:DictionaryTable |
| getSourceAsBasicObject | () | method |
public function getSourceAsBasicObject(clazz:Class, subtypeMappingArray:Dictionary = null):IBasicObjectParameters
clazz:Class |
|
subtypeMappingArray:Dictionary (default = null) |
IBasicObject |
| getValueFromSource | () | method |
protected function getValueFromSource(src:DictionaryTable, key:String):IBasicObjectExtracts value inside the source by smartFormElement[matchProperty] ( should be a key of the source IBasicObject ).
Parameterssrc:DictionaryTable |
|
key:String |
IBasicObject |
| hideElements | () | method |
protected function hideElements():voidHides components wehn entering read mode.
| modeChangeHandler | () | method |
protected function modeChangeHandler(event:Event = null):voidHandles the change of the mode
Parametersevent:Event (default = null) |
| readValuesFromSmartFormElementsCatalog | () | method |
protected function readValuesFromSmartFormElementsCatalog():DictionaryTableLoops over all form elements and builds the new DictionaryTable.
ReturnsDictionaryTable |
| refreshReadSmartFormElements | () | method |
public function refreshReadSmartFormElements():voidRefreshes simple and complex renderers in read mode.
| resetForm | () | method |
public function resetForm():voidResets the form with original data.
| showElements | () | method |
protected function showElements():voidShows components when exiting read mode.
| smartFormElementChangeHandler | () | method |
public function smartFormElementChangeHandler(e:Event):voidParameters
e:Event |
| storeNotMappedValues | () | method |
protected function storeNotMappedValues(filledKeys:Array):voidStores NotMappedValues.
ParametersfilledKeys:Array |
| switchSmartFormElementsToReadMode | () | method |
protected function switchSmartFormElementsToReadMode():void
Switches to "read" mode :
- append renderers into the form,
- hide FormItem instances to let complex renderers display correctly or hide the form to place a simple renderer
| switchSmartFormElementsToUpdateMode | () | method |
protected function switchSmartFormElementsToUpdateMode():voidSwitches the form to update Mode.
| switchToRead | () | method |
public function switchToRead():voidSwitches to read mode.
| switchToUpdate | () | method |
public function switchToUpdate():voidSwitches to update mode.
| validationChange | () | method |
protected function validationChange(e:Event):voidForwards VALID/INVALID validator event to SmartForm.
Parameterse:Event |
| org.servebox.toolbox.form.event.SmartFormEvent | event |
dispatch when a sub SmartFormElement change
| org.servebox.toolbox.form.event.SmartFormEvent | event |
dispacth when form state change
| org.servebox.toolbox.form.event.SmartFormEvent | event |
dispatched when source to forms elements mapping is done
| org.servebox.toolbox.form.event.SmartFormEvent | event |
dispatched when all ISmartFormElement are referenced
| org.servebox.toolbox.form.event.SmartFormEvent | event |
dispatched when user clear the form
| org.servebox.toolbox.form.event.SmartFormEvent | event |
dispacth when renderers are refreshed
| READ_MODE | constant |
public static const READ_MODE:String = "READ_MODE"
| UPDATE_MODE | constant |
public static const UPDATE_MODE:String = "UPDATE_MODE"