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.
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:
-
Nested Class Summary
Nested 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<String> onError) Creates a fullscreen action whose outcome is reported back to the server viaonSuccess/onError. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappendPromiseExpression(com.vaadin.flow.component.trigger.internal.JsBuilder builder, StringBuilder out) Subclasses append a JS expression that evaluates to aPromisewhen the trigger fires.Methods inherited from class com.vaadin.flow.component.trigger.internal.PromiseAction
appendStatement
-
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<String> onError) Creates a fullscreen action whose outcome is reported back to the server viaonSuccess/onError. SeePromiseActionfor the contract on both consumers.- 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 message after the client reportsrequestFullscreenrejected, notnull
-
-
Method Details
-
appendPromiseExpression
protected void appendPromiseExpression(com.vaadin.flow.component.trigger.internal.JsBuilder builder, StringBuilder out) Description copied from class:PromiseActionSubclasses append a JS expression that evaluates to aPromisewhen the trigger fires. The result of that promise is whatonSuccess/onErrorobserve; the resolved value itself is not delivered to the server (only success vs. failure and the rejection message).- Specified by:
appendPromiseExpressionin classPromiseAction- Parameters:
builder- collects element parameter references, notnullout- buffer to append into, notnull
-