TextBoxControl
- Object
- SitedObject
- Control
- TextBoxControl
Remarks
TextBoxControl supports user text input using either an HTML <input> or <textara> form element. The control uses ID_isMultiLine and ID_isPassword properties to determine how to render itself:
Property | Renders as HTML element |
ID_isMultiLine = false | <input type="text"> |
ID_isMultiLine = true | <textarea> |
ID_isPassword = true (and ID_isMultiLine = false) | <input type="password"> |
TextBoxcontrol provides a common API to both input mechanisms, and also adds support for databinding, validation, and submitters.
.Properties
ID_animators (inherited from Control) | A SitedList of animators. |
ID_controlId (inherited from Control) | The ID this control is known in the nearest binding container parent. |
ID_eventMask (inherited from Control) | (Advanced) A comma-separated list of peer events this control should receive. |
ID_isBindingContainer (inherited from Control) | (Advanced) Force this control to act as a binding container. |
ID_isInvalid | True if the current text value fails to validate. |
ID_isMultiLine | True if this control should use a textarea. |
ID_isPassword | True if this text box is for password entry. |
ID_isPeerless (inherited from Control) | (Advanced) Set this to true to prevent this control from generating a peer element in the rendered HTML. |
ID_submitterId | The ID of the submitter this control uses. |
ID_submitters (inherited from Control) | A SitedList of submitters. |
ID_tagName (inherited from Control) | Overrides the default HTML tag name used for this control. |
ID_text | The text value. |
ID_updateMode | Either ID_enter, ID_explicit, or ID_everyKeyStroke. |
ID_validationErrorMessage | An error message from the validation system. |
ID_visible (inherited from Control) | True if this control is visible, false if it is hidden. |
Events
ID_change | Event handler called every time the raw text in the text box changes. |
ID_mouseDown (inherited from Control) | Event handler called when a mouse button is pressed down. |
ID_mouseMove (inherited from Control) | Event handler called when the mouse is moved. |
ID_mouseOut (inherited from Control) | Event handler called when a leaves a control. |
ID_mouseOver (inherited from Control) | Event handler called when a mouse moves over a control. |
ID_mouseUp (inherited from Control) | Event handler called when a mouse button is released. |
ID_updated | Event handler called when the text is updated. See updateMode below. |
Methods
acceptsDrop (inherited from Control) | Called to determine if this control will accept a drop. |
addBinding (inherited from Control) | Adds a databinding between a property on this object and a binding path. |
addBindingEx (inherited from Control) | Extended entry point for adding a binding. |
addCalculatedBinding (inherited from Control) | Adds a calculated binding for a property. |
addClassName (inherited from Control) | Adds a CSS class to this controls "class" attribute |
addEventHandler (inherited from SitedObject) | Adds a delegate to be called when the specified eventId occurs on this object. |
animateEx (inherited from Control) | Animates a property to a value. |
blur (inherited from Control) | Tells this control's peer to relinquish keyboard focus. |
bubble (inherited from Control) | Bubbles a message up the control hierarchy - calls onBubbleEvent on this control and each of its parents. |
captureMouse (inherited from Control) | Register a control to receive mouse move/up events |
construct (inherited from Control) | Used to initialize a markup control. |
equals (inherited from SitedObject) | Tests if two objects are equal. |
fireEventHandler (inherited from SitedObject) | Invokes any user event handlers registered for a particular event using SitedObject.addEventHandler(). |
focus (inherited from Control) | Tells this control's peer to request keyboard focus. |
getBindingContainer (inherited from Control) | Gets this object's nearest enclosing binding container. |
getBindingStatus (inherited from SitedObject) | Provides debugging information on bindings for this object. |
getEventMask (inherited from Control) | Gets an object indicating which peer events this control is interested in. |
getParent (inherited from Control) | Gets the parent Control of this control. |
getPathValue (inherited from SitedObject) | Traverses a binding path and returns the value at the end of it. |
getPeer (inherited from Control) | Gets the peer DOM element associated with this control. |
getPeerForParent (inherited from Control) | Gets the peer element of this control that the parent control should use in DOM manipulations. |
getPropertyInfo (inherited from SitedObject) | Gets information on a property. |
getRawText | Gets the raw value of the textbox |
getResource (inherited from Control) | Given the ID of a resource, returns the resource's value. |
getSelection | Gets the current selection start and end index. |
getSite (inherited from SitedObject) | Gets this object's site. |
getTagName | (Override) Returns either 'input' or 'textarea' |
getValue (inherited from Control) | Gets a property, style or attribute. |
getViewState (inherited from Control) | Retrieve any viewstate that has been saved for this control in a previous session. |
getViewStateId (inherited from Control) | Get a unique and consistent viewstateId for this control. |
invalidateLayout (inherited from Control) | Tells the layout system to redo layout. |
onBubbleEvent (inherited from Control) | Called to handle a bubbled event. |
onDragEvent (inherited from Control) | Called to handle a drag drop event.. |
onFirstRender (inherited from Control) | Called the first time a control is rendered. |
onPeerCreated (inherited from Control) | Called when a peer is created. |
onPeerEvent (inherited from Control) | Called to dispatch low level events that arise in the Dom. |
onSetValue (inherited from SitedObject) | Called by SitedObject.setValue() when a property value is set on this object. |
onSited (inherited from SitedObject) | Called when this object is sited. |
onSitedRoot (inherited from Control) | Called when a control is added to the main control tree. |
onUnsited (inherited from SitedObject) | Called when this object is about to lose its site. |
onUnsitedRoot (inherited from Control) | Called when a control is removed from the main control tree. |
onValidate | Runs validation. |
onValueSited (inherited from SitedObject) | Called when an object is sited within this object. |
onValueUnsited (inherited from SitedObject) | Called when an object is about to be unsited in this. |
onViewStateChanged (inherited from Control) | Overridable. Controls implement this method to update their viewstate. |
reflectOnBoundValue (inherited from Control) | Gets runtime reflection information on an underlying bound object. |
removeClassName (inherited from Control) | Removes a CSS class from this controls "class" attribute |
removeEventHandler (inherited from SitedObject) | Remove an existing delegate from the list of delegates for the specified event. |
render (inherited from Control) | Places the Html representation of this control into the htmlBuilder. |
renderAttributes | (Override) Called by Control.render() to render attributes for this control. |
renderChildren (inherited from Control) | Places the Html markup for all the Control inside this control into the htmlBuilder. |
setBounds (inherited from Control) | Convenience method to set the left/top/width/height of an element. |
setInitialValues (inherited from SitedObject) | Sets multiple property values on an object (during initialization only) |
setPathValue (inherited from SitedObject) | Traverses a binding path and sets the value at the end of it. |
setSelection | Sets the text selection start and end points. |
setValue (inherited from Control) | Sets a property, style or attribute. |
setViewState (inherited from Control) | Save viewstate that should persist across sessions. |
startAnimator (inherited from Control) | Starts an animation. |
startDragDrop (inherited from Control) | Start a drag drop operation. |
stopAnimator (inherited from Control) | Stops an animation. |
toString (inherited from SitedObject) | Returns a string representation of this object. |
update | Validates the text and updates the ID_text property. |
TextBoxControl getRawText method
JavaScript
var strVal = textBoxControl.getRawText()
Remarks
Returns
TextBoxControl getSelection method
JavaScript
var selectionObj = textBoxControl.getSelection()
Remarks
Returns
Example
To compute the length of the selection, use:
var sel = textBox.getSelection(); alert("Text selection length is: " + sel.end - sel.start);
TextBoxControl getTagName method (override)
JavaScript
textBoxControl.getTagName()
Remarks
Returns
Base Implementation
TextBoxControl ID_change event
JavaScript
textBoxControl.addEventHandler(ID_change, new Delegate(obj, func))
Xml
<j:TextBox change="alert('change happened')" ... >
Example
In Xml, writing:
<j:TextBox change="alert('hello');"/>
creates a change event handler on the button. Whenever the user edits the text in any way, an alert pops up saying 'hello'.
In JavaScript, you write:
// create a click function function myChange() { alert('Hello'); } // create a text box var tb = new TextBoxControl(); // register myChange as an event handler for the textbox tb.addEventHandler(ID_change, new Delegate(tb, myChange));
TextBoxControl ID_isInvalid property
JavaScript
var boolVal = textBoxControl.getValue(ID_isInvalid)
Remarks
TextBoxControl ID_isMultiLine property
JavaScript
var boolVal = textBoxControl.getValue(ID_isMultiLine)
textBoxControl.setValue(ID_isMultiLine, boolVal)
Xml
<j:TextBox isMultiLine="true" ... >
or
<j:TextBox isMultiLine="false" ... >
Remarks
If ID_isMultiLine is set to true, TextBox renders as a <textarea> control.
By default, TextBox renders as either an <inputtype="text"> or <inputtype="password"> control, depending on the value of TextBoxControl.ID_isPassword.
TextBoxControl ID_isPassword property
JavaScript
var boolVal = textBoxControl.getValue(ID_isPassword)
textBoxControl.setValue(ID_isPassword, boolVal)
Xml
<j:TextBox isPassword="true" ... >
or
<j:TextBox isPassword="false" ... >
Remarks
TextBoxControl ID_submitterId property
JavaScript
var idname = textBoxControl.getValue(ID_submitterId)
textBoxControl.setValue(ID_submitterId, idname)
Xml
<j:TextBox submitterId="string" ... >
Remarks
TextBoxControl ID_text property
JavaScript
var strVal = textBoxControl.getValue(ID_text)
textBoxControl.setValue(ID_text, strVal)
Xml
<j:TextBox text="string" ... >
Remarks
TextBoxControl ID_updated event
JavaScript
textBoxControl.addEventHandler(ID_updated, new Delegate(obj, func))
Xml
<j:TextBox updated="alert('updated happened')" ... >
Example
In Xml, writing:
<j:TextBox updated="alert('hello');"/>
creates an updated event handler on the button. When the user edits the text and then hits enter, the alert pops up saying 'hello'.
TextBoxControl ID_updateMode property
JavaScript
var idname = textBoxControl.getValue(ID_updateMode)
textBoxControl.setValue(ID_updateMode, idname)
Xml
<j:TextBox updateMode="enter" ... >
or
<j:TextBox updateMode="everyKeyStroke" ... >
or
<j:TextBox updateMode="explicit" ... >
Remarks
Specifies when the textbox updates its ID_text property (causing changes to propagate to anything bound to that property).
If ID_updateMode is ID_enter (the default), the ID_text property is only updated when the user hits ENTER or when the keyboard focus leaves the control.
If ID_updateMode is ID_everyKeyStroke, every time the user types in the text box the ID_text property is updated to reflect the new value.
If ID_updateMode is ID_explicit, the application must explicitly call TextBoxControl.update() to update the ID_text property.
In all three cases, the ID_text property will not be updated if the current value in the textbox fails to validate.
TextBoxControl ID_validationErrorMessage property
JavaScript
var strVal = textBoxControl.getValue(ID_validationErrorMessage)
Remarks
TextBoxControl onValidate method
JavaScript
var boolVal = textBoxControl.onValidate()
Remarks
This gets the current raw text value in the control and performs any necessary validation. A side effect of calling this method is that ID_isInvalid and ID_validationErrorMessage are updated.
This method does not update ID_text - use TextBoxControl.update() for that.
Returns
TextBoxControl renderAttributes method (override)
JavaScript
textBoxControl.renderAttributes(htmlBuilder)
Remarks
Base Implementation
TextBoxControl setSelection method
JavaScript
textBoxControl.setSelection(startIndex,endIndex)
TextBoxControl update method
JavaScript
textBoxControl.update()