Packageorg.servebox.toolbox.form
Classpublic class SmartForm
InheritanceSmartForm Inheritance 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



Public Properties
 PropertyDefined 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
Protected Properties
 PropertyDefined by
  _requiredIndicatorManager : RequiredIndicatorManager
SmartForm
Public Methods
 MethodDefined 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
  
Refreshes simple and complex renderers in read mode.
SmartForm
  
resetForm():void
Resets the form with original data.
SmartForm
  
SmartForm
  
switchToRead():void
Switches to read mode.
SmartForm
  
Switches to update mode.
SmartForm
Protected Methods
 MethodDefined 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
  
SmartForm
  
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
Events
 EventSummaryDefined 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
Styles
 StyleDescriptionDefined by
  
rendererPaddingTop
Type: Number
SmartForm
Public Constants
 ConstantDefined by
  READ_MODE : String = "READ_MODE"
[static]
SmartForm
  UPDATE_MODE : String = "UPDATE_MODE"
[static]
SmartForm
Property detail
handleNotMappedValuesproperty
public var 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. //TODO : When retrieving sources, the initial notMappedValues dictionary is appended to the source dictionary table

isAllFieldsValidproperty 
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
isReadproperty 
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
isUpdateproperty 
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
keepObjectInSourceproperty 
public var keepObjectInSource:Boolean = true

Specify this if you want to keep subObjet

matchPropertyproperty 
matchProperty:String  [read-only]Implementation
    public function get matchProperty():String
modeproperty 
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
notMappedValuesproperty 
notMappedValues:DictionaryTable  [read-only]

Gets all values that have not been mapped to ISmartFormElement on fillSmartFormElementsCatalog.

Implementation
    public function get notMappedValues():DictionaryTable
renderersproperty 
renderers:Array  [read-write]

An array of visual renderers for ISmartFormElements

Implementation
    public function get renderers():Array
    public function set renderers(value:Array):void
_requiredIndicatorManagerproperty 
protected var _requiredIndicatorManager:RequiredIndicatorManager
smartFormElementsCatalogproperty 
smartFormElementsCatalog:Dictionary  [read-only]

Gets all smartFormElements inside the form.

Implementation
    public function get smartFormElementsCatalog():Dictionary
sourceproperty 
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
toHideOnReadproperty 
public var toHideOnRead:Array

Element to hide on readMode

useNameAsMatchPropertyproperty 
public var useNameAsMatchProperty:Boolean

Use the name property in the SFElement istead of id Fix a common problem, where one of value objet property is "label"

validatorsproperty 
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
Constructor detail
SmartForm()constructor
public function SmartForm()

Creates a new SmartForm object.

Method detail
bindValuesInRenderer()method
protected function bindValuesInRenderer(complexRenderer:Container):void

Bindes all value in specific renderer.

Parameters
complexRenderer:Container
buildRendererElementsCatalog()method 
protected function buildRendererElementsCatalog(rendererElementsCatalog:Dictionary, container:Container = null):Dictionary

Retrieves all IsmartFormRenderer with id in the specific renderer.

Parameters
rendererElementsCatalog:Dictionary
 
container:Container (default = null)

Returns
Dictionary
buildSmartFormElementsCatalog()method 
protected function buildSmartFormElementsCatalog(container:Container = null):void

Recursively loops over all formElements and builds the _smartFormElementsCatalog. TODO : check for form structure alteration ( addChild / removeChild ), for relaunch buildSmartFormElementCatalog

Parameters
container:Container (default = null)
childrenCreated()method 
protected override function childrenCreated():void
clear()method 
public function clear():void

Clears all values in the SmartForm.

dispatchEvent()method 
public override function dispatchEvent(event:Event):Boolean

Dispatches an event. Debug purpose

Parameters
event:Event

Returns
Boolean
fillSmartFormElementsCatalog()method 
protected function fillSmartFormElementsCatalog(source:DictionaryTable):void

Fills the smartForm with the source. All non mapped values are stored in notMappedValues.

Parameters
source:DictionaryTable
getSourceAsBasicObject()method 
public function getSourceAsBasicObject(clazz:Class, subtypeMappingArray:Dictionary = null):IBasicObjectParameters
clazz:Class
 
subtypeMappingArray:Dictionary (default = null)

Returns
IBasicObject
getValueFromSource()method 
protected function getValueFromSource(src:DictionaryTable, key:String):IBasicObject

Extracts value inside the source by smartFormElement[matchProperty] ( should be a key of the source IBasicObject ).

Parameters
src:DictionaryTable
 
key:String

Returns
IBasicObject
hideElements()method 
protected function hideElements():void

Hides components wehn entering read mode.

modeChangeHandler()method 
protected function modeChangeHandler(event:Event = null):void

Handles the change of the mode

Parameters
event:Event (default = null)
readValuesFromSmartFormElementsCatalog()method 
protected function readValuesFromSmartFormElementsCatalog():DictionaryTable

Loops over all form elements and builds the new DictionaryTable.

Returns
DictionaryTable
refreshReadSmartFormElements()method 
public function refreshReadSmartFormElements():void

Refreshes simple and complex renderers in read mode.

resetForm()method 
public function resetForm():void

Resets the form with original data.

showElements()method 
protected function showElements():void

Shows components when exiting read mode.

smartFormElementChangeHandler()method 
public function smartFormElementChangeHandler(e:Event):voidParameters
e:Event
storeNotMappedValues()method 
protected function storeNotMappedValues(filledKeys:Array):void

Stores NotMappedValues.

Parameters
filledKeys: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():void

Switches the form to update Mode.

switchToRead()method 
public function switchToRead():void

Switches to read mode.

switchToUpdate()method 
public function switchToUpdate():void

Switches to update mode.

validationChange()method 
protected function validationChange(e:Event):void

Forwards VALID/INVALID validator event to SmartForm.

Parameters
e:Event
Event detail
org.servebox.toolbox.form.event.SmartFormEventevent 

dispatch when a sub SmartFormElement change

org.servebox.toolbox.form.event.SmartFormEventevent  

dispacth when form state change

org.servebox.toolbox.form.event.SmartFormEventevent  

dispatched when source to forms elements mapping is done

org.servebox.toolbox.form.event.SmartFormEventevent  

dispatched when all ISmartFormElement are referenced

org.servebox.toolbox.form.event.SmartFormEventevent  

dispatched when user clear the form

org.servebox.toolbox.form.event.SmartFormEventevent  

dispacth when renderers are refreshed

Constant detail
READ_MODEconstant
public static const READ_MODE:String = "READ_MODE"
UPDATE_MODEconstant 
public static const UPDATE_MODE:String = "UPDATE_MODE"