Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tapestry5.corelib.mixins
Class Autocomplete

    java.lang.Object
      org.apache.tapestry5.corelib.mixins.Autocomplete

    @Import(library={"${tapestry.scriptaculous}/controls.js","autocomplete.js"})
    @Events(value="provideCompletions")
    public class Autocomplete

extends java.lang.Object

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 . . .;
     }

Component Parameters
Name | Description | Type | Flags | Default | Default Prefix | Since
--- | --- | --- | --- | --- | --- | ---
frequency | Overrides the default check frequency for determining whether to send a server request. The default is .4 seconds. | double |  |  | literal |
minChars | Overwrites the default minimum characters to trigger a server round trip (the default is 1). | int |  |  | literal |
tokens | If given, then the autocompleter will support multiple input values, seperated by any of the individual characters in the string. | String |  |  | literal |

Events:

provideCompletions

Constructor Summary
`Autocomplete()`

Method Summary
`protected void` | `configure(JSONObject config)` Invoked to allow subclasses to further configure the parameters passed to the JavaScript Ajax.Autocompleter options.
`protected void` | `generateResponseMarkup(MarkupWriter writer, java.util.List matches)` Generates the markup response that will be returned to the client; this should be an <ul> element with nested <li> elements.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Autocomplete

    public Autocomplete()

Method Detail

### configure

    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.

  Parameters:
    `config` - parameters object

### generateResponseMarkup

    protected void generateResponseMarkup(MarkupWriter writer,
                                          java.util.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).

  Parameters:
    `writer` - to write the list to
    `matches` - list of matching objects, each should be converted to a string

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2012 The Apache Software Foundation.