public class UIInternals extends Object implements Serializable
Modifier and Type | Class and Description |
---|---|
static class |
UIInternals.JavaScriptInvocation
A
Page.executeJs(String, Serializable...) invocation that has not
yet been sent to the client. |
Constructor and Description |
---|
UIInternals(UI ui)
Creates a new instance for the given UI.
|
Modifier and Type | Method and Description |
---|---|
Registration |
addAfterNavigationListener(AfterNavigationListener listener)
Add a listener that will be informed when new components have been
attached and all navigation tasks have resolved.
|
Registration |
addBeforeEnterListener(BeforeEnterListener listener)
Add a listener that will be informed when a new set of components are
going to be attached.
|
Registration |
addBeforeLeaveListener(BeforeLeaveListener listener)
Add a listener that will be informed when old components are detached.
|
void |
addComponentDependencies(Class<? extends Component> componentClass)
Adds the dependencies defined using
StyleSheet ,
JavaScript or HtmlImport on the given Component class. |
Registration |
addHeartbeatListener(HeartbeatListener listener) |
void |
addJavaScriptInvocation(PendingJavaScriptInvocation invocation)
Adds a JavaScript invocation to be sent to the client.
|
boolean |
cancelPendingTitleUpdate()
Cancels any pending page title update set via
setTitle(String) . |
void |
clearLastHandledNavigation()
Clear latest handled navigation location.
|
List<PendingJavaScriptInvocation> |
dumpPendingJavaScriptInvocations()
Gets all the pending JavaScript invocations and clears the queue.
|
Component |
getActiveDragSourceComponent()
Gets the drag source of an active HTML5 drag event.
|
List<HasElement> |
getActiveRouterTargetsChain()
Gets the currently active router target and parent layouts.
|
Location |
getActiveViewLocation()
Gets the location of the currently shown view.
|
String |
getAppId()
Gets the application id tied with this UI.
|
ConstantPool |
getConstantPool()
Gets the constant pool that is used for keeping track of constants shared
with the client for this UI.
|
String |
getContextRootRelativePath()
Gets the relative path from the UI (servlet) path to the context root.
|
BeforeLeaveEvent.ContinueNavigationAction |
getContinueNavigationAction()
Get stored
BeforeLeaveEvent.ContinueNavigationAction if any. |
DependencyList |
getDependencyList()
Returns the helper which handles loading of dependencies (css, js).
|
ExtendedClientDetails |
getExtendedClientDetails()
The extended client details, if obtained, are cached in this field.
|
Location |
getLastHandledLocation()
Get the latest handled location or empty optional if no active
navigation.
|
long |
getLastHeartbeatTimestamp()
Returns the timestamp of the last received heartbeat for the related UI.
|
int |
getLastProcessedClientToServerId()
Gets the last processed server message id.
|
byte[] |
getLastProcessedMessageHash()
Gets the hash of the last processed message from the client.
|
<E> List<E> |
getListeners(Class<E> handler)
Get all registered listeners for given navigation handler type.
|
PushConnection |
getPushConnection()
Returns the internal push connection object used by the related UI.
|
Router |
getRouter()
Gets the router used for navigating in this UI, if the router was active
when this UI was initialized.
|
int |
getServerSyncId()
Gets the server sync id.
|
VaadinSession |
getSession()
Gets the VaadinSession to which the related UI is attached.
|
StateTree |
getStateTree()
Gets the state tree of the related UI.
|
String |
getTitle()
Gets the page title recorded with
Page.setTitle(String) . |
UI |
getUI()
Gets the UI that this instance belongs to.
|
boolean |
hasLastHandledLocation()
Check if we have already started navigation to some location on this
roundtrip.
|
void |
incrementServerId()
Increments the server sync id.
|
boolean |
isDirty()
Checks if there are changes waiting to be sent to the client side.
|
void |
setActiveDragSourceComponent(Component activeDragSourceComponent)
Sets the drag source of an active HTML5 drag event.
|
void |
setAppId(String appId)
Sets the application id tied with this UI.
|
void |
setContextRoot(String contextRootRelativePath)
Sets the relative path from the UI (servlet) path to the context root.
|
void |
setContinueNavigationAction(BeforeLeaveEvent.ContinueNavigationAction continueNavigationAction)
Set a
BeforeLeaveEvent.ContinueNavigationAction or null to clear existing action. |
void |
setExtendedClientDetails(ExtendedClientDetails details)
Updates the extended client details.
|
void |
setLastHandledNavigation(Location location)
Set the latest navigation location for active navigation.
|
void |
setLastHeartbeatTimestamp(long lastHeartbeat)
Sets the last heartbeat request timestamp for the related UI.
|
void |
setLastProcessedClientToServerId(int lastProcessedClientToServerId,
byte[] lastProcessedMessageHash)
Sets the last processed server message id.
|
void |
setPushConnection(PushConnection pushConnection)
Sets the internal push connection object used by the related UI.
|
void |
setSession(VaadinSession session)
Sets the session to which the related UI is assigned.
|
void |
setTheme(AbstractTheme theme)
Deprecated.
use
setTheme(Class) instead |
void |
setTheme(Class<? extends AbstractTheme> themeClass)
Sets the theme using its
themeClass . |
void |
setTitle(String title)
Records the page title set with
Page.setTitle(String) . |
void |
showRouteTarget(Location viewLocation,
String path,
Component target,
List<RouterLayout> layouts)
Shows a route target in the related UI.
|
public UIInternals(UI ui)
ui
- the UI to usepublic StateTree getStateTree()
public int getLastProcessedClientToServerId()
Used internally for communication tracking.
public byte[] getLastProcessedMessageHash()
The hash is set through
setLastProcessedClientToServerId(int, byte[])
.
Used internally for communication tracking.
null
if no hash has
been setpublic void setLastProcessedClientToServerId(int lastProcessedClientToServerId, byte[] lastProcessedMessageHash)
Used internally for communication tracking.
lastProcessedClientToServerId
- the id of the last processed server messagelastProcessedMessageHash
- the hash of the messagepublic int getServerSyncId()
The sync id is incremented by one whenever a new response is written. This id is then sent over to the client. The client then adds the most recent sync id to each communication packet it sends back to the server. This way, the server knows at what state the client is when the packet is sent. If the state has changed on the server side since that, the server can try to adjust the way it handles the actions from the client side.
The sync id value -1
is ignored to facilitate testing with
pre-recorded requests.
public void incrementServerId()
This should only be called by whoever sends a message to the client, after the message has been sent.
public long getLastHeartbeatTimestamp()
This method is not intended to be overridden. If it is overridden, care
should be taken since this method might be called in situations where
UI.getCurrent()
does not return the UI.
VaadinService.closeInactiveUIs(VaadinSession)
public void setLastHeartbeatTimestamp(long lastHeartbeat)
This method is not intended to be overridden. If it is overridden, care
should be taken since this method might be called in situations where
UI.getCurrent()
does not return the UI.
lastHeartbeat
- The time the last heartbeat request occurred, in milliseconds
since the epoch.public void setSession(VaadinSession session)
This method is for internal use by the framework. To explicitly close a
UI, see UI.close()
.
session
- the session to setIllegalStateException
- if the session has already been setgetSession()
public PushConnection getPushConnection()
This method is not intended to be overridden. If it is overridden, care
should be taken since this method might be called in situations where
UI.getCurrent()
does not return the UI.
null
if push is
not available.public void setPushConnection(PushConnection pushConnection)
The pushConnection
argument must be non-null if and only if
getPushConfiguration().getPushMode().isEnabled()
.
pushConnection
- the push connection to use for the UIpublic Registration addBeforeEnterListener(BeforeEnterListener listener)
listener
- the before enter listenerpublic Registration addBeforeLeaveListener(BeforeLeaveListener listener)
listener
- the before leave listenerpublic Registration addAfterNavigationListener(AfterNavigationListener listener)
listener
- the after navigation listenerpublic Registration addHeartbeatListener(HeartbeatListener listener)
public <E> List<E> getListeners(Class<E> handler)
E
- the handler typehandler
- handler to get listeners forpublic void addJavaScriptInvocation(PendingJavaScriptInvocation invocation)
invocation
- the invocation to addpublic List<PendingJavaScriptInvocation> dumpPendingJavaScriptInvocations()
public void setTitle(String title)
Page.setTitle(String)
.
You should not set the page title for the browser with this method, use
Page.setTitle(String)
instead.
title
- the title to setpublic String getTitle()
Page.setTitle(String)
.
NOTE this might not be up to date with the actual title set since
it is not updated from the browser and the update might have been
canceled before it has been sent to the browser with
cancelPendingTitleUpdate()
.
public boolean cancelPendingTitleUpdate()
setTitle(String)
.true
if pending title update was cancelled,
false
if notpublic void showRouteTarget(Location viewLocation, String path, Component target, List<RouterLayout> layouts)
UI.navigate(String)
to change the route
target that is shown in a UI.viewLocation
- the location of the route target relative to the servlet
serving the UI, not null
target
- the component to show, not null
path
- the resolved route path so we can determine what the rendered
target is forlayouts
- the parent layouts@Deprecated public void setTheme(AbstractTheme theme)
setTheme(Class)
instead
Note! The set theme will be overridden for each call to
showRouteTarget(Location, String, Component, List)
if the new
theme is not the same as the set theme.
This method is intended for managed internal use only.
theme
- theme implementation to setpublic void setTheme(Class<? extends AbstractTheme> themeClass)
themeClass
.
Note! The set theme will be overridden for each call to
showRouteTarget(Location, String, Component, List)
if the new
theme is not the same as the set theme.
This method is intended for managed internal use only.
themeClass
- theme class to set, may be null
setTheme(AbstractTheme)
public List<HasElement> getActiveRouterTargetsChain()
public Location getActiveViewLocation()
null
public VaadinSession getSession()
The method will return null
if the UI is not currently attached
to a VaadinSession.
public DependencyList getDependencyList()
public void addComponentDependencies(Class<? extends Component> componentClass)
StyleSheet
,
JavaScript
or HtmlImport
on the given Component class.componentClass
- the component class to read annotations frompublic ConstantPool getConstantPool()
null
public Location getLastHandledLocation()
null
public void setLastHandledNavigation(Location location)
location
- last location navigated topublic boolean hasLastHandledLocation()
!=
nullpublic void clearLastHandledNavigation()
public BeforeLeaveEvent.ContinueNavigationAction getContinueNavigationAction()
BeforeLeaveEvent.ContinueNavigationAction
if any.public void setContinueNavigationAction(BeforeLeaveEvent.ContinueNavigationAction continueNavigationAction)
BeforeLeaveEvent.ContinueNavigationAction
or null to clear existing action.continueNavigationAction
- continue navigation action to store or nullpublic void setAppId(String appId)
appId
- the id of the application tied with this UIpublic String getAppId()
public Router getRouter()
null
if there is no
routerpublic boolean isDirty()
true
if there are pending changes,
false
otherwisepublic void setContextRoot(String contextRootRelativePath)
contextRootRelativePath
- the relative path from servlet to context rootpublic String getContextRootRelativePath()
public void setActiveDragSourceComponent(Component activeDragSourceComponent)
activeDragSourceComponent
- the drag source componentpublic Component getActiveDragSourceComponent()
public UI getUI()
public ExtendedClientDetails getExtendedClientDetails()
public void setExtendedClientDetails(ExtendedClientDetails details)
details
- the updated extended client details.Copyright © 2020. All rights reserved.