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 :
Example : setting rendering method for one field :
var passField : FvPasswordField = new FvPasswordField( "Password", 6, 10 ); passField.setRenderStateHandler( this, _renderValidationState );
Example : setting rendering method for entire form :
var form : FvForm = new FvForm(); form.setRenderStateHandler( this, _renderValidationState );
Sample rendering method :
private function _renderValidationState( captionLabel : JLabel, caption : String, preventLabel : JLabel, must : Boolean, valid : Boolean, msg : String ) : Void { if( valid ) { captionLabel.setForeground( UIManager.getColor( "TextField.foreground" ) ); if( must ) { preventLabel.setText( FvForm.REQUIRED_FIELD_SUFFIX ); preventLabel.setToolTipText( msg ); } else { preventLabel.setText(); preventLabel.setToolTipText(); } } else { captionLabel.setForeground( ASColor.RED ); preventLabel.setText( FvForm.ERROR_FIELD_SUFFIX ); preventLabel.setToolTipText( msg ); } }
new FvForm()static public REQUIRED_FIELD_SUFFIX:Stringstatic public ERROR_FIELD_SUFFIX:Stringstatic public CONFIG_ID:String [Read Only]public function setRenderStateHandler(scopeMethod, renderingMethod:Function):Void
Delegates field state rendering to passed-in renderingMethod function.
scopeMethod | Context where function is call. |
renderingMethod | Function implementation to render field state |
public function addField(field:FvFormField, registrationID:String):StringAdds passed-in FvFormField into form.
Add all your fields before append form onto other component.
field | FvFormField 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
|
public function getField(registrationID:String):FvFormField
Returns FvFormField registred into form
with passed-in registrationID.
registrationID | Field identifier ( defined using addField() method. |
public function isFormDataValid():Boolean
Returns true if all form fields are valid.
Depends of field properties.
public function save():VoidSaves 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.