Class MultipleValueAutoSuggestTextField

  extended by com.databasesandlife.util.wicket.MultipleValueAutoSuggestTextField

public class MultipleValueAutoSuggestTextField
extends Object

Represents a text-field in Wicket, which allows the user to enter multiple values, and values are suggested from a list of existing values. These values are only suggestions, however, the user may type in other new values, not in the list of existing values. This is ideal for entering tags on a newly created object, where you want the user to use existing tags if appropriate, but also allow the user to create new tags if none of the existing ones are appropriate.


If new values should not be allowed, for example when selecting from a list of existing languages, see MultipleValueAutoCompleteTextField.

The model of the field is an array of Strings which have been chosen. (It is not possible to display strings to the user, while maintaining a list of IDs corresponding to those strings internally, as the user may enter new strings, and those would have no corresponding IDs.)

The list of values to be suggested is a collection of Strings. There are two ways the these may be fetched:


  <!-- in HTML -->
  <!-- Include JQuery, JQuery UI-->
  <link rel="stylesheet" type="text/css" ....> <-- From JQuery UI themeroller >
  <input type="text" wicket:id="tags" class="my-css-class"></input>

  // In Java
  MultipleValueAutoSuggestTextField tagsField =
      new MultipleValueAutoSuggestTextField("tags");
  tagsField.setClientSideOptions(new String[] { "java", "php" }); // or..
  tagsField.setServerSideDataSource(new AutoSuggestDataSource() {
      public String[] suggest(String userEnteredPartialText) {
          return new String[] { "java", "php" };

If there is an error about a missing </span> tag, make sure the <input> tag is closed with a </input>, even though HTML would not normally require it to be closed. This is a consequence of an implementation issue.

The Javascript used by this software is based on the JQuery autocomplete multiple example.

$Revision: 3740 $
The Java source is copyright Adrian Smith and licensed under the LGPL 3.

Constructor Summary
Method Summary
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public MultipleValueAutoSuggestTextField()