Class RequestFullscreenAction
- All Implemented Interfaces:
Serializable
Two modes:
- Page — calls
window.Vaadin.Flow.fullscreen .requestPageFullscreen()which fullscreensdocument.documentElement. Themes and overlay components keep working. - Component — calls
window.Vaadin.Flow.fullscreen .requestComponentFullscreen(element, wrapper)which moves the target into the Vaadin wrapper element, hides the rest of the view, and fullscreensdocument.documentElement. The component is restored to its original position when fullscreen exits (programmatically, via Escape, or a superseding request).
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.
Outcome handling extends PromiseAction: use the fire-and-forget
constructors, or the overloads 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
ConstructorsConstructorDescriptionCreates a fire-and-forget page-level fullscreen action.RequestFullscreenAction(Component target) Creates a fire-and-forget component-level fullscreen action.RequestFullscreenAction(Component target, SerializableRunnable onSuccess, SerializableConsumer<PromiseAction.Error> onError) Creates a component-level fullscreen action whose outcome is reported back to the server.RequestFullscreenAction(SerializableRunnable onSuccess, SerializableConsumer<PromiseAction.Error> onError) Creates a page-level 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
toJsMethods inherited from class com.vaadin.flow.component.trigger.internal.Action
warnIfNotVisible
-
Constructor Details
-
RequestFullscreenAction
public RequestFullscreenAction()Creates a fire-and-forget page-level fullscreen action. The rendered JS callsrequestPageFullscreen()and the server never sees the outcome. -
RequestFullscreenAction
public RequestFullscreenAction(SerializableRunnable onSuccess, SerializableConsumer<PromiseAction.Error> onError) Creates a page-level fullscreen action whose outcome is reported back to the server.- Parameters:
onSuccess- invoked on the UI thread after the client reports the request resolved, notnullonError- invoked on the UI thread with the browser's error after the client reports the request rejected, notnull
-
RequestFullscreenAction
Creates a fire-and-forget component-level fullscreen action. The component is moved into the UI's wrapper element so themes and overlay components keep working.- Parameters:
target- the component to fullscreen, notnull; must be attached to a UI
-
RequestFullscreenAction
public RequestFullscreenAction(Component target, SerializableRunnable onSuccess, SerializableConsumer<PromiseAction.Error> onError) Creates a component-level fullscreen action whose outcome is reported back to the server.- Parameters:
target- the component to fullscreen, notnull; must be attached to a UIonSuccess- invoked on the UI thread after the client reports the request resolved, notnullonError- invoked on the UI thread with the browser's error after the client reports the request rejected, 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
-