Project Wonder 5.0.0.8660

er.ajax
Class AjaxAutoComplete

java.lang.Object
  extended by com.webobjects.appserver.WOElement
      extended by com.webobjects.appserver.WOComponent
          extended by er.ajax.AjaxComponent
              extended by er.ajax.AjaxAutoComplete
All Implemented Interfaces:
WOActionResults, NSKeyValueCoding, NSKeyValueCoding.ErrorHandling, NSKeyValueCodingAdditions, NSValidation, IAjaxElement, Serializable, Cloneable

public class AjaxAutoComplete
extends AjaxComponent

Autocompleting combo-box similar to Google suggest.
This is a component that look like a text field, where when you start entering value, it start giving you a menu of options related to what you type. Think about the auto-completion feature of many IDE (XCode / Eclipse) inside a textField.

The scriptaculous library has 2 version of the autocompleter combo-box : a local version and an ajax version.

Local

The local version hold the list of values all in memory (client-side), there is no interaction. If the number of elements is big enough to be in a WOPopUP, then this variant is well suited for you. If the list of element to show is too big, then you might prefer the 'ajax' version.
You have to tell the component that it is local (by default it is 'ajax' type) using the isLocal binding. Then the list binding will need to provide all the objects needed to be found. Filtering of the list as you type will be done client-side, all javascript.

Ajax

Autocomplete field similar to what google has. You bind a value and a method that returns a list and it hits the server on each keystroke and displays the results.

Author:
ak
See Also:
Serialized Form
Bindings
list bound to a method that should return the whole list of object to be displayed. When used in an Ajax context, the component will push first to the value binding, giving you the chance to narrow the list of elements displayed. When used in a Local context, the list should contain all possible objects. the list will be filtered by the scriptaculous engine.
           
value string that will hold the text entered in the field. It is continiously updated.
           
item pushed and pulled the current element of the list. This can be used to customized the string representation (in conjuction with the displayString binding) of the object.
           
displayString optional custom string representation of the current element.
           
isLocal boolean indicating if you want the list to be completely client-side. Binding a true value, would mean that the list will filtered on the client.
           
isLocalSharedList boolean indicating if the list needs to be shared.
           
localSharedVarName the name of the javascript variable to use to store the list in. The list is stored in the userInfo dictionary on the server side to allow for shared use by multiple auto complete components.
           
tokentoken
           
frequency Look at the scriptaculous documentation.
           
minChars Look at the scriptaculous documentation.
           
indicator Look at the scriptaculous documentation.
           
updateElement Look at the scriptaculous documentation.
           
afterUpdateElement Look at the scriptaculous documentation.
           
fullSearch Look at the scriptaculous documentation.
           
partialSearch Look at the scriptaculous documentation.
           
choices Look at the scriptaculous documentation (Local only)
           
partialChars Look at the scriptaculous documentation (Local only)
           
ignoreCase Look at the scriptaculous documentation (Local only)
           
accesskey hot key that should activate the text field (optional)
           
tabindex tab index of the text field (optional)
           

Nested Class Summary
 
Nested classes/interfaces inherited from class com.webobjects.appserver.WOComponent
WOComponent._EventLoggingEnabler, WOComponent.Event
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
NSKeyValueCodingAdditions.DefaultImplementation, NSKeyValueCodingAdditions.Utility
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSValidation
NSValidation._MethodBinding, NSValidation._ValidationBinding, NSValidation.DefaultImplementation, NSValidation.Utility, NSValidation.ValidationException
 
Field Summary
 String divName
           
 String fieldName
           
 
Fields inherited from class er.ajax.AjaxComponent
log
 
Fields inherited from class com.webobjects.appserver.WOComponent
_Extension, _IsEventLoggingEnabled, _keyAssociations
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding.ErrorHandling
_CLASS
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
_CLASS, _KeyPathSeparatorChar, KeyPathSeparator
 
Fields inherited from interface com.webobjects.foundation.NSValidation
_CLASS
 
Constructor Summary
AjaxAutoComplete(WOContext context)
           
 
Method Summary
protected  void addRequiredWebResources(WOResponse res)
          Adds all required resources.
 void appendToResponse(WOResponse res, WOContext ctx)
          Overridden to add the initialization javascript for the auto completer.
 void awake()
          Overridden to set the IDs for the field and the div tag.
protected  NSDictionary createAjaxOptions()
           
 WOActionResults handleRequest(WORequest request, WOContext context)
          Handles the Ajax request.
 boolean isStateless()
          Overridden because the component is stateless
 boolean synchronizesVariablesWithBindings()
          Overridden because the component does not synch with the bindings.
 
Methods inherited from class er.ajax.AjaxComponent
_containerID, addScriptResourceInHead, addScriptResourceInHead, addStylesheetResourceInHead, addStylesheetResourceInHead, appendTagAttributeToResponse, booleanValueForBinding, invokeAction, safeElementID, valueForBinding, valueForBinding, valueForBinding
 
Methods inherited from class com.webobjects.appserver.WOComponent
_associationWithName, _awakeInContext, _childTemplate, _componentDefinition, _componentUnroll, _isPage, _setContext, _setIsPage, _setParent, _setSubcomponent, _sleepInContext, _subcomponentForElementWithID, _templateNameForClass, _unroll, application, baseURL, bindingKeys, canAccessFieldsDirectly, canGetValueForBinding, canSetValueForBinding, clone, context, debugString, descriptionForResponse, ensureAwakeInContext, frameworkName, generateResponse, handleQueryWithUnboundKey, handleTakeValueForUnboundKey, hasBinding, hasSession, isCachingEnabled, isEventLoggingEnabled, logString, name, pageWithName, parent, path, pathURL, performParentAction, pullValuesFromParent, pushValuesToParent, reset, session, set_componentUnroll, set_unroll, setCachingEnabled, setValueForBinding, sleep, takeValueForKey, takeValueForKeyPath, takeValuesFromRequest, template, templateWithHTMLString, templateWithName, toString, unableToSetNullForKey, validateTakeValueForKeyPath, validateValueForKey, validationFailedWithException, valueForBinding, valueForKey, valueForKeyPath
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

divName

public String divName

fieldName

public String fieldName
Constructor Detail

AjaxAutoComplete

public AjaxAutoComplete(WOContext context)
Method Detail

awake

public void awake()
Overridden to set the IDs for the field and the div tag.

Overrides:
awake in class WOComponent

isStateless

public boolean isStateless()
Overridden because the component is stateless

Overrides:
isStateless in class WOComponent

synchronizesVariablesWithBindings

public boolean synchronizesVariablesWithBindings()
Overridden because the component does not synch with the bindings.

Overrides:
synchronizesVariablesWithBindings in class WOComponent

createAjaxOptions

protected NSDictionary createAjaxOptions()

appendToResponse

public void appendToResponse(WOResponse res,
                             WOContext ctx)
Overridden to add the initialization javascript for the auto completer.

Overrides:
appendToResponse in class AjaxComponent

addRequiredWebResources

protected void addRequiredWebResources(WOResponse res)
Adds all required resources.

Specified by:
addRequiredWebResources in class AjaxComponent

handleRequest

public WOActionResults handleRequest(WORequest request,
                                     WOContext context)
Handles the Ajax request. Checks for the form value in the edit field, pushes it up to the parent and pulls the "list" binding. The parent is responsible for returning a list with some items that match the current value.

Specified by:
handleRequest in interface IAjaxElement
Specified by:
handleRequest in class AjaxComponent

Last updated: Sat, Nov 22, 2008 • 04:24 AM EST

Copyright © 2002 – 2007 Project Wonder.