public class DomEvent extends EventObject
source| Constructor and Description |
|---|
DomEvent(Element source,
String eventType,
elemental.json.JsonObject eventData)
Creates a new DOM event.
|
| Modifier and Type | Method and Description |
|---|---|
elemental.json.JsonObject |
getEventData()
Gets additional data related to the event.
|
Optional<Element> |
getEventDataElement(String eventDataExpression)
Gets the closest
Element corresponding to the given event data
expression. |
Optional<Element> |
getEventTarget()
Gets the closest
Element that corresponds to the
event.target for the DOM event. |
DebouncePhase |
getPhase()
Gets the debounce phase for which this event is fired.
|
Element |
getSource()
Returns the element on which the listener has been attached.
|
String |
getType()
Gets the type of the event.
|
toStringpublic DomEvent(Element source, String eventType, elemental.json.JsonObject eventData)
source - the element on which the listener has been attached, not
nulleventType - the type of the event, not nulleventData - additional data related to the event, not nullElement.addEventListener(String, DomEventListener),
DomEventListenerpublic Element getSource()
getSource in class EventObjectElement.addEventListener(String, DomEventListener),
Element.addEventListener(String, DomEventListener, String...),
for event target elementpublic String getType()
public elemental.json.JsonObject getEventData()
nullDomListenerRegistration.addEventData(String)public DebouncePhase getPhase()
public Optional<Element> getEventTarget()
Element that corresponds to the
event.target for the DOM event. This is always inside the child
hierarchy of the element returned by getSource().
To get this reported, you need to call
DomListenerRegistration.mapEventTargetElement() or an empty
optional is always returned.
The returned element is the same as getSource() only if
the event originated from that element on the browser (and not from its
child).
event.target or an empty
optionalpublic Optional<Element> getEventDataElement(String eventDataExpression)
Element corresponding to the given event data
expression. NOTE: this only works if you have added the
expression using
DomListenerRegistration.addEventDataElement(String).
If the evaluated JS expression returned an element that is not created or controlled by the server side, the closest parent element that is controlled is returned instead. Invisible elements are not reported.
In case you want the event.target element, use
getEventTarget() instead.
eventDataExpression - the expression that was executed on the client to retrieve the
element, not nullCopyright © 2025. All rights reserved.