Class AutoCompleteTextField<T>
- java.lang.Object
-
- org.apache.wicket.Component
-
- org.apache.wicket.MarkupContainer
-
- org.apache.wicket.markup.html.WebMarkupContainer
-
- org.apache.wicket.markup.html.form.LabeledWebMarkupContainer
-
- org.apache.wicket.markup.html.form.FormComponent<T>
-
- org.apache.wicket.markup.html.form.AbstractTextComponent<T>
-
- org.apache.wicket.markup.html.form.TextField<T>
-
- org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField<T>
-
- Type Parameters:
T
- The model object type
- All Implemented Interfaces:
Serializable
,Iterable<Component>
,IEventSink
,IEventSource
,IFeedbackContributor
,IConverterLocator
,IGenericComponent<T,FormComponent<T>>
,IMetadataContext<Serializable,Component>
,IFormModelUpdateListener
,IFormVisitorParticipant
,ILabelProvider<String>
,IHeaderContributor
,IRequestableComponent
,IHierarchical<Component>
,IClusterable
- Direct Known Subclasses:
DefaultCssAutoCompleteTextField
public abstract class AutoCompleteTextField<T> extends TextField<T>
An implementation of a textfield with the autoassist ajax behaviorAutoCompleteBehavior
.An
IAutoCompleteRenderer
is used for rendering of choices. To convert input back into a non-String type you will have to provide a customIConverter
, either by overridingComponent.getConverter(Class)
or by setting a suitableIConverter
on the application'sConverterLocator
.Note that you must add your own CSS to make the suggestion display properly, see
DefaultCssAutoCompleteTextField
for an example.- Since:
- 1.2
- Author:
- Igor Vaynberg (ivaynberg)
- See Also:
DefaultCssAutoCompleteTextField
,AutoCompleteBehavior
,IAutoCompleteRenderer
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.wicket.markup.html.form.AbstractTextComponent
AbstractTextComponent.ITextFormatProvider
-
-
Field Summary
-
Fields inherited from class org.apache.wicket.markup.html.form.FormComponent
FLAG_CONVERT_EMPTY_INPUT_STRING_TO_NULL, VALUE_SEPARATOR
-
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_INITIALIZED, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING, RFLAG_CONTAINER_HAS_REMOVALS
-
-
Constructor Summary
Constructors Constructor Description AutoCompleteTextField(String id)
Constructor.AutoCompleteTextField(String id, Class<T> type)
Constructor for the given type with default settings.AutoCompleteTextField(String id, Class<T> type, IAutoCompleteRenderer<T> renderer)
Constructor for the given type using the given rendererAutoCompleteTextField(String id, AutoCompleteSettings settings)
Constructor.AutoCompleteTextField(String id, IAutoCompleteRenderer<T> renderer)
Constructor using the given renderer.AutoCompleteTextField(String id, IModel<T> model)
Constructor for the given model.AutoCompleteTextField(String id, IModel<T> model, Class<T> type, AutoCompleteSettings settings)
Constructor for the given model and type.AutoCompleteTextField(String id, IModel<T> model, Class<T> type, IAutoCompleteRenderer<T> renderer, AutoCompleteSettings settings)
Constructor for the given model using the given renderer.AutoCompleteTextField(String id, IModel<T> model, AutoCompleteSettings settings)
Constructor for given model.AutoCompleteTextField(String id, IModel<T> model, IAutoCompleteRenderer<T> renderer)
Constructor for the given model using the given renderer.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description IAutoCompleteRenderer<T>
getChoiceRenderer()
protected abstract Iterator<T>
getChoices(String input)
Callback method that should return an iterator over all possible assist choice objects.protected AutoCompleteBehavior<T>
newAutoCompleteBehavior(IAutoCompleteRenderer<T> renderer, AutoCompleteSettings settings)
Factory method for autocomplete behavior that will be added to this textfieldprotected void
onComponentTag(ComponentTag tag)
Processes the component tag.protected void
onDetach()
Sets the temporary converted input value to null.protected void
onInitialize()
Initializes theAutoCompleteBehavior
if it is not already there.protected void
updateAjaxAttributes(AjaxRequestAttributes attributes)
-
Methods inherited from class org.apache.wicket.markup.html.form.TextField
getInputTypes
-
Methods inherited from class org.apache.wicket.markup.html.form.AbstractTextComponent
convertInput, getConvertEmptyInputStringToNull, isInputNullable, onBeforeRender, setConvertEmptyInputStringToNull
-
Methods inherited from class org.apache.wicket.markup.html.form.FormComponent
add, add, checkRequired, clearInput, convertValue, error, getConvertedInput, getDefaultLabel, getDefaultLabel, getForm, getInput, getInputAsArray, getInputName, getModelValue, getParameterValues, getRawInput, getType, getValidatorKeyPrefix, getValidators, getValue, hasRawInput, inputAsInt, inputAsInt, inputAsIntArray, inputChanged, internalOnModelChanged, invalid, isMultiPart, isRequired, isValid, newValidatable, newValidationError, onDisabled, onInvalid, onValid, processChildren, processInput, remove, reportRequiredError, setConvertedInput, setLabel, setModelValue, setRequired, setType, shouldTrimInput, trim, updateAutoLabels, updateAutoLabels, updateCollectionModel, updateModel, valid, validate, validateRequired, validateValidators, visitComponentsPostOrder, visitFormComponentsPostOrder
-
Methods inherited from class org.apache.wicket.markup.html.form.LabeledWebMarkupContainer
getLabel
-
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSession
-
Methods inherited from class org.apache.wicket.MarkupContainer
add, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, getRegionMarkup, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onComponentTagBody, onRender, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, stream, streamChildren, toString, toString, visitChildren, visitChildren
-
Methods inherited from class org.apache.wicket.Component
add, addStateChange, beforeRender, canCallListener, canCallListenerAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, createConverter, debug, detach, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviorById, getBehaviorId, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessages, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkup, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdFromMarkup, getMarkupIdImpl, getMarkupSourcingStrategy, getMarkupTag, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getRequestFlag, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isInitialized, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, newMarkupSourcingStrategy, onAfterRender, onConfigure, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderPart, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlForListener, urlForListener, visitParents, visitParents, warn, wrap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.wicket.IGenericComponent
getDefaultModel, getDefaultModelObject, getModel, getModelObject, setDefaultModel, setDefaultModelObject, setModel, setModelObject
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
AutoCompleteTextField
public AutoCompleteTextField(String id, Class<T> type)
Constructor for the given type with default settings.- Parameters:
id
- component idtype
- model objec type
-
AutoCompleteTextField
public AutoCompleteTextField(String id, IModel<T> model, Class<T> type, AutoCompleteSettings settings)
Constructor for the given model and type.- Parameters:
id
- component idmodel
- modeltype
- model object typesettings
- settings for autocomplete
-
AutoCompleteTextField
public AutoCompleteTextField(String id, IModel<T> model, AutoCompleteSettings settings)
Constructor for given model.- Parameters:
id
- component idmodel
- modelsettings
- settings for autocomplete
-
AutoCompleteTextField
public AutoCompleteTextField(String id, IModel<T> model)
Constructor for the given model.- Parameters:
id
- component idmodel
- model
-
AutoCompleteTextField
public AutoCompleteTextField(String id, AutoCompleteSettings settings)
Constructor.- Parameters:
id
- component idsettings
- settings for autocomplete
-
AutoCompleteTextField
public AutoCompleteTextField(String id)
Constructor.- Parameters:
id
- component id
-
AutoCompleteTextField
public AutoCompleteTextField(String id, IAutoCompleteRenderer<T> renderer)
Constructor using the given renderer.- Parameters:
id
- component idrenderer
- renderer for autocomplete
-
AutoCompleteTextField
public AutoCompleteTextField(String id, Class<T> type, IAutoCompleteRenderer<T> renderer)
Constructor for the given type using the given renderer- Parameters:
id
- component idtype
- model object typerenderer
- renderer for autocomplete
-
AutoCompleteTextField
public AutoCompleteTextField(String id, IModel<T> model, IAutoCompleteRenderer<T> renderer)
Constructor for the given model using the given renderer.- Parameters:
id
- component idmodel
- modelrenderer
- renderer for autocomplete
-
AutoCompleteTextField
public AutoCompleteTextField(String id, IModel<T> model, Class<T> type, IAutoCompleteRenderer<T> renderer, AutoCompleteSettings settings)
Constructor for the given model using the given renderer.- Parameters:
id
- component idmodel
- modeltype
- model object typerenderer
- renderer for autocompletesettings
- settings for autocomplete
-
-
Method Detail
-
newAutoCompleteBehavior
protected AutoCompleteBehavior<T> newAutoCompleteBehavior(IAutoCompleteRenderer<T> renderer, AutoCompleteSettings settings)
Factory method for autocomplete behavior that will be added to this textfield- Parameters:
renderer
- auto complete renderersettings
- auto complete settings- Returns:
- auto complete behavior
-
updateAjaxAttributes
protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
-
onInitialize
protected void onInitialize()
Initializes theAutoCompleteBehavior
if it is not already there.- Overrides:
onInitialize
in classMarkupContainer
-
onComponentTag
protected void onComponentTag(ComponentTag tag)
Description copied from class:TextField
Processes the component tag.- Overrides:
onComponentTag
in classTextField<T>
- Parameters:
tag
- Tag to modify- See Also:
Component.onComponentTag(ComponentTag)
-
getChoices
protected abstract Iterator<T> getChoices(String input)
Callback method that should return an iterator over all possible assist choice objects. These objects will be passed to the renderer to generate output. Usually it is enough to return an iterator over strings.- Parameters:
input
- current input- Returns:
- iterator over all possible choice objects
- See Also:
AutoCompleteBehavior.getChoices(String)
-
getChoiceRenderer
public final IAutoCompleteRenderer<T> getChoiceRenderer()
- Returns:
- The
IAutoCompleteRenderer
used to generate html output for theAutoCompleteBehavior
.
-
onDetach
protected void onDetach()
Description copied from class:FormComponent
Sets the temporary converted input value to null.- Overrides:
onDetach
in classFormComponent<T>
- See Also:
Component.onDetach()
-
-