Annotation Interface DomEvent


@Retention(RUNTIME) @Target(TYPE) @Documented @Inherited public @interface DomEvent
Maps a DOM event to a ComponentEvent.

Marking a ComponentEvent class with @DomEvent will cause the ComponentEvent to be fired whenever the DOM event occurs.

A ComponentEvent class mapped with @DomEvent must have a special constructor which is invoked by the framework when creating and firing a ComponentEvent based on a DOM event.

  • The first parameter must be the event source, a Component.
  • The second parameter must be a boolean, indicating whether the event originated from the client (always true when fired based on a DOM event)
  • Any additional parameters must be annotated using @EventData, telling the framework which part of the DOM event data object to map to the parameter.
Since:
1.0
Author:
Vaadin Ltd
See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The name of the DOM event which should fire the annotated component event.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Controls whether this event listener should bypass the server-side security checks for modality.
    Controls RPC for the listener when the element is disabled.
    The debounce settings to use with this event.
    The filter expression to run in the browser to determine whether fired events should be passed to the server.
    boolean
    Controls if the browser is asked to prevent the default browser behavior.
    boolean
    Controls if the event is let to propagate to parent elements.
  • Element Details

    • value

      String value
      The name of the DOM event which should fire the annotated component event.
      Returns:
      the name of the DOM event
    • allowUpdates

      DisabledUpdateMode allowUpdates
      Controls RPC for the listener when the element is disabled.
      Returns:
      the property update mode for disabled element
      See Also:
      Default:
      ONLY_WHEN_ENABLED
    • filter

      String filter
      The filter expression to run in the browser to determine whether fired events should be passed to the server. The event is sent only if the expression returns a truthy value. The expression is evaluated in a context where element refers to the element for which the listener is registered and event refers to the fired event.

      A filter that is a property path, which is event or element followed by property names separated with . or ?., is read in the browser without compiling it. Many filters can be written as a path, as the value only has to be truthy:

      • event.key?.length instead of typeof(event.key) === 'string' && event.key.length > 0, for a keyboard event with a non-empty key
      • event.detail instead of event.detail !== 0, for a mouse event with a non-zero click count
      Any other filter is put into the frontend bundle as a function when the application is built, and the browser runs that function. Both work with a Content Security Policy without unsafe-eval and in the CspMode.STRICT mode. If the bundle does not have the function, for example because the filter changed after the bundle was built, the browser compiles the filter from a string, which such a policy does not allow.
      Returns:
      the filter expression to use, or empty string to not use any filtering
      See Also:
      Default:
      ""
    • debounce

      The debounce settings to use with this event. By default, debounce is not used.
      Returns:
      the debounce settings
      See Also:
      Default:
      @com.vaadin.flow.component.DebounceSettings(timeout=0, phases={LEADING})
    • stopPropagation

      boolean stopPropagation
      Controls if the event is let to propagate to parent elements.
      Returns:
      true if the event is not let to propagate to parent elements
      Since:
      24.2
      Default:
      false
    • preventDefault

      boolean preventDefault
      Controls if the browser is asked to prevent the default browser behavior.
      Returns:
      true if default behavior is should be prevented
      Since:
      24.2
      Default:
      false
    • allowInert

      boolean allowInert
      Controls whether this event listener should bypass the server-side security checks for modality. When set to true, the listener will receive events even when the component is behind a modal component's modality curtain (i.e., when the component is inert).

      Handle with care! This should only be used for cases where the event needs to be processed regardless of the component's modal state, such as geolocation updates or other non-UI related events.

      Returns:
      true if the listener should receive events even when the component is inert, false otherwise (default)
      Since:
      25.1
      See Also:
      Default:
      false