Class TAutoComplete

Description

Implements interfaces:

TAutoComplete class.

TAutoComplete is a textbox that provides a list of suggestion on the current partial word typed in the textbox. The suggestions are requested using callbacks, and raises the onSuggestion event. The events of the TActiveText (from which TAutoComplete is extended from) and onSuggestion are mutually exculsive. That is, if onTextChange and/or OnCallback events are raise, then onSuggestion will not be raise, and vice versa.

The list of suggestions should be set in the onSuggestion event handler. The partial word to match the suggestion is in the TCallbackEventParameter::getCallbackParameter property. The datasource of the TAutoComplete must be set using setDataSource method. This sets the datasource for the suggestions repeater, available through the Suggestions property. Header, footer templates and other properties of the repeater can be access via the Suggestions property (e.g. they can be set in the .page templates).

To return the list of suggestions back to the browser, supply a non-empty data source and call databind. For example,

  1. function autocomplete_suggestion($sender, $param)
  2. {
  3. $token = $param->getCallbackParameter(); //the partial word to match
  4. $sender->setDataSource($this->getSuggestionsFor($token)); //set suggestions
  5. $sender->dataBind();
  6. }

The suggestion will be rendered when the dataBind() method is called <strong>during a callback request</strong>.

TAutoComplete allows multiple suggestions within one textbox with each word or phrase separated by any characters specified in the Separator property. The Frequency and MinChars properties sets the delay and minimum number of characters typed, respectively, before requesting for sugggestions.

Use onTextChange and/or OnCallback events to handle post backs due to AutoPostBack.

In the Suggestions TRepater item template, all HTML text elements are considered as text for the suggestion. Text within HTML elements with CSS class name "informal" are ignored as text for suggestions.

  • since: 3.1
  • version: $Id: TAutoComplete.php 1568 2006-12-09 09:17:22Z wei $
  • author: Wei Zhuo <weizhuo[at]gmail[dot]com>

Located in /Web/UI/ActiveControls/TAutoComplete.php (line 71)

TComponent
   |
   --TApplicationComponent
      |
      --TControl
         |
         --TWebControl
            |
            --TTextBox
               |
               --TActiveTextBox
                  |
                  --TAutoComplete
Method Summary
void addAttributesToRender (mixed $writer)
void dataBind ()
string getClientClassName ()
float getFrequency ()
integer getMinChars ()
string getSeparator ()
void renderCallback (THtmlWriter $writer)
void renderClientControlScript (mixed $writer)
void renderEndTag (mixed $writer)
void renderResultPanel (THtmlWriter $writer)
void renderSuggestions (THtmlWriter $writer)
void setDataSource (array $data)
void setFrequency (float $value)
void setMinChars (integer $value)
string setSeparator (mixed $value)
Methods
addAttributesToRender (line 307)

Ensure that the ID attribute is rendered and registers the javascript code for initializing the active control.

  • access: public
void addAttributesToRender (mixed $writer)

Redefinition of:
TTextBox::addAttributesToRender()
Adds attribute name-value pairs to renderer.
createRepeater (line 218)
  • return: new instance of TRepater to render the list of suggestions.
  • access: protected
TRepeater createRepeater ()
createResultPanel (line 197)
  • return: new instance of result panel. Default uses TPanel.
  • access: protected
TPanel createResultPanel ()
dataBind (line 177)

Overrides parent implementation. Callback renderSuggestions() when page's IsCallback property is true.

  • access: public
void dataBind ()

Redefinition of:
TControl::dataBind()
Performs the databinding for this control.
getAutoCompleteOptions (line 273)
  • return: list of callback options.
  • access: protected
array getAutoCompleteOptions ()
getClientClassName (line 318)
  • return: corresponding javascript class name for this TActiveButton.
  • access: protected
string getClientClassName ()

Redefinition of:
TActiveTextBox::getClientClassName()
Gets the name of the javascript class responsible for performing postback for this control.
getFrequency (line 101)
  • return: maximum delay (in seconds) before requesting a suggestion.
  • access: public
float getFrequency ()
getMinChars (line 118)
  • return: minimum number of characters before requesting a suggestion.
  • access: public
integer getMinChars ()
getResultPanel (line 187)
  • return: suggestion results panel.
  • access: public
TPanel getResultPanel ()
getSeparator (line 85)
  • return: word or token separators (delimiters).
  • access: public
string getSeparator ()
getSuggestions (line 208)
  • return: suggestion list repeater
  • access: public
TRepeater getSuggestions ()
onSuggest (line 160)

This method is invoked when a autocomplete suggestion is requested.

The method raises 'OnSuggest' event. If you override this method, be sure to call the parent implementation so that the event handler can be invoked.

  • access: public
void onSuggest (TCallbackEventParameter $param)
raiseCallbackEvent (line 141)

Raises the callback event. This method is overrides the parent implementation.

If AutoPostBack is enabled it will raise OnTextChanged event event and then the OnCallback event. The OnSuggest event is raise if the request is to find sugggestions, the OnTextChanged and OnCallback events are NOT raised. This method is mainly used by framework and control developers.

  • access: public
void raiseCallbackEvent (TCallbackEventParameter $param)

Redefinition of:
TActiveTextBox::raiseCallbackEvent()
Raises the callback event. This method is required by ICallbackEventHandler interface.
renderCallback (line 251)

Renders the suggestions during a callback respones.

  • access: public
void renderCallback (THtmlWriter $writer)
renderClientControlScript (line 298)

Override parent implementation, no javascript is rendered here instead the javascript required for active control is registered in addAttributesToRender.

  • access: protected
void renderClientControlScript (mixed $writer)

Redefinition of:
TActiveTextBox::renderClientControlScript()
Renders the javascript for textbox.
renderEndTag (line 231)

Renders the end tag and registers javascript effects library.

  • access: public
void renderEndTag (mixed $writer)

Redefinition of:
TWebControl::renderEndTag()
Renders the closing tag for the control
renderResultPanel (line 242)

Renders the result panel.

  • access: protected
void renderResultPanel (THtmlWriter $writer)
renderSuggestions (line 260)

Renders the suggestions repeater.

  • access: public
void renderSuggestions (THtmlWriter $writer)
setDataSource (line 168)
  • access: public
void setDataSource (array $data)
  • array $data: data source for suggestions.
setFrequency (line 110)
  • access: public
void setFrequency (float $value)
  • float $value: maximum delay (in seconds) before requesting a suggestion. Default is 0.4.
setMinChars (line 126)
  • access: public
void setMinChars (integer $value)
  • integer $value: minimum number of characters before requesting a suggestion.
setSeparator (line 93)
  • return: word or token separators (delimiters).
  • access: public
string setSeparator (mixed $value)

Inherited Methods

Inherited From TActiveTextBox

TActiveTextBox::__construct()
TActiveTextBox::getActiveControl()
TActiveTextBox::getClientClassName()
TActiveTextBox::getClientSide()
TActiveTextBox::onCallback()
TActiveTextBox::raiseCallbackEvent()
TActiveTextBox::renderClientControlScript()
TActiveTextBox::setText()

Inherited From TTextBox

TTextBox::addAttributesToRender()
TTextBox::getAutoCompleteType()
TTextBox::getAutoPostBack()
TTextBox::getAutoTrim()
TTextBox::getCausesValidation()
TTextBox::getClientClassName()
TTextBox::getColumns()
TTextBox::getEnableClientScript()
TTextBox::getMaxLength()
TTextBox::getPostBackOptions()
TTextBox::getReadOnly()
TTextBox::getRows()
TTextBox::getSafeText()
TTextBox::getSafeTextParser()
TTextBox::getTagName()
TTextBox::getText()
TTextBox::getTextMode()
TTextBox::getValidationGroup()
TTextBox::getValidationPropertyValue()
TTextBox::getWrap()
TTextBox::loadPostData()
TTextBox::onTextChanged()
TTextBox::raisePostDataChangedEvent()
TTextBox::renderClientControlScript()
TTextBox::renderContents()
TTextBox::setAutoCompleteType()
TTextBox::setAutoPostBack()
TTextBox::setAutoTrim()
TTextBox::setCausesValidation()
TTextBox::setColumns()
TTextBox::setEnableClientScript()
TTextBox::setMaxLength()
TTextBox::setReadOnly()
TTextBox::setRows()
TTextBox::setText()
TTextBox::setTextMode()
TTextBox::setValidationGroup()
TTextBox::setWrap()

Inherited From TWebControl

TWebControl::addAttributesToRender()
TWebControl::copyBaseAttributes()
TWebControl::createStyle()
TWebControl::getAccessKey()
TWebControl::getBackColor()
TWebControl::getBorderColor()
TWebControl::getBorderStyle()
TWebControl::getBorderWidth()
TWebControl::getCssClass()
TWebControl::getFont()
TWebControl::getForeColor()
TWebControl::getHasStyle()
TWebControl::getHeight()
TWebControl::getStyle()
TWebControl::getTabIndex()
TWebControl::getTagName()
TWebControl::getToolTip()
TWebControl::getWidth()
TWebControl::render()
TWebControl::renderBeginTag()
TWebControl::renderContents()
TWebControl::renderEndTag()
TWebControl::setAccessKey()
TWebControl::setBackColor()
TWebControl::setBorderColor()
TWebControl::setBorderStyle()
TWebControl::setBorderWidth()
TWebControl::setCssClass()
TWebControl::setForeColor()
TWebControl::setHeight()
TWebControl::setStyle()
TWebControl::setTabIndex()
TWebControl::setToolTip()
TWebControl::setWidth()

Inherited From TControl

TControl::__construct()
TControl::addedControl()
TControl::addParsedObject()
TControl::addToPostDataLoader()
TControl::applyStyleSheetSkin()
TControl::autoBindProperty()
TControl::autoDataBindProperties()
TControl::bindProperty()
TControl::broadcastEvent()
TControl::bubbleEvent()
TControl::clearChildState()
TControl::clearControlState()
TControl::clearNamingContainer()
TControl::clearViewState()
TControl::createChildControls()
TControl::createControlCollection()
TControl::dataBind()
TControl::dataBindChildren()
TControl::dataBindProperties()
TControl::ensureChildControls()
TControl::findControl()
TControl::findControlsByID()
TControl::findControlsByType()
TControl::focus()
TControl::getAdapter()
TControl::getAllowChildControls()
TControl::getAttribute()
TControl::getAttributes()
TControl::getChildControlsCreated()
TControl::getClientID()
TControl::getControls()
TControl::getControlStage()
TControl::getControlState()
TControl::getCustomData()
TControl::getEnabled()
TControl::getEnableTheming()
TControl::getEnableViewState()
TControl::getHasAdapter()
TControl::getHasAttributes()
TControl::getHasChildInitialized()
TControl::getHasControls()
TControl::getHasInitialized()
TControl::getHasLoaded()
TControl::getHasLoadedPostData()
TControl::getHasPreRendered()
TControl::getID()
TControl::getNamingContainer()
TControl::getPage()
TControl::getParent()
TControl::getRegisteredObject()
TControl::getSkinID()
TControl::getSourceTemplateControl()
TControl::getTemplateControl()
TControl::getUniqueID()
TControl::getViewState()
TControl::getVisible()
TControl::hasAttribute()
TControl::initRecursive()
TControl::isDescendentOf()
TControl::isObjectRegistered()
TControl::loadRecursive()
TControl::loadState()
TControl::loadStateRecursive()
TControl::onDataBinding()
TControl::onInit()
TControl::onLoad()
TControl::onPreRender()
TControl::onUnload()
TControl::preRenderRecursive()
TControl::raiseBubbleEvent()
TControl::registerObject()
TControl::removeAttribute()
TControl::removedControl()
TControl::render()
TControl::renderChildren()
TControl::renderControl()
TControl::saveState()
TControl::saveStateRecursive()
TControl::setAdapter()
TControl::setAttribute()
TControl::setChildControlsCreated()
TControl::setControlStage()
TControl::setControlState()
TControl::setCustomData()
TControl::setEnabled()
TControl::setEnableTheming()
TControl::setEnableViewState()
TControl::setID()
TControl::setPage()
TControl::setSkinID()
TControl::setTemplateControl()
TControl::setViewState()
TControl::setVisible()
TControl::traverseChildControls()
TControl::unbindProperty()
TControl::unloadRecursive()
TControl::unregisterObject()
TControl::__get()

Inherited From TApplicationComponent

TApplicationComponent::getApplication()
TApplicationComponent::getRequest()
TApplicationComponent::getResponse()
TApplicationComponent::getService()
TApplicationComponent::getSession()
TApplicationComponent::getUser()
TApplicationComponent::publishAsset()
TApplicationComponent::publishFilePath()

Inherited From TComponent

TComponent::addParsedObject()
TComponent::attachEventHandler()
TComponent::canGetProperty()
TComponent::canSetProperty()
TComponent::createdOnTemplate()
TComponent::detachEventHandler()
TComponent::evaluateExpression()
TComponent::evaluateStatements()
TComponent::getEventHandlers()
TComponent::getSubProperty()
TComponent::hasEvent()
TComponent::hasEventHandler()
TComponent::hasProperty()
TComponent::raiseEvent()
TComponent::setSubProperty()
TComponent::__get()
TComponent::__set()
Class Constants

Documentation generated on Sun, 14 Jan 2007 21:41:09 -0500 by phpDocumentor 1.3.0RC4