The Form Service is used to represent form elements in a Virtual Form instead of a traditional HTML Form collection. Virtual Forms track values whether or not the backing element exists (or is rendered), and Virtual Form Elements may be aggregated as desired. With Application Spaces, Virtual Forms are aggregated at the space level.
An internal representation of a form element.
Returns the rendered HTML Form Element.
o = getElement( )
o as object: HTML Form Element
Returns true if the form elemnet is rendered.
b = getIsRendered( )
b as boolean: Bit indicating whether the element is rendered.
Returns the name of form element.
t = getName( )
t as String: The name of form element.
Returns the id of the underlying XHTMLComponent
i = getObjectId( )
i as String: The id of the XHTMLComponent.
Returns the id of the reference implementor, such as an Engine object.
i = getReferenceId( )
i as String: The id of the reference implementor.
Returns the type of form element.
t = getType( )
t as String: The type of form element.
Returns the value of form element.
t = getValue( )
t as String: The value of form element.
An internal representation of a form within the framework.
Returns the specified XHTMLFormElement object.
e = getElement( i )
e as XHTMLFormElement: XHTMLFormElement object.
Returns the specified XHTMLFormElement object.
e = getElementByName( n )
e as XHTMLFormElement: XHTMLFormElement object.
Returns an array of XHTMLFormElement objects.
a = getElements( )
a as array: Array of XHTMLFormElement objects.
Returns true if the specified name exists.
b = isElement( i )
b as boolean: Bit indicating whether the specified object name exists.
Static implementation of serviceImpl.
Manage collection of form elements used within Engine and XHTMLComponent contexts.
This example shows how a form field, bound as an XHTMLComponent, is virtualized through XHTMLFormComponent. This allows the form value to persist in a virtual form even though the node no longer exists.
<!-- HTML Source -->
<div id = "oFields">
<input type = "text" id = "oText" value = "example text" />
<input type = "button" value = "Destroy the text field" onclick = "testXhtmlDestroy()" />
</div>
<!-- Script Source -->
window.onload = testXhtml;
var oX;
function testXhtml(){
var oForm = Hemi.data.form.service;
var o = document.getElementById("oText");
/// Up-bind the component with the service
/// Name the component 'My Text'
/// And identify its form as 'MyForm'
/// The HTML form it is in doesn't matter.
///
oX = Hemi.object.xhtml.newInstance(o,1,"My Text","MyForm",oForm,0,0);
oX.post_init();
}
function testXhtmlDestroy(){
// Destroy the component
// And throw away the input field
// This will automatically syncronize the field value
//
oX.destroy();
oX = null;
document.getElementById("oFields").innerHTML =
"<input type = \"button\" value = \"Retrieve the form\" onclick = \"testXhtmlRecover()\" />";
}
function testXhtmlRecover(){
document.getElementById("oFields").innerHTML = "";
// And, make another field
//
var oI = document.createElement("input");
oI.type = "text";
oI.style.border = "2px solid #FF0000";
document.getElementById("oFields").appendChild(oI);
// Make another component
//
var oForm = Hemi.data.form.service;
var oX = Hemi.object.xhtml.newInstance(oI,1,"My Text","MyForm",oForm,0,0);
oX.post_init();
}Object API structure for storing sub structures: object_config.pointers and object_config.status.
object = object.object_config
Unique instance identifier.
String = object.object_id
The type of this object.
String = object.object_type
Version of the object class.
String = object.object_version
Object load and execution state. Follows: 0 unitialized, 1 through 3 variant, 4 ready, 5 destroyed.
int = object.ready_state
Adds an XHTMLComponent, creating a new XHTMLFormElement that can synchronize and retain data whether or not the HTML Form Element continues to exist.
b = addComponent( x, ri, bi )
b as boolean: Bit indicating whether the component was added.
Clears or resets the specified form elements.
b = clearDataForm( i, b, q )
b as boolean: Returns true if the form was reset, false otherwise.
Returns the HTML Node corresponding to the specified name and form index.
o = getElement( n, i )
o as DOMNode: HTML Form Field Node.
Returns an array of visible or active form elements.
a = getElements( i )
a as array: Array of visible or active form elements.
Returns the specified XHTMLForm object.
e = getForm( i )
e as XHTMLForm: XHTMLForm object.
Returns the specified XHTMLForm object.
e = getFormByName( n )
e as XHTMLForm: XHTMLForm object.
Returns an array of XHTMLForm objects.
a = getForms( )
a as array: Array of XHTMLForm objects.
Returns the unique id of the object.
i = getObjectId( )
i as String: The unique object instance id.
Returns the type of the object.
t = getObjectType( )
t as String: The type of the object instance.
Returns the version of the object.
v = getObjectVersion( )
v as String: The version of the object instance.
Returns the state of the object.
s = getReadyState( )
s as int: The object ready state.
Returns the value of the XHTMLFormElement. Checkbox values are bit, and multi-selects are arrays of selected values.
v = getValue( n, i )
v as variant: The value of the XHTMLFormElement.
Sets the value of the specified XHTMLFormElement.
b = getValue( n, v, i )
b as boolean: Bit indicating whether the value was set.
Returns the XHTMLFormElement object corresponding to the specified name and form index.
o = getXElement( n, i )
o as XHTMLFormElement: XHTMLFormElement object.
Returns a bit indicating whether the specified field matches a predefined list of recognizable fields or custom components.
bField = isFieldNode( n )
bField as boolean: Bit indicating whether the node is recognized by the form service.
Returns true if the specified name exists.
b = isForm( i )
b as boolean: Bit indicating whether the specified object name exists.
Removes the XHTMLForm object.
b = removeDataForm( v )
b as boolean: Bit whether the form was removed.
Clears all forms and form hashmaps data and pointers.
void resetAll( )
Resets the specified form elements to either their default state or their previous state.
b = resetDataForm( i, q )
b as boolean: Returns true if the form was reset, false otherwise.
Synchronizes the XHTMLFormElement, XHTMLComponent, and the rendered HTML Field.
o = synchronizeComponent( x, b, l, q, s )
o as boolean: Bit indicating whether the field was synchronized.
Validates the specified form field based on the specified validation pattern id. Uses the hemi.data.validator.service class.
o = validate( n, w, i )
o as boolean: Bit indicating whether the form field validated.
Validates form fields based on the configured validation patterns. Uses the hemi.data.validator.service class.
o = validateForm( fi, b )
o as boolean: Bit indicating whether the form validated.
[ Hemi JavaScript Framework - Stephen W. Cote, 2002 - 2011. ]