baseformitem.lzx
<library>
<include href="base/basevaluecomponent.lzx"/>
<class name="baseformitem" extends="basevaluecomponent">
<attribute name="_parentform" value="null
"/>
<attribute name="submitname" value="
" type="string"/>
<attribute name="submit" value="${enabled}" type="boolean"/>
<attribute name="changed" value="false
" setter="this.setChanged(changed)"/>
<attribute name="value" value="null
" setter="this.setValue(value,false)"/>
<event name="onchanged"/>
<event name="onvalue"/>
<attribute name="rollbackvalue" value="null
"/>
<attribute name="ignoreform" value="false
"/>
<method name="init">
// set up submitname before baseclasses have a chance to see ""
if (this.submitname == "") this.submitname = this.name;
if (this.submitname == "") {
if ($debug) {
Debug.error('name required for form submit', this);
}
}
super.init();
var fp = this.findForm();
if (fp != null) {
fp.addFormItem(this);
this._parentform = fp;
}
</method>
<method name="destroy">
if (this._parentform)
this._parentform.removeFormItem(this);
super.destroy();
</method>
<method name="setChanged" args="changed,skipform=null">
// Rollbackvalue will be value if init is not completed.
if (! this._initcomplete) {
this.changed = false;
return;
}
var oldchanged = this.changed;
this.changed = changed;
// Only send changed event if it wasn't changed before.
if (this.changed != oldchanged) {
if (this.onchanged) this.onchanged.sendEvent(this.changed);
}
// Only set parent's changed property if parent hasn't changed
if (! skipform && this.changed && ! ignoreform) {
// It's possible that baseformitem is not in a form.
if (this['_parentform'] &&
this._parentform['changed'] != undefined &&
! this._parentform.changed) {
this._parentform.setChanged(changed, false);
}
}
// notify about reset to original state...
if(!skipform && !this.changed && !ignoreform){
// It's possible that baseformitem is not in a form.
if(this['_parentform'] &&
this._parentform['changed'] != undefined &&
this._parentform.changed){
this._parentform.setChanged(changed, true);
}
}
</method>
<method name="rollback">
if (this.rollbackvalue != this['value']) {
this.setAttribute('value', this.rollbackvalue);
}
this.setAttribute('changed', false);
</method>
<method name="commit">
this.rollbackvalue = this.value;
this.setAttribute('changed', false);
</method>
<method name="setValue" args="v,isinitvalue=null">
var didchange = (this.value != v);
this.value = v;
if (isinitvalue || ! this._initcomplete) {
this.rollbackvalue = v;
}
this.setChanged(didchange && !isinitvalue && this.rollbackvalue != v);
if (this['onvalue']) this.onvalue.sendEvent(v);
</method>
<method name="acceptValue" args="data, type=null">
if (type == null) type = this.type;
this.setValue(lz.Type.acceptTypeValue(type, data, this, 'value'), true);
</method>
<method name="findForm">
if (_parentform != null)
return _parentform;
else {
var p = this.immediateparent;
var fp = null;
while (p != canvas) {
if (p['formdata']) {
fp = p;
break;
}
p = p.immediateparent;
}
return fp;
}
</method>
<method name="toXML" args="convert">
var val = this.value;
if (convert) {
// Force javascript to convert booleans to numbers
if (typeof(val) == 'boolean') val = val - 0;
}
if ($debug) {
if (this.submitname == "") {
Debug.format("WARNING: submitname not given for object %w (baseformitem.toXML)\n", this);
}
}
return (lz.Browser.xmlEscape(this.submitname) + "=\"" + lz.Browser.xmlEscape(val) + '"');
</method>
<doc>
<tag name="shortdesc"><text>an abstract class for components which are used in a form</text></tag>
<text>
<p>This abstract class works with <sgmltag class="element" role="lz.form"><form></sgmltag> or
<sgmltag class="element" role="lz.baseform"><baseform></sgmltag>. All form components subclass this.</p>
<p><b>See Also:</b></p>
<ul>
<li>
<sgmltag class="element" role="lz.form"><form></sgmltag> and <sgmltag class="element" role="lz.submit"><submit></sgmltag>
</li>
<li>Form components:
<sgmltag class="element" role="lz.checkbox"><checkbox></sgmltag>, <sgmltag class="element" role="lz.radiogroup"><radiogroup></sgmltag>,
<sgmltag class="element" role="lz.combobox"><combobox></sgmltag>, <sgmltag class="element" role="lz.button"><button></sgmltag>,
<sgmltag class="element" role="lz.edittext"><edittext></sgmltag>, and <sgmltag class="element" role="lz.list"><list></sgmltag>
</li>
</ul>
</text>
</doc>
</class>
</library>
Cross References
Includes
Classes