Home » tapestry-src-5.0.19 » org.apache.tapestry5.corelib.mixins » [javadoc | source]
public class: Autocomplete [javadoc | source]
A mixin for a text field that allows for autocompletion of text fields. This is based on Prototype's autocompleter control.

The mixin renders an (initially invisible) progress indicator after the field (it will also be after the error icon most fields render). The progress indicator is made visible during the request to the server. The mixin then renders a <div> that will be filled in on the client side with dynamically obtained selections.

Multiple selection on the client is enabled by binding the tokens parameter (however, the mixin doesn't help split multiple selections up on the server, that is still your code's responsibility).

The container is responsible for providing an event handler for event "providecompletions". The context will be the partial input string sent from the client. The return value should be an array or list of completions, in presentation order. I.e.

String[] onProvideCompletionsFromMyField(String input)
  return . . .;
Field Summary
static final  String EVENT_NAME     
Method from org.apache.tapestry5.corelib.mixins.Autocomplete Summary:
afterRender,   configure,   generateResponseMarkup,   onAutocomplete
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.tapestry5.corelib.mixins.Autocomplete Detail:
  void afterRender(MarkupWriter writer) 
    Mixin afterRender phrase occurs after the component itself. This is where we write the <div> element and the JavaScript.
 protected  void configure(JSONObject config) 
    Invoked to allow subclasses to further configure the parameters passed to the JavaScript Ajax.Autocompleter options. The values minChars, frequency and tokens my be pre-configured. Subclasses may override this method to configure additional features of the Ajax.Autocompleter.

    This implementation does nothing.

 protected  void generateResponseMarkup(MarkupWriter writer,
    List matches) 
    Generates the markup response that will be returned to the client; this should be an <ul> element with nested <li> elements. Subclasses may override this to produce more involved markup (including images and CSS class attributes).
 Object onAutocomplete()