com.vaadin.ui.
Class UI
-
All Implemented Interfaces:
Action.Container
,Action.Notifier
,ConnectorEventListener
,ContextClickEvent.ContextClickNotifier
,MethodEventSource
,SerializableEventListener
,UIEvents.PollNotifier
,ClientConnector
,Sizeable
,VariableOwner
,Connector
,Component
,Component.Focusable
,HasComponents
,HasComponents.ComponentAttachDetachNotifier
,LegacyComponent
,SingleComponentContainer
,Serializable
,Iterable<Component>
,EventListener
Direct Known Subclasses:
public abstract class UI extends AbstractSingleComponentContainer implements Action.Notifier, UIEvents.PollNotifier, LegacyComponent, Component.Focusable
The topmost component in any component hierarchy. There is one UI for every Vaadin instance in a browser window. A UI may either represent an entire browser window (or tab) or some part of a html page where a Vaadin application is embedded.
The UI is the server side entry point for various client side features that are not represented as components added to a layout, e.g notifications, sub windows, and executing javascript in the browser.
When a new UI instance is needed, typically because the user opens a URL in a browser window which points to e.g.
VaadinServlet
, allUIProvider
s registered to the currentVaadinSession
are queried for the UI class that should be used. The selection is by default based on theUI
init parameter from web.xml.After a UI has been created by the application, it is initialized using
init(VaadinRequest)
. This method is intended to be overridden by the developer to add components to the user interface and initialize non-component functionality. The component hierarchy must be initialized by passing aComponent
with the main layout or other content of the view tosetContent(Component)
or to the constructor of the UI.Since:
7.0
See Also:
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
UI.DelayedCallback
An interface for the callback in
runAfterRoundTrip(DelayedCallback)
.static interface
UI.DelayedCallbackRegistration
An interface used for keeping track of callback requests registered via
runAfterRoundTrip(DelayedCallback)
.static class
UI.WindowOrderUpdateEvent
Event which is fired when the ordering of the windows is updated.
static interface
UI.WindowOrderUpdateListener
An interface used for listening to Windows order update events.
-
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.HasComponents
HasComponents.ComponentAttachDetachNotifier, HasComponents.ComponentAttachEvent, HasComponents.ComponentAttachListener, HasComponents.ComponentDetachEvent, HasComponents.ComponentDetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
-
-
Field Summary
Fields Modifier and Type Field Description protected ActionManager
actionManager
Keeps track of the Actions added to this component, and manages the painting and handling as well.
-
Fields inherited from class com.vaadin.ui.AbstractComponent
DESIGN_ATTR_PLAIN_TEXT
-
Fields inherited from interface com.vaadin.server.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
-
-
Method Summary
All Methods Modifier and Type Method Description Future<Void>
access(Runnable runnable)
Provides exclusive access to this UI from outside a request handling thread.
void
accessSynchronously(Runnable runnable)
Locks the session of this UI and runs the provided Runnable right away.
<T extends Action & Action.Listener>
voidaddAction(T action)
void
addActionHandler(Action.Handler actionHandler)
Registers a new action handler for this container.
Registration
addClickListener(MouseEvents.ClickListener listener)
Add a click listener to the UI.
Registration
addPollListener(UIEvents.PollListener listener)
Add a poll listener.
void
addWindow(Window window)
Adds a window as a subwindow inside this UI.
Registration
addWindowOrderUpdateListener(UI.WindowOrderUpdateListener listener)
Adds a WindowOrderUpdateListener to the UI.
void
attach()
Called after the UI is added to the session.
void
changeVariables(Object source, Map<String,Object> variables)
Called when one or more variables handled by the implementing class are changed.
void
close()
Marks this UI to be
detached
from the session at the end of the current request, or the next request if there is no current request (if called from a background thread, for instance.)void
detach()
Called before the UI is removed from the session.
void
doInit(VaadinRequest request, int uiId, String embedId)
Internal initialization method, should not be overridden.
void
doRefresh(VaadinRequest request)
Internal reinitialization method, should not be overridden.
void
focus()
Sets the focus for this component if the component is
Component.Focusable
.protected ActionManager
getActionManager()
Gets the
ActionManager
used to manage theShortcutListener
s added to this component.DragSourceExtension<? extends AbstractComponent>
getActiveDragSource()
Gets the drag source of an active HTML5 drag event.
int
getComponentCount()
Gets the number of children this
SingleComponentContainer
has.ConnectorTracker
getConnectorTracker()
static UI
getCurrent()
Gets the currently used UI.
String
getEmbedId()
Gets a string the uniquely distinguishes this UI instance based on where it is embedded.
long
getLastHeartbeatTimestamp()
Returns the timestamp of the last received heartbeat for this UI.
int
getLastProcessedClientToServerId()
Gets the last processed server message id.
LoadingIndicatorConfiguration
getLoadingIndicatorConfiguration()
Retrieves the object used for configuring the loading indicator.
LocaleService
getLocaleService()
Returns the locale service which handles transmission of Locale data to the client.
Navigator
getNavigator()
Returns the navigator attached to this UI or null if there is no navigator.
NotificationConfiguration
getNotificationConfiguration()
Retrieves the object used for configuring notifications.
String
getOverlayContainerLabel()
Get the label that is added to the container element, where tooltip, notification and dialogs are added to.
Page
getPage()
int
getPollInterval()
Returns the interval with which the UI polls the server.
PushConfiguration
getPushConfiguration()
Retrieves the object used for configuring the push channel.
PushConnection
getPushConnection()
Returns the internal push connection object used by this UI.
ReconnectDialogConfiguration
getReconnectDialogConfiguration()
Retrieves the object used for configuring the reconnect dialog.
int
getScrollLeft()
int
getScrollTop()
VaadinSession
getSession()
Gets the application object to which the component is attached.
protected UIState
getState()
Returns the shared state bean with information to be sent from the server to the client.
protected UIState
getState(boolean markAsDirty)
Returns the shared state for this connector.
Class<? extends UIState>
getStateType()
Returns the type of the shared state for this connector.
int
getTabIndex()
Gets the tabulator index of the
Focusable
component.String
getTheme()
Gets the theme currently in use by this UI.
TooltipConfiguration
getTooltipConfiguration()
Retrieves the object used for configuring tooltips.
UI
getUI()
Overridden to return a value instead of referring to the parent.
int
getUIId()
Gets the id of the UI, used to identify this UI within its application when processing requests.
String
getUiPathInfo()
Gets the path info part of the request that is used to detect the UI.
String
getUiRootPath()
Gets the part of path (from browser's URL) that points to this UI.
Collection<Window>
getWindows()
Gets all the windows added to this UI.
protected abstract void
init(VaadinRequest request)
Initializes this UI.
boolean
isClosing()
Returns whether this UI is marked as closed and is to be detached.
boolean
isConnectorEnabled()
Checks if the communicator is enabled.
boolean
isMobileHtml5DndEnabled()
Returns whether HTML5 DnD extensions
DragSourceExtension
andDropTargetExtension
and alike should be enabled for mobile devices.boolean
isResizeLazy()
Checks whether lazy resize is enabled.
boolean
isUsingThoroughSizeCheck()
Returns whether LayoutManager uses thorough size check that evaluates the presence of the element and uses calculated size, or defaults to a slightly faster check that can result in incorrect size information if the check is triggered while a transform animation is ongoing.
Iterator<Component>
iterator()
Gets an iterator to the collection of contained components.
void
paintContent(PaintTarget target)
Paints the Paintable into a UIDL stream.
void
push()
Pushes the pending changes and client RPC invocations of this UI to the client-side.
protected void
refresh(VaadinRequest request)
Reinitializes this UI after a browser refresh if the UI is set to be preserved on refresh, typically using the
PreserveOnRefresh
annotation.<T extends Action & Action.Listener>
voidremoveAction(T action)
void
removeActionHandler(Action.Handler actionHandler)
Removes a previously registered action handler for the contents of this container.
void
removeClickListener(MouseEvents.ClickListener listener)
Deprecated.
As of 8.0, replaced byRegistration.remove()
in the registration object returned fromremoveClickListener(ClickListener)
.void
removePollListener(UIEvents.PollListener listener)
Deprecated.
boolean
removeWindow(Window window)
Remove the given subwindow from this UI.
UI.DelayedCallbackRegistration
runAfterRoundTrip(UI.DelayedCallback callback)
Executes the given callback function after a single client round-trip.
UI.DelayedCallbackRegistration
runAfterRoundTrip(UI.DelayedCallback callback, int numberOfRoundTripsToWait)
Executes the given callback function after the given number of client round-trips.
UI.DelayedCallbackRegistration
runAfterRoundTrip(UI.DelayedCallback callback, UI.DelayedCallback cancelCallback)
Executes the given callback function after a single client round-trip, or the cancel callback if the execution is cancelled through
UI.DelayedCallbackRegistration.cancel()
.UI.DelayedCallbackRegistration
runAfterRoundTrip(UI.DelayedCallback callback, UI.DelayedCallback cancelCallback, int numberOfRoundTripsToWait)
Executes the given callback function after the given number of client round-trips, or the cancel callback if the execution is cancelled through
UI.DelayedCallbackRegistration.cancel()
.void
scrollIntoView(Component component)
Scrolls any component between the component and UI to a suitable position so the component is visible to the user.
void
setActiveDragSource(DragSourceExtension<? extends AbstractComponent> extension)
Sets the drag source of an active HTML5 drag event.
void
setCaption(String caption)
Deprecated.
As of 7.0, usePage.setTitle(String)
void
setContent(Component content)
Sets the content of this container.
static void
setCurrent(UI ui)
Sets the thread local for the current UI.
protected void
setDisconnectPushOnRefresh(boolean disconnectPushOnRefresh)
Normally when UI is refreshed when PreserveOnRefresh is used, UI checks if Push connection is active and disconnects it in order to avoid race condition.
void
setFocusedComponent(Component.Focusable focusable)
This method is used by Component.Focusable objects to request focus to themselves.
void
setLastHeartbeatTimestamp(long lastHeartbeat)
Sets the last heartbeat request timestamp for this UI.
void
setLastProcessedClientToServerId(int lastProcessedClientToServerId)
Sets the last processed server message id.
void
setMobileHtml5DndEnabled(boolean enabled)
Enable or disable HTML5 DnD for mobile devices.
void
setNavigator(Navigator navigator)
For internal use only.
void
setOverlayContainerLabel(String overlayContainerLabel)
Sets the label that is added to the container element, where tooltip, notifications and dialogs are added to.
void
setPollInterval(int intervalInMillis)
Sets the interval with which the UI should poll the server to see if there are any changes.
void
setPushConnection(PushConnection pushConnection)
Sets the internal push connection object used by this UI.
void
setResizeLazy(boolean resizeLazy)
Should resize operations be lazy, i.e.
void
setScrollLeft(int scrollLeft)
Set left offset to which the UI should scroll to.
void
setScrollTop(int scrollTop)
Set top offset to which the UI should scroll to.
void
setSession(VaadinSession session)
Sets the session to which this UI is assigned.
void
setTabIndex(int tabIndex)
Sets the tabulator index of the
Focusable
component.void
setTheme(String theme)
Sets the theme currently in use by this UI
void
setUsingThoroughSizeCheck(boolean thoroughSizeCheck)
Set whether LayoutManager should use thorough size check that evaluates the presence of the element and uses calculated size, or default to a slightly faster check that can result in incorrect size information if the check is triggered while a transform animation is ongoing.
void
showNotification(Notification notification)
Deprecated.
As of 7.0, use Notification.show insteadvoid
showNotification(String caption)
Deprecated.
As of 7.0, use Notification.show instead but be aware that Notification.show does not allow HTML.void
showNotification(String caption, Notification.Type type)
Deprecated.
As of 7.0, use Notification.show instead but be aware that Notification.show does not allow HTML.void
showNotification(String caption, String description)
Deprecated.
As of 7.0, use new Notification(...).show(Page) instead but be aware that HTML by default not allowed.void
showNotification(String caption, String description, Notification.Type type)
Deprecated.
As of 7.0, use new Notification(...).show(Page) instead but be aware that HTML by default not allowed.void
showNotification(String caption, String description, Notification.Type type, boolean htmlContentAllowed)
Deprecated.
As of 7.0, use new Notification(...).show(Page).-
Methods inherited from class com.vaadin.ui.AbstractSingleComponentContainer
addComponentAttachListener, addComponentDetachListener, fireComponentAttachEvent, fireComponentDetachEvent, getContent, readDesign, readDesignChildren, removeComponentAttachListener, removeComponentDetachListener, removeFromParent, setHeight, setWidth, writeDesign
-
Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, beforeClientResponse, findAncestor, fireComponentErrorEvent, fireComponentEvent, getCaption, getComponentError, getCustomAttributes, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isEnabled, isOrHasAncestor, isReadOnly, isRequiredIndicatorVisible, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeightFull, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setReadOnly, setRequiredIndicatorVisible, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidthFull, setWidthUndefined
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, encodeState, getErrorHandler, getExtensions, getRpcManager, handleConnectorRequest, isAttached, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, addStyleNames, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, isEnabled, isVisible, readDesign, removeListener, removeStyleName, removeStyleNames, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisible, writeDesign
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface com.vaadin.ui.LegacyComponent
markAsDirty
-
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull, setWidthUndefined
-
Methods inherited from interface com.vaadin.server.VariableOwner
isEnabled
-
-
-
-
Field Detail
-
actionManager
protected ActionManager actionManager
Keeps track of the Actions added to this component, and manages the painting and handling as well.
-
-
Constructor Detail
-
UI
public UI()
Creates a new empty UI without a caption. The content of the UI must be set by calling
setContent(Component)
before using the UI.
-
UI
public UI(Component content)
Creates a new UI with the given component (often a layout) as its content.
Parameters:
content
- the component to use as this UIs content.See Also:
-
-
Method Detail
-
getState
protected UIState getState()
Description copied from class:
AbstractComponent
Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().
Overrides:
getState
in classAbstractSingleComponentContainer
Returns:
updated component shared state
-
getState
protected UIState getState(boolean markAsDirty)
Description copied from class:
AbstractClientConnector
Returns the shared state for this connector.
Overrides:
getState
in classAbstractSingleComponentContainer
Parameters:
markAsDirty
- true if the connector should automatically be marked dirty, false otherwiseReturns:
The shared state for this connector. Never null.
See Also:
-
getStateType
public Class<? extends UIState> getStateType()
Description copied from interface:
ClientConnector
Returns the type of the shared state for this connector.
Specified by:
getStateType
in interfaceClientConnector
Overrides:
getStateType
in classAbstractClientConnector
Returns:
The type of the state. Must never return null.
-
getUI
public UI getUI()
Overridden to return a value instead of referring to the parent.
Specified by:
getUI
in interfaceClientConnector
Specified by:
Overrides:
getUI
in classAbstractClientConnector
Returns:
this UI
See Also:
-
getSession
public VaadinSession getSession()
Gets the application object to which the component is attached.
The method will return
null
if the component is not currently attached to an application.Getting a null value is often a problem in constructors of regular components and in the initializers of custom composite components. A standard workaround is to use
VaadinSession.getCurrent()
to retrieve the application instance that the current request relates to. Another way is to move the problematic initialization toattach()
, as described in the documentation of the method.Overrides:
getSession
in classAbstractClientConnector
Returns:
the parent application of the component or
null
.See Also:
-
paintContent
public void paintContent(PaintTarget target) throws PaintException
Description copied from interface:
LegacyComponent
Paints the Paintable into a UIDL stream. This method creates the UIDL sequence describing it and outputs it to the given UIDL stream.
It is called when the contents of the component should be painted in response to the component first being shown or having been altered so that its visual representation is changed.
Specified by:
paintContent
in interfaceLegacyComponent
Parameters:
target
- the target UIDL stream where the component should paint itself to.Throws:
PaintException
- if the paint operation failed.
-
changeVariables
public void changeVariables(Object source, Map<String,Object> variables)
Description copied from interface:
VariableOwner
Called when one or more variables handled by the implementing class are changed.
Specified by:
changeVariables
in interfaceVariableOwner
Parameters:
source
- the Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.variables
- the Mapping from variable names to new variable values.
-
iterator
public Iterator<Component> iterator()
Description copied from interface:
HasComponents
Gets an iterator to the collection of contained components. Using this iterator it is possible to step through all components contained in this container.
The iterator is typically unmodifiable, and calls to
Iterator.remove()
throw an exception.Specified by:
iterator
in interfaceHasComponents
Specified by:
iterator
in interfaceIterable<Component>
Overrides:
iterator
in classAbstractSingleComponentContainer
Returns:
the component iterator.
-
getComponentCount
public int getComponentCount()
Description copied from interface:
SingleComponentContainer
Gets the number of children this
SingleComponentContainer
has. This must be symmetric with whatHasComponents.iterator()
returns and thus typically return 1 if the content is set, 0 otherwise.Specified by:
getComponentCount
in interfaceSingleComponentContainer
Overrides:
getComponentCount
in classAbstractSingleComponentContainer
Returns:
The number of child components this container has.
-
setSession
public void setSession(VaadinSession session)
Sets the session to which this UI is assigned.
This method is for internal use by the framework. To explicitly close a UI, see
close()
.Parameters:
session
- the session to setThrows:
IllegalStateException
- if the session has already been setSee Also:
-
getUIId
public int getUIId()
Gets the id of the UI, used to identify this UI within its application when processing requests. The UI id should be present in every request to the server that originates from this UI.
VaadinService.findUI(VaadinRequest)
uses this id to find the route to which the request belongs.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
getCurrent()
does not return this UI.Returns:
the id of this UI
-
addWindow
public void addWindow(Window window) throws IllegalArgumentException, NullPointerException
Adds a window as a subwindow inside this UI. To open a new browser window or tab, you should instead use a
UIProvider
.Parameters:
window
-Throws:
IllegalArgumentException
- if the window is already added to an applicationNullPointerException
- if the givenWindow
isnull
.
-
removeWindow
public boolean removeWindow(Window window)
Remove the given subwindow from this UI. Since Vaadin 6.5,
Window.CloseListener
s are called also when explicitly removing a window by calling this method. Since Vaadin 6.5, returns a boolean indicating if the window was removed or not.Parameters:
window
- Window to be removed.Returns:
true if the subwindow was removed, false otherwise
-
getWindows
public Collection<Window> getWindows()
Gets all the windows added to this UI.
Returns:
an unmodifiable collection of windows
-
focus
public void focus()
Description copied from class:
AbstractComponent
Sets the focus for this component if the component is
Component.Focusable
.Specified by:
focus
in interfaceComponent.Focusable
Overrides:
focus
in classAbstractComponent
See Also:
FieldEvents
,FieldEvents.FocusEvent
,FieldEvents.FocusListener
,FieldEvents.BlurEvent
,FieldEvents.BlurListener
-
setDisconnectPushOnRefresh
protected void setDisconnectPushOnRefresh(boolean disconnectPushOnRefresh)
Normally when UI is refreshed when PreserveOnRefresh is used, UI checks if Push connection is active and disconnects it in order to avoid race condition. With some application containers like Payara this can have side effects. With this method it is possible turn off this feature. See framework issue #12577.
Parameters:
disconnectPushOnRefresh
- boolean value.
-
setFocusedComponent
public void setFocusedComponent(Component.Focusable focusable)
This method is used by Component.Focusable objects to request focus to themselves. Focus renders must be handled at window level (instead of Component.Focusable) due we want the last focused component to be focused in client too. Not the one that is rendered last (the case we'd get if implemented in Focusable only). To focus component from Vaadin application, use Focusable.focus(). See
Component.Focusable
.Parameters:
focusable
- to be focused on next paint
-
scrollIntoView
public void scrollIntoView(Component component) throws IllegalArgumentException
Scrolls any component between the component and UI to a suitable position so the component is visible to the user. The given component must belong to this UI.
Parameters:
component
- the component to be scrolled into viewThrows:
IllegalArgumentException
- ifcomponent
does not belong to this UI
-
doInit
public void doInit(VaadinRequest request, int uiId, String embedId)
Internal initialization method, should not be overridden. This method is not declared as final because that would break compatibility with e.g. CDI.
Parameters:
request
- the initialization requestuiId
- the id of the new uiembedId
- the embed id of this UI, ornull
if no id is knownSee Also:
-
getUiRootPath
public String getUiRootPath()
Gets the part of path (from browser's URL) that points to this UI. Basically the same as the value from
Page.getLocation()
, but without possible view identifiers or path parameters.Returns:
the part of path (from browser's URL) that points to this UI, without possible view identifiers or path parameters
Since:
8.2
-
getUiPathInfo
public String getUiPathInfo()
Gets the path info part of the request that is used to detect the UI. This is defined during UI init by certain
UIProviders
that map different UIs to different URIs, like Vaadin Spring. This information is used by theNavigator
when theUI
is annotated withPushStateNavigation
.For example if the UI is accessed through
http://example.com/MyUI/mainview/parameter=1
the path info would be/MyUI
.Returns:
the path info part of the request;
null
if no request from client has been processedSince:
8.2
-
init
protected abstract void init(VaadinRequest request)
Initializes this UI. This method is intended to be overridden by subclasses to build the view and configure non-component functionality. Performing the initialization in a constructor is not suggested as the state of the UI is not properly set up when the constructor is invoked.
The
VaadinRequest
can be used to get information about the request that caused this UI to be created.Parameters:
request
- the Vaadin request that caused this UI to be created
-
doRefresh
public void doRefresh(VaadinRequest request)
Internal reinitialization method, should not be overridden.
Parameters:
request
- the request that caused this UI to be reloadedSince:
7.2
-
refresh
protected void refresh(VaadinRequest request)
Reinitializes this UI after a browser refresh if the UI is set to be preserved on refresh, typically using the
PreserveOnRefresh
annotation. This method is intended to be overridden by subclasses if needed; the default implementation is empty.The
VaadinRequest
can be used to get information about the request that caused this UI to be reloaded.Parameters:
request
- the request that caused this UI to be reloadedSince:
7.2
-
setCurrent
public static void setCurrent(UI ui)
Sets the thread local for the current UI. This method is used by the framework to set the current application whenever a new request is processed and it is cleared when the request has been processed.
The application developer can also use this method to define the current UI outside the normal request handling, e.g. when initiating custom background threads.
The UI is stored using a weak reference to avoid leaking memory in case it is not explicitly cleared.
Parameters:
ui
- the UI to register as the current UISee Also:
-
getCurrent
public static UI getCurrent()
Gets the currently used UI. The current UI is automatically defined when processing requests to the server. In other cases, (e.g. from background threads), the current UI is not automatically defined.
The UI is stored using a weak reference to avoid leaking memory in case it is not explicitly cleared.
Returns:
the current UI instance if available, otherwise
null
See Also:
-
setScrollTop
public void setScrollTop(int scrollTop)
Set top offset to which the UI should scroll to.
Parameters:
scrollTop
-
-
getScrollTop
public int getScrollTop()
-
setScrollLeft
public void setScrollLeft(int scrollLeft)
Set left offset to which the UI should scroll to.
Parameters:
scrollLeft
-
-
getScrollLeft
public int getScrollLeft()
-
getActionManager
protected ActionManager getActionManager()
Description copied from class:
AbstractComponent
Gets the
ActionManager
used to manage theShortcutListener
s added to this component.Overrides:
getActionManager
in classAbstractComponent
Returns:
the ActionManager in use
-
addAction
public <T extends Action & Action.Listener> void addAction(T action)
Specified by:
addAction
in interfaceAction.Notifier
-
removeAction
public <T extends Action & Action.Listener> void removeAction(T action)
Specified by:
removeAction
in interfaceAction.Notifier
-
addActionHandler
public void addActionHandler(Action.Handler actionHandler)
Description copied from interface:
Action.Container
Registers a new action handler for this container.
Specified by:
addActionHandler
in interfaceAction.Container
Parameters:
actionHandler
- the new handler to be added.
-
removeActionHandler
public void removeActionHandler(Action.Handler actionHandler)
Description copied from interface:
Action.Container
Removes a previously registered action handler for the contents of this container.
Specified by:
removeActionHandler
in interfaceAction.Container
Parameters:
actionHandler
- the handler to be removed.
-
setResizeLazy
public void setResizeLazy(boolean resizeLazy)
Should resize operations be lazy, i.e. should there be a delay before layout sizes are recalculated and resize events are sent to the server. Speeds up resize operations in slow UIs with the penalty of slightly decreased usability.
Default value:
false
When there are active window resize listeners, lazy resize mode should be used to avoid a large number of events during resize.
Parameters:
resizeLazy
- true to use a delay before recalculating sizes, false to calculate immediately.
-
isResizeLazy
public boolean isResizeLazy()
Checks whether lazy resize is enabled.
Returns:
true
if lazy resize is enabled,false
if lazy resize is not enabled
-
addClickListener
public Registration addClickListener(MouseEvents.ClickListener listener)
Add a click listener to the UI. The listener is called whenever the user clicks inside the UI. Also when the click targets a component inside the UI, provided the targeted component does not prevent the click event from propagating.
Parameters:
listener
- The listener to add, not nullReturns:
a registration object for removing the listener
Since:
8.0
See Also:
-
removeClickListener
@Deprecated public void removeClickListener(MouseEvents.ClickListener listener)
Deprecated.As of 8.0, replaced byRegistration.remove()
in the registration object returned fromremoveClickListener(ClickListener)
.Remove a click listener from the UI. The listener should earlier have been added using
addClickListener(ClickListener)
.Parameters:
listener
- The listener to remove
-
isConnectorEnabled
public boolean isConnectorEnabled()
Description copied from interface:
ClientConnector
Checks if the communicator is enabled. An enabled communicator is allowed to receive messages from its counter-part.
Specified by:
isConnectorEnabled
in interfaceClientConnector
Overrides:
isConnectorEnabled
in classAbstractComponent
Returns:
true if the connector can receive messages, false otherwise
-
getConnectorTracker
public ConnectorTracker getConnectorTracker()
-
getPage
public Page getPage()
-
getNavigator
public Navigator getNavigator()
Returns the navigator attached to this UI or null if there is no navigator.
Returns:
-
setNavigator
public void setNavigator(Navigator navigator)
For internal use only.
Parameters:
navigator
-
-
setCaption
@Deprecated public void setCaption(String caption)
Deprecated.As of 7.0, usePage.setTitle(String)
Setting the caption of a UI is not supported. To set the title of the HTML page, use Page.setTitle
Specified by:
setCaption
in interfaceComponent
Overrides:
setCaption
in classAbstractComponent
Parameters:
caption
- the new caption for the component. If the caption isnull
, no caption is shown and it does not normally take any space
-
showNotification
@Deprecated public void showNotification(String caption)
Deprecated.As of 7.0, use Notification.show instead but be aware that Notification.show does not allow HTML.Shows a notification message on the middle of the UI. The message automatically disappears ("humanized message"). Care should be taken to to avoid XSS vulnerabilities as the caption is rendered as html.
Parameters:
caption
- The messageSee Also:
-
showNotification
@Deprecated public void showNotification(String caption, Notification.Type type)
Deprecated.As of 7.0, use Notification.show instead but be aware that Notification.show does not allow HTML.Shows a notification message the UI. The position and behavior of the message depends on the type, which is one of the basic types defined in
Notification
, for instance Notification.TYPE_WARNING_MESSAGE. Care should be taken to to avoid XSS vulnerabilities as the caption is rendered as html.Parameters:
caption
- The messagetype
- The message typeSee Also:
-
showNotification
@Deprecated public void showNotification(String caption, String description)
Deprecated.As of 7.0, use new Notification(...).show(Page) instead but be aware that HTML by default not allowed.Shows a notification consisting of a bigger caption and a smaller description on the middle of the UI. The message automatically disappears ("humanized message"). Care should be taken to to avoid XSS vulnerabilities as the caption and description are rendered as html.
Parameters:
caption
- The caption of the messagedescription
- The message descriptionSee Also:
-
showNotification
@Deprecated public void showNotification(String caption, String description, Notification.Type type)
Deprecated.As of 7.0, use new Notification(...).show(Page) instead but be aware that HTML by default not allowed.Shows a notification consisting of a bigger caption and a smaller description. The position and behavior of the message depends on the type, which is one of the basic types defined in
Notification
, for instance Notification.TYPE_WARNING_MESSAGE. Care should be taken to to avoid XSS vulnerabilities as the caption and description are rendered as html.Parameters:
caption
- The caption of the messagedescription
- The message descriptiontype
- The message typeSee Also:
-
showNotification
@Deprecated public void showNotification(String caption, String description, Notification.Type type, boolean htmlContentAllowed)
Deprecated.As of 7.0, use new Notification(...).show(Page).Shows a notification consisting of a bigger caption and a smaller description. The position and behavior of the message depends on the type, which is one of the basic types defined in
Notification
, for instance Notification.TYPE_WARNING_MESSAGE. Care should be taken to avoid XSS vulnerabilities if html content is allowed.Parameters:
caption
- The message captiondescription
- The message descriptiontype
- The type of messagehtmlContentAllowed
- Whether html in the caption and description should be displayed as html or as plain textSee Also:
-
showNotification
@Deprecated public void showNotification(Notification notification)
Deprecated.As of 7.0, use Notification.show insteadShows a notification message.
Parameters:
notification
- The notification message to showSee Also:
Notification
,showNotification(String)
,showNotification(String, String)
-
getLastHeartbeatTimestamp
public long getLastHeartbeatTimestamp()
Returns the timestamp of the last received heartbeat for this 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
getCurrent()
does not return this UI.Returns:
The time the last heartbeat request occurred, in milliseconds since the epoch.
See Also:
-
setLastHeartbeatTimestamp
public void setLastHeartbeatTimestamp(long lastHeartbeat)
Sets the last heartbeat request timestamp for this UI. Called by the framework whenever the application receives a valid heartbeat request for this 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
getCurrent()
does not return this UI.Parameters:
lastHeartbeat
- The time the last heartbeat request occurred, in milliseconds since the epoch.
-
getTheme
public String getTheme()
Gets the theme currently in use by this UI.
Returns:
the theme name
-
setTheme
public void setTheme(String theme)
Sets the theme currently in use by this UI
Calling this method will remove the old theme (CSS file) from the application and add the new theme.
Note that this method is NOT SAFE to call in a portal environment or other environment where there are multiple UIs on the same page. The old CSS file will be removed even if there are other UIs on the page which are still using it.
Parameters:
theme
- The new theme nameSince:
7.3
-
close
public void close()
Marks this UI to be
detached
from the session at the end of the current request, or the next request if there is no current request (if called from a background thread, for instance.)The UI is detached after the response is sent, so in the current request it can still update the client side normally. However, after the response any new requests from the client side to this UI will cause an error, so usually the client should be asked, for instance, to reload the page (serving a fresh UI instance), to close the page, or to navigate somewhere else.
Note that this method is strictly for users to explicitly signal the framework that the UI should be detached. Overriding it is not a reliable way to catch UIs that are to be detached. Instead,
UI.detach()
should be overridden or aClientConnector.DetachListener
used.
-
isClosing
public boolean isClosing()
Returns whether this UI is marked as closed and is to be detached.
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
getCurrent()
does not return this UI.Returns:
whether this UI is closing.
See Also:
-
attach
public void attach()
Called after the UI is added to the session. A UI instance is attached exactly once, before its
init
method is called.Specified by:
attach
in interfaceClientConnector
Specified by:
Overrides:
attach
in classAbstractComponent
See Also:
-
detach
public void detach()
Called before the UI is removed from the session. A UI instance is detached exactly once, either:
- after it is explicitly
closed
. - when its session is closed or expires
- after three missed heartbeat requests.
Note that when a UI is detached, any changes made in the
detach
methods of any children orClientConnector.DetachListener
s that would be communicated to the client are silently ignored.Specified by:
detach
in interfaceClientConnector
Overrides:
detach
in classAbstractComponent
- after it is explicitly
-
setContent
public void setContent(Component content)
Description copied from class:
AbstractSingleComponentContainer
Sets the content of this container. The content is a component that serves as the outermost item of the visual contents. The content must always be set, either with a constructor parameter or by calling this method. Previous versions of Vaadin used a
VerticalLayout
with margins enabled as the default content but that is no longer the case.Specified by:
setContent
in interfaceSingleComponentContainer
Overrides:
setContent
in classAbstractSingleComponentContainer
Parameters:
content
- a component (typically a layout) to use as content
-
setTabIndex
public void setTabIndex(int tabIndex)
Description copied from interface:
Component.Focusable
Sets the tabulator index of the
Focusable
component. The tab index property is used to specify the order in which the fields are focused when the user presses the Tab key. Components with a defined tab index are focused sequentially first, and then the components with no tab index.Form loginBox = new Form(); loginBox.setCaption("Login"); layout.addComponent(loginBox); // Create the first field which will be focused TextField username = new TextField("User name"); loginBox.addField("username", username); // Set focus to the user name username.focus(); TextField password = new TextField("Password"); loginBox.addField("password", password); Button login = new Button("Login"); loginBox.getFooter().addComponent(login); // An additional component which natural focus order would // be after the button. CheckBox remember = new CheckBox("Remember me"); loginBox.getFooter().addComponent(remember); username.setTabIndex(1); password.setTabIndex(2); remember.setTabIndex(3); // Different than natural place login.setTabIndex(4);
After all focusable user interface components are done, the browser can begin again from the component with the smallest tab index, or it can take the focus out of the page, for example, to the location bar.
If the tab index is not set (is set to zero), the default tab order is used. The order is somewhat browser-dependent, but generally follows the HTML structure of the page.
A negative value means that the component is completely removed from the tabulation order and can not be reached by pressing the Tab key at all.
Specified by:
setTabIndex
in interfaceComponent.Focusable
Parameters:
tabIndex
- the tab order of this component. Indexes usually start from 1. Zero means that default tab order should be used. A negative value means that the field should not be included in the tabbing sequence.See Also:
-
getTabIndex
public int getTabIndex()
Description copied from interface:
Component.Focusable
Gets the tabulator index of the
Focusable
component.Specified by:
getTabIndex
in interfaceComponent.Focusable
Returns:
tab index set for the
Focusable
componentSee Also:
-
accessSynchronously
public void accessSynchronously(Runnable runnable) throws UIDetachedException
Locks the session of this UI and runs the provided Runnable right away.
It is generally recommended to use
This method behaves differently thanaccess(Runnable)
instead of this method for accessing a session from a different thread asaccess(Runnable)
can be used while holding the lock of another session. To avoid causing deadlocks, this methods throws an exception if it is detected than another session is also locked by the current thread.access(Runnable)
in some situations:- If the current thread is currently holding the lock of the session,
accessSynchronously(Runnable)
runs the task right away whereasaccess(Runnable)
defers the task to a later point in time. - If some other thread is currently holding the lock for the session,
accessSynchronously(Runnable)
blocks while waiting for the lock to be available whereasaccess(Runnable)
defers the task to a later point in time.
Parameters:
runnable
- the runnable which accesses the UIThrows:
UIDetachedException
- if the UI is not attached to a session (and locking can therefore not be done)IllegalStateException
- if the current thread holds the lock for another sessionSince:
7.1
See Also:
access(Runnable)
,VaadinSession.accessSynchronously(Runnable)
- If the current thread is currently holding the lock of the session,
-
access
public Future<Void> access(Runnable runnable)
Provides exclusive access to this UI from outside a request handling thread.
The given runnable is executed while holding the session lock to ensure exclusive access to this UI. If the session is not locked, the lock will be acquired and the runnable is run right away. If the session is currently locked, the runnable will be run before that lock is released.
RPC handlers for components inside this UI do not need to use this method as the session is automatically locked by the framework during RPC handling.
Please note that the runnable might be invoked on a different thread or later on the current thread, which means that custom thread locals might not have the expected values when the command is executed.
getCurrent()
,VaadinSession.getCurrent()
andVaadinService.getCurrent()
are set according to this UI before executing the command. Other standard CurrentInstance values such asVaadinService.getCurrentRequest()
andVaadinService.getCurrentResponse()
will not be defined.The returned future can be used to check for task completion and to cancel the task.
Parameters:
runnable
- the runnable which accesses the UIReturns:
a future that can be used to check for task completion and to cancel the task
Throws:
UIDetachedException
- if the UI is not attached to a session (and locking can therefore not be done)Since:
7.1
See Also:
getCurrent()
,accessSynchronously(Runnable)
,VaadinSession.access(Runnable)
,VaadinSession.lock()
-
getTooltipConfiguration
public TooltipConfiguration getTooltipConfiguration()
Retrieves the object used for configuring tooltips.
Returns:
The instance used for tooltip configuration
-
getNotificationConfiguration
public NotificationConfiguration getNotificationConfiguration()
Retrieves the object used for configuring notifications.
Returns:
The instance used for notification configuration
-
getLoadingIndicatorConfiguration
public LoadingIndicatorConfiguration getLoadingIndicatorConfiguration()
Retrieves the object used for configuring the loading indicator.
Returns:
The instance used for configuring the loading indicator
-
push
public void push()
Pushes the pending changes and client RPC invocations of this UI to the client-side.
If push is enabled, but the push connection is not currently open, the push will be done when the connection is established.
As with all UI methods, the session must be locked when calling this method. It is also recommended that
getCurrent()
is set up to return this UI since writing the response may invoke logic in any attached component or extension. The recommended way of fulfilling these conditions is to useaccess(Runnable)
.Throws:
IllegalStateException
- if push is disabled.UIDetachedException
- if this UI is not attached to a session.Since:
7.1
See Also:
-
getPushConnection
public PushConnection getPushConnection()
Returns the internal push connection object used by this 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
getCurrent()
does not return this UI.Returns:
the push connection used by this UI, or
null
if push is not available.
-
setPushConnection
public void setPushConnection(PushConnection pushConnection)
Sets the internal push connection object used by this 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 this UI
-
setPollInterval
public void setPollInterval(int intervalInMillis)
Sets the interval with which the UI should poll the server to see if there are any changes. Polling is disabled by default.
Note that it is possible to enable push and polling at the same time but it should not be done to avoid excessive server traffic.
Add-on developers should note that this method is only meant for the application developer. An add-on should not set the poll interval directly, rather instruct the user to set it.
Parameters:
intervalInMillis
- The interval (in ms) with which the UI should poll the server or -1 to disable polling
-
getPollInterval
public int getPollInterval()
Returns the interval with which the UI polls the server.
Returns:
The interval (in ms) with which the UI polls the server or -1 if polling is disabled
-
addPollListener
public Registration addPollListener(UIEvents.PollListener listener)
Description copied from interface:
UIEvents.PollNotifier
Add a poll listener.
The listener is called whenever the client polls the server for asynchronous UI updates.
Specified by:
addPollListener
in interfaceUIEvents.PollNotifier
Parameters:
listener
- theUIEvents.PollListener
to add, not nullReturns:
a registration object for removing the listener
See Also:
setPollInterval(int)
,UIEvents.PollNotifier.removePollListener(PollListener)
,Registration
-
removePollListener
@Deprecated public void removePollListener(UIEvents.PollListener listener)
Deprecated.Description copied from interface:
UIEvents.PollNotifier
Remove a poll listener.
Specified by:
removePollListener
in interfaceUIEvents.PollNotifier
Parameters:
listener
- the listener to be removedSee Also:
-
getPushConfiguration
public PushConfiguration getPushConfiguration()
Retrieves the object used for configuring the push channel.
Returns:
The instance used for push configuration
Since:
7.1
-
getReconnectDialogConfiguration
public ReconnectDialogConfiguration getReconnectDialogConfiguration()
Retrieves the object used for configuring the reconnect dialog.
Returns:
The instance used for reconnect dialog configuration
Since:
7.6
-
getOverlayContainerLabel
public String getOverlayContainerLabel()
Get the label that is added to the container element, where tooltip, notification and dialogs are added to.
Returns:
the label of the container
-
setOverlayContainerLabel
public void setOverlayContainerLabel(String overlayContainerLabel)
Sets the label that is added to the container element, where tooltip, notifications and dialogs are added to.
This is helpful for users of assistive devices, as this element is reachable for them.
Parameters:
overlayContainerLabel
- label to use for the container
-
getLocaleService
public LocaleService getLocaleService()
Returns the locale service which handles transmission of Locale data to the client.
Returns:
The LocaleService for this UI
Since:
7.1
-
getEmbedId
public String getEmbedId()
Gets a string the uniquely distinguishes this UI instance based on where it is embedded. The embed identifier is based on the
window.name
DOM attribute of the browser window where the UI is displayed and the id of the div element where the UI is embedded.Returns:
the embed id for this UI, or
null
if no id knownSince:
7.2
-
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
Since:
7.6
-
setLastProcessedClientToServerId
public void setLastProcessedClientToServerId(int lastProcessedClientToServerId)
Sets the last processed server message id. Used internally for communication tracking.
Parameters:
lastProcessedClientToServerId
- the id of the last processed server messageSince:
7.6
-
addWindowOrderUpdateListener
public Registration addWindowOrderUpdateListener(UI.WindowOrderUpdateListener listener)
Adds a WindowOrderUpdateListener to the UI.
The WindowOrderUpdateEvent is fired when the order positions of windows are updated. It can happen when some window (this or other) is brought to front or detached.
The other way to listen window position for specific window is
Window.addWindowOrderChangeListener(WindowOrderChangeListener)
Parameters:
listener
- the WindowModeChangeListener to add.Returns:
a registration object for removing the listener
Since:
8.0
See Also:
Window.addWindowOrderChangeListener(WindowOrderChangeListener)
-
setActiveDragSource
public void setActiveDragSource(DragSourceExtension<? extends AbstractComponent> extension)
Sets the drag source of an active HTML5 drag event.
Parameters:
extension
- Extension of the drag source component.Since:
8.1
See Also:
-
getActiveDragSource
public DragSourceExtension<? extends AbstractComponent> getActiveDragSource()
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:
8.1
See Also:
-
isMobileHtml5DndEnabled
public boolean isMobileHtml5DndEnabled()
Returns whether HTML5 DnD extensions
DragSourceExtension
andDropTargetExtension
and alike should be enabled for mobile devices.By default, it is disabled.
Returns:
true
if enabled,false
if notSince:
8.1
See Also:
-
setMobileHtml5DndEnabled
public void setMobileHtml5DndEnabled(boolean enabled)
Enable or disable HTML5 DnD for mobile devices.
Usually you should enable the support in the
init(VaadinRequest)
method. By default, it is disabled. This operation is NOOP when the user is not on a mobile device.Changing this will effect all
DragSourceExtension
andDropTargetExtension
(and subclasses) that have not yet been attached to the UI on the client side.NOTE: When disabling this after it has been enabled, it will not affect
DragSourceExtension
andDropTargetExtension
(and subclasses) that have been previously added. Those extensions should be explicitly removed to make sure user cannot perform DnD operations anymore.Parameters:
enabled
-true
if enabled,false
if notSince:
8.1
-
isUsingThoroughSizeCheck
public boolean isUsingThoroughSizeCheck()
Returns whether LayoutManager uses thorough size check that evaluates the presence of the element and uses calculated size, or defaults to a slightly faster check that can result in incorrect size information if the check is triggered while a transform animation is ongoing. This can happen e.g. when a PopupView is opened.
By default, the thorough size check is enabled.
Returns:
true
if thorough size check enabled,false
if notSince:
8.13
-
setUsingThoroughSizeCheck
public void setUsingThoroughSizeCheck(boolean thoroughSizeCheck)
Set whether LayoutManager should use thorough size check that evaluates the presence of the element and uses calculated size, or default to a slightly faster check that can result in incorrect size information if the check is triggered while a transform animation is ongoing. This can happen e.g. when a PopupView is opened.
By default, the thorough size check is enabled.
Parameters:
thoroughSizeCheck
-true
if thorough size check enabled,false
if notSince:
8.13
-
runAfterRoundTrip
public UI.DelayedCallbackRegistration runAfterRoundTrip(UI.DelayedCallback callback)
Executes the given callback function after a single client round-trip. If this UI gets detached before he callback gets processed, execution is cancelled.
Parameters:
callback
- the callback to trigger after the round-tripReturns:
registration object that can be used to cancel the callback
Since:
8.18
-
runAfterRoundTrip
public UI.DelayedCallbackRegistration runAfterRoundTrip(UI.DelayedCallback callback, int numberOfRoundTripsToWait)
Executes the given callback function after the given number of client round-trips. If this UI gets detached before he callback gets processed, execution is cancelled.
Note: it is not recommended to use a large number as a way of simulating a delay.
Parameters:
callback
- the callback to trigger after the configured round-tripsnumberOfRoundTripsToWait
- how many round-trips should be waited for before triggering the callbackReturns:
registration object that can be used to cancel the callback
Since:
8.18
-
runAfterRoundTrip
public UI.DelayedCallbackRegistration runAfterRoundTrip(UI.DelayedCallback callback, UI.DelayedCallback cancelCallback)
Executes the given callback function after a single client round-trip, or the cancel callback if the execution is cancelled through
UI.DelayedCallbackRegistration.cancel()
. The framework cancels the execution if this UI gets detached before he callback gets processed, but the method can also be called by implementing application's code.Parameters:
callback
- the callback to trigger after the round-tripcancelCallback
- the callback to trigger if the execution gets cancelledReturns:
registration object that can be used to cancel the callback
Since:
8.18
-
runAfterRoundTrip
public UI.DelayedCallbackRegistration runAfterRoundTrip(UI.DelayedCallback callback, UI.DelayedCallback cancelCallback, int numberOfRoundTripsToWait)
Executes the given callback function after the given number of client round-trips, or the cancel callback if the execution is cancelled through
UI.DelayedCallbackRegistration.cancel()
. The framework cancels the execution if this UI gets detached before he callback gets processed, but the method can also be called by implementing application's code.Note: it is not recommended to use a large number or round-trips as a way of simulating a delay.
Parameters:
callback
- the callback to trigger after the configured round-tripscancelCallback
- the callback to trigger if the execution gets cancellednumberOfRoundTripsToWait
- how many round-trips should be waited for before triggering the callbackReturns:
registration object that can be used to cancel the callback
Since:
8.18
-
-