Class RequestFullscreenAction
- All Implemented Interfaces:
Serializable
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.
This action is intentionally low-level: it calls requestFullscreen
directly on the target's root element. That doesn't interact well with Vaadin
theming or overlay components, which expect the fullscreen element to be
document.documentElement. A higher-level
Component.requestFullscreen() facade — see PR vaadin/flow#24326 —
handles the wrapping needed for full Vaadin compatibility; this action is the
trigger-framework primitive it builds on (or a direct option when the Vaadin
wrapping isn't needed).
Outcome handling extends PromiseAction: use the target-only
constructor for fire-and-forget, or the overload taking
onSuccess/onError consumers. The promise resolves with
undefined so onSuccess is a SerializableRunnable with
no value, but onError receives a PromiseAction.Error record
with the browser's error name and message — the spec-documented rejection is
NotAllowedError (no gesture / permissions policy).
RequestFullscreenAction goFs = new RequestFullscreenAction(panel,
() -> notification.show("Fullscreen entered"),
err -> notification.show("Fullscreen denied: " + err.message()));
new ClickTrigger(button).triggers(goFs);
For internal use only. May be renamed or removed in a future release.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.trigger.internal.PromiseAction
PromiseAction.ErrorNested classes/interfaces inherited from class com.vaadin.flow.component.trigger.internal.Action
Action.Input<T> -
Constructor Summary
ConstructorsConstructorDescriptionRequestFullscreenAction(Component target) Creates a fire-and-forget fullscreen action: the rendered JS just callsrequestFullscreen()and the server never sees the outcome.RequestFullscreenAction(Component target, SerializableRunnable onSuccess, SerializableConsumer<PromiseAction.Error> onError) Creates a fullscreen action whose outcome is reported back to the server. -
Method Summary
Modifier and TypeMethodDescriptionprotected JsFunctiontoPromiseJs(Trigger trigger) Subclasses return aJsFunctionthat, when invoked with the trigger's event, evaluates to aPromise.Methods inherited from class com.vaadin.flow.component.trigger.internal.PromiseAction
toJs
-
Constructor Details
-
RequestFullscreenAction
Creates a fire-and-forget fullscreen action: the rendered JS just callsrequestFullscreen()and the server never sees the outcome.- Parameters:
target- the component whose root element to fullscreen, notnull
-
RequestFullscreenAction
public RequestFullscreenAction(Component target, SerializableRunnable onSuccess, SerializableConsumer<PromiseAction.Error> onError) Creates a fullscreen action whose outcome is reported back to the server.- Parameters:
target- the component whose root element to fullscreen, notnullonSuccess- invoked on the UI thread after the client reportsrequestFullscreenresolved, notnullonError- invoked on the UI thread with the browser's error after the client reportsrequestFullscreenrejected, notnull
-
-
Method Details
-
toPromiseJs
Description copied from class:PromiseActionSubclasses return aJsFunctionthat, when invoked with the trigger's event, evaluates to aPromise. The value the promise resolves with is decoded toTon the server and handed toonSuccess. To deliver a typed value, subclasses can wrap their API call in an IIFE inside the function body — for example, copying a string and resolving with it:return JsFunction.of( "return ((v) => navigator.clipboard.writeText(v).then(() => v))($0(event))", textInput.toJs(trigger)).withArguments("event");- Specified by:
toPromiseJsin classPromiseAction<Void>- Parameters:
trigger- the surrounding trigger this render is for, notnull- Returns:
- the promise-yielding JS function, not
null
-