public class AutocompleteTextFieldExtension
extends com.vaadin.server.AbstractJavaScriptExtension
AbstractTextField
with autocomplete (aka word completion)
functionality.
Uses a modified version of autoComplete originally developed by Simon Steinberger
autoComplete
is released under the MIT License.
com.vaadin.server.ClientConnector.AttachEvent, com.vaadin.server.ClientConnector.AttachListener, com.vaadin.server.ClientConnector.ConnectorErrorEvent, com.vaadin.server.ClientConnector.DetachEvent, com.vaadin.server.ClientConnector.DetachListener
Modifier and Type | Field and Description |
---|---|
protected AutocompleteSuggestionProvider |
suggestionProvider
The suggestion provider queried for suggesions
|
Constructor and Description |
---|
AutocompleteTextFieldExtension()
Construct a new
AutocompleteTextFieldExtension . |
AutocompleteTextFieldExtension(com.vaadin.ui.AbstractTextField target)
Construct a new
AutocompleteTextFieldExtension and extends the
given AbstractTextField . |
Modifier and Type | Method and Description |
---|---|
void |
addMenuStyleName(String styleName)
Adds one or more style names to the dropdown menu container.
|
void |
extend(com.vaadin.ui.AbstractTextField target)
Extends the given textfield.
|
int |
getDelay()
Gets the delay in milliseconds between when a keystroke occurs and when a
search is performed.
|
String |
getMenuStyleName()
Gets all user-defined CSS style names of the dropdown menu container.
|
int |
getMinChars()
Gets the minimum number of characters (>=1) a user must type before a
search is performed.
|
com.vaadin.ui.AbstractTextField |
getParent() |
ScrollBehavior |
getScrollBehavior()
Gets the
ScrollBehavior that is used when the user scrolls the
page while the suggestion box is open. |
protected AutocompleteTextFieldExtensionState |
getState() |
protected AutocompleteTextFieldExtensionState |
getState(boolean markAsDirty) |
Class<? extends AutocompleteTextFieldExtensionState> |
getStateType() |
int |
getSuggestionLimit()
Gets the maximum number of suggestions that are allowed.
|
AutocompleteSuggestionProvider |
getSuggestionProvider()
Gets the active
AutocompleteSuggestionProvider . |
protected Class<? extends com.vaadin.server.ClientConnector> |
getSupportedParentType() |
boolean |
isCache()
Checks if performed searches should be cached.
|
boolean |
isItemAsHtml()
Checks whether items are rendered as HTML.
|
protected Set<AutocompleteSuggestion> |
querySuggestions(AutocompleteQuery query)
Executes the given
AutocompleteQuery and makes sure the result is
within the boundries of the AutocompleteQuery 's limit. |
protected Set<AutocompleteSuggestion> |
querySuggestions(String term)
Creates an
AutocompleteQuery from the given search term and the
internal suggestionLimit and executes it. |
void |
removeMenuStyleName(String styleName)
Removes one or more style names from the dropdown menu container.
|
void |
setCache(boolean cache)
Sets if performed searches should be cached.
|
void |
setDelay(int delay)
Sets the delay in milliseconds between when a keystroke occurs and when a
search is performed.
|
void |
setItemAsHtml(boolean itemAsHtml)
Sets whether the items are rendered as HTML.
|
void |
setMinChars(int minChars)
Sets the minimum number of characters (>=1) a user must type before a
search is performed.
|
void |
setScrollBehavior(ScrollBehavior scrollBehavior)
Sets the
ScrollBehavior that is used when the user scrolls the
page while the suggestion box is open. |
void |
setSuggestionLimit(int suggestionLimit)
Sets the maximum number of suggestions that are allowed.
|
void |
setSuggestionProvider(AutocompleteSuggestionProvider suggestionProvider)
Sets the active
AutocompleteSuggestionProvider . |
protected elemental.json.JsonValue |
suggestionsToJson(Set<AutocompleteSuggestion> suggestions)
Converts the given
AutocompleteSuggestion into a
JsonValue representation because JsonCodec can't handle
it itself. |
addFunction, callFunction, registerRpc
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, attach, beforeClientResponse, createState, detach, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isConnectorEnabled, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
addAttachListener, addDetachListener, attach, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getUI, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
protected AutocompleteSuggestionProvider suggestionProvider
public AutocompleteTextFieldExtension()
AutocompleteTextFieldExtension
.public AutocompleteTextFieldExtension(com.vaadin.ui.AbstractTextField target)
AutocompleteTextFieldExtension
and extends the
given AbstractTextField
.target
- The textfield to extend.public void extend(com.vaadin.ui.AbstractTextField target)
target
- The textfield to extend.public com.vaadin.ui.AbstractTextField getParent()
getParent
in interface com.vaadin.server.ClientConnector
getParent
in interface com.vaadin.shared.Connector
getParent
in class com.vaadin.server.AbstractExtension
protected Class<? extends com.vaadin.server.ClientConnector> getSupportedParentType()
getSupportedParentType
in class com.vaadin.server.AbstractExtension
protected AutocompleteTextFieldExtensionState getState()
getState
in class com.vaadin.server.AbstractJavaScriptExtension
protected AutocompleteTextFieldExtensionState getState(boolean markAsDirty)
getState
in class com.vaadin.server.AbstractClientConnector
public Class<? extends AutocompleteTextFieldExtensionState> getStateType()
getStateType
in interface com.vaadin.server.ClientConnector
getStateType
in class com.vaadin.server.AbstractClientConnector
protected Set<AutocompleteSuggestion> querySuggestions(String term)
AutocompleteQuery
from the given search term and the
internal suggestionLimit
and executes it.
Returns a Set
of AutocompleteSuggestion
s with a
predictable iteration order.term
- The search term.Set
of AutocompleteSuggestion
s with a
predictable iteration order.protected Set<AutocompleteSuggestion> querySuggestions(AutocompleteQuery query)
AutocompleteQuery
and makes sure the result is
within the boundries of the AutocompleteQuery
's limit.
Returns a Set
of AutocompleteSuggestion
s with a
predictable iteration order.
query
- The Query.Set
of AutocompleteSuggestion
s with a
predictable iteration order.protected elemental.json.JsonValue suggestionsToJson(Set<AutocompleteSuggestion> suggestions)
AutocompleteSuggestion
into a
JsonValue
representation because JsonCodec
can't handle
it itself.suggestions
- Suggestions.JsonValue
representation.public AutocompleteSuggestionProvider getSuggestionProvider()
AutocompleteSuggestionProvider
.AutocompleteSuggestionProvider
.public void setSuggestionProvider(AutocompleteSuggestionProvider suggestionProvider)
AutocompleteSuggestionProvider
.suggestionProvider
- The active
AutocompleteSuggestionProvider
.public int getSuggestionLimit()
If the active AutocompleteSuggestionProvider
returns more
suggestions than allowed, the excess suggestions will be ignored!
If limit <= 0
the suggestions won't be limited.
public void setSuggestionLimit(int suggestionLimit)
If the active AutocompleteSuggestionProvider
returns more
suggestions than allowed, the excess suggestions will be ignored!
If limit <= 0 the suggestions won't be limited.
suggestionLimit
- Maximum number of suggestions.public boolean isItemAsHtml()
The default is false, i.e. to render that caption as plain text.
public void setItemAsHtml(boolean itemAsHtml)
If set to true, the items are rendered in the browser as HTML and the developer is responsible for ensuring no harmful HTML is used. If set to false, the caption is rendered in the browser as plain text.
The default is false, i.e. to render that caption as plain text.
itemAsHtml
- true if the items are rendered as HTML, false if
rendered as plain text.public int getMinChars()
public void setMinChars(int minChars)
minChars
- Minimum number of characters.public int getDelay()
public void setDelay(int delay)
delay
- Search delay in milliseconds.public boolean isCache()
public void setCache(boolean cache)
cache
- Cache performed searches.public String getMenuStyleName()
public void addMenuStyleName(String styleName)
styleName
- The new style to be added to the dropdown menu
container.public void removeMenuStyleName(String styleName)
styleName
- The style name or style names to be removed.public ScrollBehavior getScrollBehavior()
ScrollBehavior
that is used when the user scrolls the
page while the suggestion box is open.ScrollBehavior
.public void setScrollBehavior(ScrollBehavior scrollBehavior)
ScrollBehavior
that is used when the user scrolls the
page while the suggestion box is open.scrollBehavior
- The ScrollBehavior
.Copyright © 2016 Max Schuster. All Rights Reserved.