public interface DomListenerRegistration extends Registration
Element.addEventListener(String, DomEventListener)| Modifier and Type | Method and Description |
|---|---|
DomListenerRegistration |
addEventData(String eventData)
Add a JavaScript expression for extracting event data.
|
default DomListenerRegistration |
addEventDataElement(String eventData)
Add a JavaScript expression for extracting an element as event data.
|
default DomListenerRegistration |
debounce(int timeout)
Configures this listener to be notified only when at least
timeout milliseconds has passed since the last time the
event was triggered. |
DomListenerRegistration |
debounce(int timeout,
DebouncePhase firstPhase,
DebouncePhase... rest)
Configures the debouncing phases for which this listener should be
triggered.
|
default Set<DebouncePhase> |
getDebouncePhases()
Gets the debouncing phases for which this listener should be triggered.
|
default int |
getDebounceTimeout()
Gets the debounce timeout that is configured by debounce or throttle.
|
default String |
getEventType()
Gets the event type that the listener is registered for.
|
String |
getFilter()
Gets the currently set filter expression.
|
default DomListenerRegistration |
mapEventTargetElement()
Marks that the DOM event should map the
event.target to the
closest corresponding Element on the server side, to be returned
by DomEvent.getEventTarget(). |
default DomListenerRegistration |
onUnregister(SerializableRunnable unregisterHandler)
Adds a handler that will be run when this registration is removed.
|
DomListenerRegistration |
setDisabledUpdateMode(DisabledUpdateMode disabledUpdateMode)
Configure whether this listener will be called even in cases when the
element is disabled.
|
DomListenerRegistration |
setFilter(String filter)
Sets a JavaScript expression that is used for filtering events to this
listener.
|
default DomListenerRegistration |
synchronizeProperty(String propertyName)
Marks that the DOM event of this registration should trigger
synchronization for the given property.
|
default DomListenerRegistration |
throttle(int period)
Configures this listener to not be notified more often than
period milliseconds. |
addAndRemove, combine, once, removeDomListenerRegistration addEventData(String eventData)
element refers to this element and event refers
to the fired event. If multiple expressions are defined for the same
event, their order of execution is undefined.
The result of the evaluation is available in
DomEvent.getEventData() with the expression as the key in the
JSON object. An expression might be e.g.
element.value the get the value of an input element for
a change event.
event.button === 0 to get true for click events
triggered by the primary mouse button.
eventData - definition for data that should be passed back to the server
together with the event, not nullfor mapping an element,
to map the {@code event.target} to an
elementDomListenerRegistration setFilter(String filter)
true-ish according to JavaScript type coercion rules. The
expression is evaluated in a context where element refers to
this element and event refers to the fired event.
An expression might be e.g. event.button === 0 to only
forward events triggered by the primary mouse button.
Any previous filter for this registration is discarded.
filter - the JavaScript filter expression, or null to
clear the filterString getFilter()
null if no filter
is in usesetFilter(String)DomListenerRegistration setDisabledUpdateMode(DisabledUpdateMode disabledUpdateMode)
When used in combination with synchronizeProperty(String), the
most permissive update mode for the same property will be effective. This
means that there might be unexpected property updates for a disabled
component if multiple parties independently configure different aspects
for the same component. This is based on the assumption that if a
property is explicitly safe to update for disabled components in one
context, then the nature of that property is probably such that it's also
safe to update in other contexts.
disabledUpdateMode - controls RPC communication from the client side to the server
side when the element is disabled, not nullDomListenerRegistration debounce(int timeout, DebouncePhase firstPhase, DebouncePhase... rest)
timeout is set to 0.
This methods overrides the settings previously set through
debounce(int), throttle(int) or
debounce(int, DebouncePhase, DebouncePhase...).
timeout - the debounce timeout in milliseconds, or 0 to disable
debouncingfirstPhase - the first phase to userest - any remaining phases to useDebouncePhasedefault DomListenerRegistration debounce(int timeout)
timeout milliseconds has passed since the last time the
event was triggered. This is useful for cases such as text input where
it's only relevant to know the result once the user stops typing.
Debouncing is disabled if the timeout is set to 0.
This methods overrides the settings previously set through
debounce(int), throttle(int) or
debounce(int, DebouncePhase, DebouncePhase...).
timeout - the debounce timeout in milliseconds, or 0 to disable
debouncingdefault DomListenerRegistration throttle(int period)
period milliseconds.
Throttling is disabled if the period is set to 0.
This methods overrides the settings previously set through
debounce(int), throttle(int) or
debounce(int, DebouncePhase, DebouncePhase...).
period - the minimum period between listener invocations, or 0 to
disable throttlingdefault int getDebounceTimeout()
0 if debouncing is
disableddebounce(int, DebouncePhase, DebouncePhase...),
debounce(int),
throttle(int)default Set<DebouncePhase> getDebouncePhases()
debounce(int, DebouncePhase, DebouncePhase...),
debounce(int),
throttle(int)default String getEventType()
default DomListenerRegistration onUnregister(SerializableRunnable unregisterHandler)
unregisterHandler - the handler to run when the registration is removed, not
nulldefault DomListenerRegistration synchronizeProperty(String propertyName)
propertyName - the name of the property to synchronize, not null
or ""default DomListenerRegistration mapEventTargetElement()
event.target to the
closest corresponding Element on the server side, to be returned
by DomEvent.getEventTarget().default DomListenerRegistration addEventDataElement(String eventData)
element refers to this element and event
refers to the fired event. If multiple expressions are defined for the
same event, their order of execution is undefined.
The result of the evaluation is available in
DomEvent.getEventDataElement(String) with the expression as the
key in the JSON object.
In case you want to get the event.target element to the server
side, use the mapEventTargetElement() method to get it mapped
and the DomEvent.getEventTarget() to fetch the element.
eventData - definition for element that should be passed back to the
server together with the event, not nullto map the {@code event.target} to an
elementCopyright © 2025. All rights reserved.