Class RequestFullscreenAction

All Implemented Interfaces:
Serializable

public class RequestFullscreenAction extends PromiseAction
Asks the browser to fullscreen the target component's root element via Element.requestFullscreen() when the bound trigger fires.

The Fullscreen API requires transient user activation (a click, key press, …) — calling requestFullscreen from a server push or constructor is rejected by the browser. Bind this action to a Trigger that fires during such a gesture, typically a ClickTrigger, so the call happens synchronously inside the handler and inherits the gesture.

Note that fullscreening an arbitrary component element does not interact well with Vaadin theming or overlay components — those expect the fullscreen element to be document.documentElement. This action is intentionally low-level; the higher-level Component.requestFullscreen() facade handles the wrapping needed for full Vaadin compatibility.

Outcome handling is inherited from PromiseAction: use the target-only constructor for fire-and-forget, or the overload taking onSuccess/onError consumers to react to the requestFullscreen promise on the UI thread.


 RequestFullscreenAction goFs = new RequestFullscreenAction(panel,
         () -> notification.show("Fullscreen entered"),
         err -> notification.show("Fullscreen denied: " + err));
 new ClickTrigger(button).triggers(goFs);
 
For internal use only. May be renamed or removed in a future release.
See Also:
  • Constructor Details

    • RequestFullscreenAction

      public RequestFullscreenAction(Component target)
      Creates a fire-and-forget fullscreen action: the rendered JS just calls requestFullscreen() and the server never sees the outcome.
      Parameters:
      target - the component whose root element to fullscreen, not null
    • RequestFullscreenAction

      public RequestFullscreenAction(Component target, SerializableRunnable onSuccess, SerializableConsumer<String> onError)
      Creates a fullscreen action whose outcome is reported back to the server via onSuccess/onError. See PromiseAction for the contract on both consumers.
      Parameters:
      target - the component whose root element to fullscreen, not null
      onSuccess - invoked on the UI thread after the client reports requestFullscreen resolved, not null
      onError - invoked on the UI thread with the browser's error message after the client reports requestFullscreen rejected, not null
  • Method Details

    • appendPromiseExpression

      protected void appendPromiseExpression(com.vaadin.flow.component.trigger.internal.JsBuilder builder, StringBuilder out)
      Description copied from class: PromiseAction
      Subclasses append a JS expression that evaluates to a Promise when the trigger fires. The result of that promise is what onSuccess/onError observe; the resolved value itself is not delivered to the server (only success vs. failure and the rejection message).
      Specified by:
      appendPromiseExpression in class PromiseAction
      Parameters:
      builder - collects element parameter references, not null
      out - buffer to append into, not null