Class UIInternals
- All Implemented Interfaces:
Serializable
For internal use only. May be renamed or removed in a future release.
- Since:
- 1.0
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
APage.executeJs(String, Serializable...)
invocation that has not yet been sent to the client. -
Constructor Summary
ConstructorDescriptionUIInternals
(UI ui) Creates a new instance for the given UI.UIInternals
(UI ui, UIInternalUpdater internalsHandler) Creates a new instance for the given UI. -
Method Summary
Modifier and TypeMethodDescriptionAdd a listener that will be informed when new components have been attached and all navigation tasks have resolved.addBeforeEnterListener
(BeforeEnterListener listener) Add a listener that will be informed when a new set of components are going to be attached.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 usingStyleSheet
orJavaScript
on the given Component class.addHeartbeatListener
(HeartbeatListener listener) void
addJavaScriptInvocation
(PendingJavaScriptInvocation invocation) Adds a JavaScript invocation to be sent to the client.boolean
Cancels any pending page title update set viasetTitle(String)
.void
Clear latest handled navigation location.Gets all the pending JavaScript invocations that are ready to be sent to a client.Gets the drag source of an active HTML5 drag event.Get the active modal component if modal components set.Gets the currently active router target and parent layouts.Gets the location of the currently shown view.getAppId()
Gets the application id tied with this UI.Gets the stored app shell title.Gets the constant pool that is used for keeping track of constants shared with the client for this UI.Gets the relative path from the UI (servlet) path to the context root.Get storedBeforeLeaveEvent.ContinueNavigationAction
if any.Returns the helper which handles loading of dependencies (css, js).The extended client details, if obtained, are cached in this field.Gets the full app id, which funnily enough is not the same as appId.Get the latest handled location or empty optional if no active navigation.long
Returns the timestamp of the last received heartbeat for the related UI.int
Gets the last processed server message id.byte[]
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.Returns the internal push connection object used by the related UI.Gets the router used for navigating in this UI, if the router was active when this UI was initialized.int
Gets the server sync id.Gets the VaadinSession to which the related UI is attached.Gets the state tree of the related UI.getTitle()
Gets the page title recorded withPage.setTitle(String)
.getUI()
Gets the UI that this instance belongs to.boolean
Check if we have already started navigation to some location on this roundtrip.boolean
Check if we have a modal component defined for the UI.void
Increments the server sync id.boolean
isDirty()
Checks if there are changes waiting to be sent to the client side.void
moveElementsFrom
(UI otherUI) Move all the children of the other UI to this current UI.void
setActiveDragSourceComponent
(Component activeDragSourceComponent) Sets the drag source of an active HTML5 drag event.void
setAppShellTitle
(String appShellTitle) Records the text content of the title tag in the application shell.void
setChildModal
(Component child) Makes an existing child component modal.void
setChildModeless
(Component child) Sets the given child modeless.void
setContextRoot
(String contextRootRelativePath) Sets the relative path from the UI (servlet) path to the context root.void
setContinueNavigationAction
(BeforeLeaveEvent.ContinueNavigationAction continueNavigationAction) Set aBeforeLeaveEvent.ContinueNavigationAction
or null to clear existing action.void
Updates the extended client details.void
setFullAppId
(String fullAppId) Sets the application id tied with this UI.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
Records the page title set withPage.setTitle(String)
.void
showRouteTarget
(Location viewLocation, Component target, List<RouterLayout> layouts) Shows a route target in the related UI.
-
Constructor Details
-
UIInternals
Creates a new instance for the given UI.- Parameters:
ui
- the UI to use
-
UIInternals
Creates a new instance for the given UI.- Parameters:
ui
- the UI to useinternalsHandler
- an implementation ofUIInternalUpdater
-
-
Method Details
-
getStateTree
Gets the state tree of the related UI.- Returns:
- the state tree
-
getLastProcessedClientToServerId
public int getLastProcessedClientToServerId()Gets the last processed server message id.Used internally for communication tracking.
- Returns:
- lastProcessedServerMessageId the id of the last processed server message
-
getLastProcessedMessageHash
public byte[] getLastProcessedMessageHash()Gets the hash of the last processed message from the client.The hash is set through
setLastProcessedClientToServerId(int, byte[])
.Used internally for communication tracking.
- Returns:
- the hash as a byte array, or
null
if no hash has been set
-
setLastProcessedClientToServerId
public void setLastProcessedClientToServerId(int lastProcessedClientToServerId, byte[] lastProcessedMessageHash) Sets the last processed server message id.Used internally for communication tracking.
- Parameters:
lastProcessedClientToServerId
- the id of the last processed server messagelastProcessedMessageHash
- the hash of the message
-
getServerSyncId
public int getServerSyncId()Gets the server sync id.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.- Returns:
- the server sync id
-
incrementServerId
public void incrementServerId()Increments the server sync id.This should only be called by whoever sends a message to the client, after the message has been sent.
-
getLastHeartbeatTimestamp
public long getLastHeartbeatTimestamp()Returns the timestamp of the last received heartbeat for the related UI.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.- Returns:
- The time the last heartbeat request occurred, in milliseconds since the epoch.
- See Also:
-
VaadinService.closeInactiveUIs(VaadinSession)
-
setLastHeartbeatTimestamp
public void setLastHeartbeatTimestamp(long lastHeartbeat) Sets the last heartbeat request timestamp for the related UI. Called by the framework whenever the application receives a valid heartbeat request for the UI.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.- Parameters:
lastHeartbeat
- The time the last heartbeat request occurred, in milliseconds since the epoch.
-
setSession
Sets the session to which the related UI is assigned.This method is for internal use by the framework. To explicitly close a UI, see
UI.close()
.- Parameters:
session
- the session to set- Throws:
IllegalStateException
- if the session has already been set- See Also:
-
getPushConnection
Returns the internal push connection object used by the related UI. This method should only be called by the framework.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.- Returns:
- the push connection used by the UI, or
null
if push is not available.
-
setPushConnection
Sets the internal push connection object used by the related UI. This method should only be called by the framework.The
pushConnection
argument must be non-null if and only ifgetPushConfiguration().getPushMode().isEnabled()
.- Parameters:
pushConnection
- the push connection to use for the UI
-
addBeforeEnterListener
Add a listener that will be informed when a new set of components are going to be attached.- Parameters:
listener
- the before enter listener- Returns:
- handler to remove the event listener
-
addBeforeLeaveListener
Add a listener that will be informed when old components are detached.- Parameters:
listener
- the before leave listener- Returns:
- handler to remove the event listener
-
addHeartbeatListener
-
getListeners
Get all registered listeners for given navigation handler type.- Type Parameters:
E
- the handler type- Parameters:
handler
- handler to get listeners for- Returns:
- unmodifiable list of registered listeners for navigation handler
-
addJavaScriptInvocation
Adds a JavaScript invocation to be sent to the client.- Parameters:
invocation
- the invocation to add
-
dumpPendingJavaScriptInvocations
Gets all the pending JavaScript invocations that are ready to be sent to a client. Retains pending JavaScript invocations owned by invisible components in the queue.- Returns:
- a list of pending JavaScript invocations
-
setTitle
Records the page title set withPage.setTitle(String)
.You should not set the page title for the browser with this method, use
Page.setTitle(String)
instead.- Parameters:
title
- the title to set
-
setAppShellTitle
Records the text content of the title tag in the application shell.NOTE Intended for internal use, you should not call this method.
- Parameters:
appShellTitle
- the appShellTitle to set
-
getTitle
Gets the page title recorded withPage.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()
.- Returns:
- the page title
-
getAppShellTitle
Gets the stored app shell title.NOTE Intended for internal use, you should not call this method.
- Returns:
- the app shell title
-
cancelPendingTitleUpdate
public boolean cancelPendingTitleUpdate()Cancels any pending page title update set viasetTitle(String)
.- Returns:
true
if pending title update was cancelled,false
if not
-
showRouteTarget
Shows a route target in the related UI. This method is intended for framework use only. UseUI.navigate(String)
to change the route target that is shown in a UI.- Parameters:
viewLocation
- the location of the route target relative to the servlet serving the UI, notnull
target
- the component to show, notnull
layouts
- the parent layouts
-
moveElementsFrom
Move all the children of the other UI to this current UI.- Parameters:
otherUI
- the other UI to transfer content from.
-
getActiveRouterTargetsChain
Gets the currently active router target and parent layouts.- Returns:
- a list of active router target and parent layout instances, starting from the innermost part
-
getActiveViewLocation
Gets the location of the currently shown view. The location is relative the servlet mapping used for serving the related UI.- Returns:
- the view location, not
null
-
getSession
Gets the VaadinSession to which the related UI is attached.The method will return
null
if the UI is not currently attached to a VaadinSession.- Returns:
- the VaadinSession to which the related UI is attached
-
getDependencyList
Returns the helper which handles loading of dependencies (css, js).- Returns:
- the dependency list helper
-
addComponentDependencies
Adds the dependencies defined usingStyleSheet
orJavaScript
on the given Component class.- Parameters:
componentClass
- the component class to read annotations from
-
getConstantPool
Gets the constant pool that is used for keeping track of constants shared with the client for this UI.- Returns:
- the constant pool to use, not
null
-
getLastHandledLocation
Get the latest handled location or empty optional if no active navigation.- Returns:
- location if navigated during active navigation or
null
-
hasLastHandledLocation
public boolean hasLastHandledLocation()Check if we have already started navigation to some location on this roundtrip.- Returns:
- true if the last navigation location
!=
null
-
setFullAppId
Sets the application id tied with this UI. Different applications in the same page have different unique ids.- Parameters:
fullAppId
- the (full, not stripped) id of the application tied with this UI
-
getAppId
Gets the application id tied with this UI. Different applications in the same page have different unique ids.- Returns:
- the id of the application tied with this UI
-
getFullAppId
Gets the full app id, which funnily enough is not the same as appId. This really should be removed but not right now. Don't use this method, it will be gone.- Returns:
- the full app id
-
getRouter
Gets the router used for navigating in this UI, if the router was active when this UI was initialized.- Returns:
- the router used for this UI, or
null
if there is no router or the UI doesn't support navigation.
-
isDirty
public boolean isDirty()Checks if there are changes waiting to be sent to the client side.- Returns:
true
if there are pending changes,false
otherwise
-
setContextRoot
Sets the relative path from the UI (servlet) path to the context root.- Parameters:
contextRootRelativePath
- the relative path from servlet to context root
-
getContextRootRelativePath
Gets the relative path from the UI (servlet) path to the context root.- Returns:
- the relative path from servlet to context root
-
setActiveDragSourceComponent
Sets the drag source of an active HTML5 drag event.- Parameters:
activeDragSourceComponent
- the drag source component- Since:
- 2.0
-
getActiveDragSourceComponent
Gets the drag source of an active HTML5 drag event.- Returns:
- Extension of the drag source component if the drag event is active and originated from this UI, null otherwise.
- Since:
- 2.0
-
getUI
Gets the UI that this instance belongs to.- Returns:
- the UI instance.
-
getExtendedClientDetails
The extended client details, if obtained, are cached in this field.- Returns:
- the extended client details, or null if not yet received.
-
setExtendedClientDetails
Updates the extended client details.- Parameters:
details
- the updated extended client details.
-
hasModalComponent
public boolean hasModalComponent()Check if we have a modal component defined for the UI.- Returns:
true
if modal component is defined
-
getActiveModalComponent
Get the active modal component if modal components set.- Returns:
- the current active modal component
-
setChildModal
Makes an existing child component modal. This will make the UI and the other components inside it inert - they will not react to any user interaction until the modal component is removed.In case there was an existing modal component in the UI already, that is made inert until the given new component is removed. The UI is no longer inert after all modal components have been removed from it. Inert state is updated automatically when a component is removed from the UI, no need to call anything. Moving an inert component will remove inert status.
- Parameters:
child
- the child component to toggle modal
-
setChildModeless
Sets the given child modeless. The inert state of the UI and other child components is updated. This method is called automatically when a modal child component is removed from the UI.- Parameters:
child
- the child component to make modeless
-
getContainerTag
-