Interface Trigger

All Superinterfaces:
Serializable
All Known Implementing Classes:
AbstractTrigger, ClickTrigger, JsTrigger, ShortcutTrigger

public interface Trigger extends Serializable
Something that fires on the client and, when it does, runs one or more actions synchronously inside the original DOM event handler.

A trigger is bound to a host element. It is created with one of the built-in subclasses or with an add-on subclass of AbstractTrigger, and then wired to actions via triggers(com.vaadin.flow.component.trigger.Action...):


 Trigger click = new ClickTrigger(button);
 click.triggers(new ClipboardCopyAction(
         new PropertyOutput<>(textField, "value", String.class)));
 
Calling triggers more than once is additive — every subsequent call adds another binding to the same trigger.

Triggers and actions run client-side without a server round-trip. Actions may still cause a server round-trip if they have a server-side effect (e.g. updating a server-side property mirror) or if a server callback is attached via triggers(SerializableRunnable).

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes this trigger and all bindings created from it.
    triggers(Action... actions)
    Wires the given actions to this trigger.
    Wires a server-side callback to this trigger.
  • Method Details

    • triggers

      Trigger triggers(Action... actions)
      Wires the given actions to this trigger. They run in the order given, inside the original DOM event handler, the next time this trigger fires.
      Parameters:
      actions - the actions to run, not null
      Returns:
      this trigger, for chaining
    • triggers

      Trigger triggers(SerializableRunnable serverHandler)
      Wires a server-side callback to this trigger. The callback runs after the client-side dispatch of any other bound actions has finished. The callback fires on the UI thread.

      This is sugar for adding a ServerCallbackAction that wraps the given runnable.

      Parameters:
      serverHandler - the runnable to execute on the server, not null
      Returns:
      this trigger, for chaining
    • remove

      void remove()
      Removes this trigger and all bindings created from it. The corresponding client-side handlers are detached as part of the next synchronisation.