Class ClientDomEvent
When the browser dispatches an event, the Flow client evaluates every
JavaScript expression the server registered for that event type — event data
expressions, listener filters and the event.preventDefault() calls
added by DomListenerRegistration.preventDefault() — against the
native event object, and sends the results to the server as the event data.
This class does the same for a simulated event, so that filtered listeners
see the same data as in the browser, and whether a listener prevented the
default action is known when the event is dispatched, as in the browser.
Only the subset of JavaScript that such expressions use is supported:
property reads and the preventDefault() and stopPropagation()
calls on event, literals, !, &&, ||,
comparisons and parentheses. An expression outside that subset is left out of
the event data, as if it were undefined, unless it calls
preventDefault(): then the outcome of the event cannot be known and
dispatching fails.
For internal use only.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ClientDomEventDispatches an event of the given type on the given element, the way the browser does: the registered expressions are evaluated against an event object with the given properties, giving the event data and whether the default action was prevented.voidfire()Sends the event to the server, running the listeners whose filter matched.booleanGets whether an expression calledevent.preventDefault()while the event was dispatched.
-
Method Details
-
dispatch
Dispatches an event of the given type on the given element, the way the browser does: the registered expressions are evaluated against an event object with the given properties, giving the event data and whether the default action was prevented.The event is not yet sent to the server, see
fire().- Parameters:
element- the element the event is dispatched on, notnulltype- the event type, e.g.click, notnullproperties- the properties of the native event object, e.g.button; values areBoolean,NumberorString- Returns:
- the dispatched event
- Throws:
IllegalStateException- if a registered expression that callspreventDefault()uses JavaScript that cannot be evaluated without a browser
-
isDefaultPrevented
public boolean isDefaultPrevented()Gets whether an expression calledevent.preventDefault()while the event was dispatched.- Returns:
trueif the default action of the event was prevented
-
fire
public void fire()Sends the event to the server, running the listeners whose filter matched.
-