Class fvaswing.components.FvForm

Description

Builds data forms.

Take a look at fvaswing.components.forms package to see built-in form field alvailable in Fever.

All fields must be added before appending form onto other component.
Otherwise, addField() method throws a RuntimeException exceptions.

In case that a field is not valid, tooltip text is available in label object to notice user where is his error.
Same technic for required field.

Form's data can be saved onto client's computer using the Fever application dedicated sharedobject. ( see save() method.

Example

   var container : Container = new JPanel( new BorderLayout( 5,5 ) );
   var nameField : FvStringField = new FvStringField( "Name", 1 );
   var surnameField : FvStringField = new FvStringField( "Surname", 1, 4 );
   var messageField : FvStringAreaField = new FvStringAreaField( "Message" );
   var emailField : FvEmailField = new FvEmailField( "Email" );
   var agreeField : FvCheckboxField = new FvCheckboxField( "I agree", true );
   
   var pollBox : FvCheckPollField = new FvCheckPollField( "Your hobbies" );
   pollBox.addChoice( "basket-ball" );
   pollBox.addChoice( "actionscript" );
   
   var passField : FvPasswordField = new FvPasswordField( "Password", 6, 10 );
   
   var pollRadio : FvRadioPollField = new FvRadioPollField( "Your opinion", true );
   pollRadio.addChoice( "bad" );
   pollRadio.addChoice( "execellent" );
   
   var form : FvForm = new FvForm( "myForm" );
   form.addField( nameField );
   form.addField( surnameField );
   form.addField( messageField );
   
   container.append( form, BorderLayout.CENTER );
 

You can customize render validation state using setRenderStateHandler() method.
2 ways to the job :

Field Index

CONFIG_ID, ERROR_FIELD_SUFFIX, REQUIRED_FIELD_SUFFIX

Method Index

new FvForm()
addField(), clear(), getField(), isEmpty(), isFormDataValid(), load(), save(), setRenderStateHandler(), toString()

Constructor Detail

FvForm

public function FvForm(formName:String)

Constructor.

Parameters

formNameA simple string to allow load / save actions on form.
If formName is undefined, form can't be loaded / saved from client sharedobject.

Field Detail

REQUIRED_FIELD_SUFFIX

static public REQUIRED_FIELD_SUFFIX:String
Constant.
Defines suffix sub string for required field type.
Added to field caption.
Default is '(*)'

ERROR_FIELD_SUFFIX

static public ERROR_FIELD_SUFFIX:String
Constant.
Defines suffix sub string for validation error in field.
Added to field caption.
Default is '(?)'

CONFIG_ID

static public CONFIG_ID:String [Read Only]
Property name identifier for sharedObject saving.
All forms are saved under this object name.

Method Detail

setRenderStateHandler

public function setRenderStateHandler(scopeMethod, renderingMethod:Function):Void

Delegates field state rendering to passed-in renderingMethod function.

Parameters

scopeMethodContext where function is call.
renderingMethodFunction implementation to render field state

addField

public function addField(field:FvFormField, registrationID:String):String

Adds passed-in FvFormField into form.

Add all your fields before append form onto other component.

Parameters

fieldFvFormField to add
registrationID( optional ) Allow load / save process using registrationID data name.
If not defined, use the field label property, but if you use Localisation API, field's label can change, so you must specify a explicit registrationID

getField

public function getField(registrationID:String):FvFormField

Returns FvFormField registred into form with passed-in registrationID.

Parameters

registrationIDField identifier ( defined using addField() method.

isEmpty

public function isEmpty():Boolean

Returns true if form contains no field.

clear

public function clear():Void

Clears all fields value.

isFormDataValid

public function isFormDataValid():Boolean

Returns true if all form fields are valid.

Depends of field properties.

load

public function load():Void

Loads form's data from local SharedObject.

Forms's data must be saved using save() method in order to be loaded.

Retreives SharedObject info using CONFIG_ID name identifer and the form's name ( defined in contructor argument ).

save

public function save():Void

Saves forms data into client's sharedobject.

Form must have a valid name, defined by the form constructor.

All forms are saved under CONFIG_ID object in application sharedobject.

toString

public function toString():String

Returns string representation.