<source><name>Hemi.data.form</name><project><name>Hemi JavaScript Framework</name><url-title>Hemi JavaScript Framework</url-title><url>/Hemi/</url></project><package><path>Hemi.data.form</path><library>Hemi</library><description>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.</description><class><name>XHTMLFormElement</name><description>An internal representation of a form element.</description><version>3.1.9</version><method><name>getType</name><return-value type="String" name="t">The type of form element.</return-value><description>Returns the type of form element.</description></method><method><name>getIsRendered</name><return-value type="boolean" name="b">Bit indicating whether the element is rendered.</return-value><description>Returns true if the form elemnet is rendered.</description></method><method><name>getName</name><return-value type="String" name="t">The name of form element.</return-value><description>Returns the name of form element.</description></method><method><name>getValue</name><return-value type="String" name="t">The value of form element.</return-value><description>Returns the value of form element.</description></method><method><name>getObjectId</name><return-value type="String" name="i">The id of the XHTMLComponent.</return-value><description>Returns the id of the underlying XHTMLComponent</description></method><method><name>getReferenceId</name><return-value type="String" name="i">The id of the reference implementor.</return-value><description>Returns the id of the reference implementor, such as an Engine object.</description></method><method><name>getElement</name><return-value type="object" name="o">HTML Form Element</return-value><description>Returns the rendered HTML Form Element.</description></method></class><class><name>XHTMLForm</name><description>An internal representation of a form within the framework.</description><version>3.1.9</version><method><name>isElement</name><param name="i" type="variant">Name or index of the XHTMLFormElement object.</param><return-value name="b" type="boolean">Bit indicating whether the specified object name exists.</return-value><description>Returns true if the specified name exists.</description></method><method><name>getElements</name><return-value name="a" type="array">Array of XHTMLFormElement objects.</return-value><description>Returns an array of XHTMLFormElement objects.</description></method><method><name>getElement</name><param name="i" type="int">Index of the XHTMLFormElement object..</param><return-value name="e" type="XHTMLFormElement">XHTMLFormElement object.</return-value><description>Returns the specified XHTMLFormElement object.</description></method><method><name>getElementByName</name><param name="n" type="String">Name of the element.</param><return-value name="e" type="XHTMLFormElement">XHTMLFormElement object.</return-value><description>Returns the specified XHTMLFormElement object.</description></method></class><static-class><name>service</name><version>3.1.9</version><description>Static implementation of serviceImpl.</description></static-class><class><name>serviceImpl</name><version>3.1.9</version><description>Manage collection of form elements used within Engine and XHTMLComponent contexts.</description><example><name><![CDATA[Virtual Form Example #1]]></name><description><![CDATA[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.]]></description><code><![CDATA[<!-- HTML Source -->]]></code><code><![CDATA[<div id = "oFields">]]></code><code><![CDATA[  <input type = "text" id = "oText" value = "example text" />]]></code><code><![CDATA[  <input type = "button" value = "Destroy the text field" onclick = "testXhtmlDestroy()" />]]></code><code><![CDATA[</div>]]></code><code><![CDATA[]]></code><code><![CDATA[<!-- Script Source -->]]></code><code><![CDATA[window.onload = testXhtml;]]></code><code><![CDATA[var oX;]]></code><code><![CDATA[function testXhtml(){]]></code><code><![CDATA[  var oForm = Hemi.data.form.service;]]></code><code><![CDATA[  var o = document.getElementById("oText");]]></code><code><![CDATA[  /// Up-bind the component with the service]]></code><code><![CDATA[  /// Name the component 'My Text']]></code><code><![CDATA[  /// And identify its form as 'MyForm']]></code><code><![CDATA[  /// The HTML form it is in doesn't matter.]]></code><code><![CDATA[  /// ]]></code><code><![CDATA[  oX = Hemi.object.xhtml.newInstance(o,1,"My Text","MyForm",oForm,0,0);]]></code><code><![CDATA[  oX.post_init();]]></code><code><![CDATA[}]]></code><code><![CDATA[function testXhtmlDestroy(){]]></code><code><![CDATA[]]></code><code><![CDATA[  // Destroy the component]]></code><code><![CDATA[  // And throw away the input field]]></code><code><![CDATA[  // This will automatically syncronize the field value]]></code><code><![CDATA[  //]]></code><code><![CDATA[  oX.destroy();]]></code><code><![CDATA[  oX = null;]]></code><code><![CDATA[  document.getElementById("oFields").innerHTML = ]]></code><code><![CDATA[  	"<input type = \"button\" value = \"Retrieve the form\" onclick = \"testXhtmlRecover()\" />";]]></code><code><![CDATA[}]]></code><code><![CDATA[function testXhtmlRecover(){]]></code><code><![CDATA[  document.getElementById("oFields").innerHTML = "";]]></code><code><![CDATA[  ]]></code><code><![CDATA[  // And, make another field]]></code><code><![CDATA[  //]]></code><code><![CDATA[  var oI = document.createElement("input");]]></code><code><![CDATA[  oI.type = "text";]]></code><code><![CDATA[  oI.style.border = "2px solid #FF0000";]]></code><code><![CDATA[  document.getElementById("oFields").appendChild(oI);]]></code><code><![CDATA[  ]]></code><code><![CDATA[  // Make another component]]></code><code><![CDATA[  //]]></code><code><![CDATA[  var oForm = Hemi.data.form.service;]]></code><code><![CDATA[  var oX = Hemi.object.xhtml.newInstance(oI,1,"My Text","MyForm",oForm,0,0);]]></code><code><![CDATA[  oX.post_init();]]></code><code><![CDATA[}]]></code></example><property type="String" get="1" internal="1"><name>object_id</name><description>Unique instance identifier.</description></property><property type="String" get="1" internal="1"><name>object_version</name><description>Version of the object class.</description></property><property type="String" get="1" internal="1"><name>object_type</name><description>The type of this object.</description></property><property type="int" get="1" internal="1"><name>ready_state</name><description>Object load and execution state.  Follows: 0 unitialized, 1 through 3 variant, 4 ready, 5 destroyed.</description></property><property type="object" get="1" internal="1"><name>object_config</name><description>Object API structure for storing sub structures: object_config.pointers and object_config.status.</description></property><method><name>getObjectId</name><return-value name="i" type="String">The unique object instance id.</return-value><description>Returns the unique id of the object.</description></method><method><name>getObjectType</name><return-value name="t" type="String">The type of the object instance.</return-value><description>Returns the type of the object.</description></method><method><name>getObjectVersion</name><return-value name="v" type="String">The version of the object instance.</return-value><description>Returns the version of the object.</description></method><method><name>getReadyState</name><return-value name="s" type="int">The object ready state.</return-value><description>Returns the state of the object.</description></method><method><name>isFieldNode</name><param name="n" type="variant">Name or object of a node.</param><return-value name="bField" type="boolean">Bit indicating whether the node is recognized by the form service.</return-value><description>Returns a bit indicating whether the specified field matches a predefined list of recognizable fields or custom components.</description></method><method><name>getElements</name><param name="i" type="int" optional="1">Index identifying a form.</param><return-value name="a" type="array">Array of visible or active form elements.</return-value><description>Returns an array of visible or active form elements.</description></method><method><name>resetAll</name><description>Clears all forms and form hashmaps data and pointers.</description></method><method><name>resetDataForm</name><param name="i" type="int" optional="1">Index identifying a form.</param><param name="q" type="boolean" optional="1">Bit indicating whether the form should be reset to the default value instead of the previous value.</param><return-value name="b" type="boolean">Returns true if the form was reset, false otherwise.</return-value><description>Resets the specified form elements to either their default state or their previous state.</description></method><method><name>clearDataForm</name><param name="i" type="int" optional="1">Index identifying a form.</param><param name="b" type="boolean" optional="1">Bit indicating whether the form should be reset.</param><param name="q" type="boolean" optional="1">Bit indicating whether the form should be reset to the default value instead of the previous value.</param><return-value name="b" type="boolean">Returns true if the form was reset, false otherwise.</return-value><description>Clears or resets the specified form elements.</description></method><method><name>getElement</name><param name="n" type="String">String identifying the name of the XHTMLFormElement object.</param><param name="i" type="int" optional="1">Index identifying a XHTMLForm.</param><return-value name="o" type="DOMNode">HTML Form Field Node.</return-value><description>Returns the HTML Node corresponding to the specified name and form index.</description></method><method><name>getXElement</name><param name="n" type="String">String identifying the name of the XHTMLFormElement object.</param><param name="i" type="int" optional="1">Index identifying a XHTMLForm.</param><return-value name="o" type="XHTMLFormElement">XHTMLFormElement object.</return-value><description>Returns the XHTMLFormElement object corresponding to the specified name and form index.</description></method><method><name>getValue</name><param name="n" type="String">String identifying the name of the XHTMLFormElement object.</param><param name="i" type="int" optional="1">Index identifying a XHTMLForm.</param><return-value name="v" type="variant">The value of the XHTMLFormElement.</return-value><description>Returns the value of the XHTMLFormElement.  Checkbox values are bit, and multi-selects are arrays of selected values.</description></method><method><name>getValue</name><param name="n" type="String">String identifying the name of the XHTMLFormElement object.</param><param name="v" type="variant">Value of the XHTMLFormElement</param><param name="i" type="int" optional="1">Index identifying a XHTMLForm.</param><return-value name="b" type="boolean">Bit indicating whether the value was set.</return-value><description>Sets the value of the specified XHTMLFormElement.</description></method><method internal="1"><name>synchronizeComponent</name><param name="x" type="XHTMLComponent">XHTMLComponent object representing an HTML Form Element.</param><param name="b" type="boolean" optional="1">Bit indicating whether this is a sync-in or sync-out operation.</param><param name="l" type="boolean" optional="1">Bit indicating whether the XHTLMFormElement should be linked to the rendered HTML Form Field.</param><param name="q" type="boolean" optional="1">Bit indicating whether the field should be reset to the default value before synchronizing.</param><param name="s" type="variant" optional="1">Default value to set on the field</param><return-value name="o" type="boolean">Bit indicating whether the field was synchronized.</return-value><description>Synchronizes the XHTMLFormElement, XHTMLComponent, and the rendered HTML Field.</description></method>

o == internal form element construct

If binding is specified, retrieve the object

If synchronizing in and the reset bit is set,
Restore the default value.
if (w) alert(b + ":" + j + ":" + w[j]);
c.selectedIndex = o.v.i;
<method><name>removeDataForm</name><param name="v" type="variant">Name, index, or object representing the XHTMLForm object.</param><return-value name="b" type="boolean">Bit whether the form was removed.</return-value><description>Removes the XHTMLForm object.</description></method>

Clear out the object pointers

<method><name>addComponent</name><param name="x" type="XHTMLComponent">XHTMLComponent object representing an HTML Form Element.</param><param name="ri" type="String" optional="1">Reference id for field containment.</param><param name="bi" type="String" optional="1">Binding id.</param><return-value name="b" type="boolean">Bit indicating whether the component was added.</return-value><description>Adds an XHTMLComponent, creating a new XHTMLFormElement that can synchronize and retain data whether or not the HTML Form Element continues to exist.</description></method>

Reuse p
If a backing bean is specified, and the bean exists,
Then use the bean value instead of the element value
_m.sendMessage("Skip existing " + i, "200.1");
_m.sendMessage("Don't add","200.1");
<method><name>validateForm</name><param name="fi" type="variant">Name or index of a form.</param><param name="b" type="boolean" optional="1">Bit indicating whether focus should be set on fields failing validation.</param><return-value name="o" type="boolean">Bit indicating whether the form validated.</return-value><description>Validates form fields based on the configured validation patterns. Uses the hemi.data.validator.service class.</description></method><method><name>validate</name><param name="n" type="variant">Name or index of the XHTMLFormElement.</param><param name="w" type="String">Validation pattern id.</param><param name="i" type="variant" optional="1">Name or index of the XHTMLForm.</param><return-value name="o" type="boolean">Bit indicating whether the form field validated.</return-value><description>Validates the specified form field based on the specified validation pattern id. Uses the hemi.data.validator.service class.</description></method><method><name>isForm</name><param name="i" type="variant">Name or index of the XHTMLForm object..</param><return-value name="b" type="boolean">Bit indicating whether the specified object name exists.</return-value><description>Returns true if the specified name exists.</description></method><method><name>getForms</name><return-value name="a" type="array">Array of XHTMLForm objects.</return-value><description>Returns an array of XHTMLForm objects.</description></method><method><name>getForm</name><param name="i" type="int">Index of the XHTMLForm object..</param><return-value name="e" type="XHTMLForm">XHTMLForm object.</return-value><description>Returns the specified XHTMLForm object.</description></method><method><name>getFormByName</name><param name="n" type="String">Name of the element.</param><return-value name="e" type="XHTMLForm">XHTMLForm object.</return-value><description>Returns the specified XHTMLForm object.</description></method></class></package><index><description>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.</description><url>Hemi_api.html</url><url-title>API Index</url-title></index></source>
