public abstract class UI extends AbstractSingleComponentContainer implements Action.Container, Action.Notifier, UIEvents.PollNotifier, LegacyComponent, Component.Focusable
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
, all
UIProvider
s registered to the current VaadinSession
are
queried for the UI class that should be used. The selection is by default
based on the UI
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 a Component
with the main layout or other content of the view
to setContent(Component)
or to the constructor of the UI.
init(VaadinRequest)
,
UIProvider
,
Serialized FormModifier and Type | Class and Description |
---|---|
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.
|
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
Sizeable.Unit
HasComponents.ComponentAttachDetachNotifier, HasComponents.ComponentAttachEvent, HasComponents.ComponentAttachListener, HasComponents.ComponentDetachEvent, HasComponents.ComponentDetachListener
Modifier and Type | Field and Description |
---|---|
protected ActionManager |
actionManager
Keeps track of the Actions added to this component, and manages the
painting and handling as well.
|
DESIGN_ATTR_PLAIN_TEXT
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
Constructor and Description |
---|
UI()
Creates a new empty UI without a caption.
|
UI(Component content)
Creates a new UI with the given component (often a layout) as its
content.
|
Modifier and Type | Method and 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> |
addAction(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
Focusable . |
protected ActionManager |
getActionManager()
Gets the
ActionManager used to manage the
ShortcutListener 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.
|
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 and
DropTargetExtension and alike should be enabled for mobile
devices. |
boolean |
isResizeLazy()
Checks whether lazy resize is enabled.
|
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> |
removeAction(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 by
Registration.remove() in the
registration object returned from
#removeClickListener(ClickListener) . |
void |
removePollListener(UIEvents.PollListener listener)
Deprecated.
|
boolean |
removeWindow(Window window)
Remove the given subwindow from this UI.
|
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, use
Page.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.
|
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 |
showNotification(Notification notification)
Deprecated.
As of 7.0, use Notification.show instead
|
void |
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).
|
addComponentAttachListener, addComponentDetachListener, fireComponentAttachEvent, fireComponentDetachEvent, getContent, readDesign, readDesignChildren, removeComponentAttachListener, removeComponentDetachListener, removeFromParent, setHeight, setWidth, writeDesign
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, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setReadOnly, setRequiredIndicatorVisible, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setStyleName, setVisible, setWidth, setWidthUndefined
addAttachListener, addDetachListener, addExtension, 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, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
markAsDirty
isEnabled
addListener, addStyleName, addStyleNames, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, isEnabled, isVisible, readDesign, removeListener, removeStyleName, removeStyleNames, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setVisible, writeDesign
addAttachListener, addDetachListener, beforeClientResponse, encodeState, getErrorHandler, getExtensions, getRpcManager, handleConnectorRequest, isAttached, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
getConnectorId
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefined
forEach, spliterator
protected ActionManager actionManager
public UI()
setContent(Component)
before using the UI.public UI(Component content)
content
- the component to use as this UIs content.setContent(Component)
protected UIState getState()
AbstractComponent
getState
in class AbstractSingleComponentContainer
protected UIState getState(boolean markAsDirty)
AbstractClientConnector
getState
in class AbstractSingleComponentContainer
markAsDirty
- true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()
public Class<? extends UIState> getStateType()
ClientConnector
getStateType
in interface ClientConnector
getStateType
in class AbstractClientConnector
public UI getUI()
getUI
in interface ClientConnector
getUI
in interface Component
getUI
in class AbstractClientConnector
AbstractClientConnector.getUI()
public VaadinSession getSession()
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 to
attach()
, as described in the documentation of the method.
getSession
in class AbstractClientConnector
null
.attach()
public void paintContent(PaintTarget target) throws PaintException
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.
paintContent
in interface LegacyComponent
target
- the target UIDL stream where the component should paint itself
to.PaintException
- if the paint operation failed.public void changeVariables(Object source, Map<String,Object> variables)
VariableOwner
changeVariables
in interface VariableOwner
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.public Iterator<Component> iterator()
HasComponents
The iterator is typically unmodifiable, and calls to
Iterator.remove()
throw an exception.
iterator
in interface HasComponents
iterator
in interface Iterable<Component>
iterator
in class AbstractSingleComponentContainer
public int getComponentCount()
SingleComponentContainer
SingleComponentContainer
has.
This must be symmetric with what HasComponents.iterator()
returns and thus
typically return 1 if the content is set, 0 otherwise.getComponentCount
in interface SingleComponentContainer
getComponentCount
in class AbstractSingleComponentContainer
public void setSession(VaadinSession session)
This method is for internal use by the framework. To explicitly close a
UI, see close()
.
session
- the session to setIllegalStateException
- if the session has already been setgetSession()
public int getUIId()
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.
public void addWindow(Window window) throws IllegalArgumentException, NullPointerException
UIProvider
.window
- IllegalArgumentException
- if the window is already added to an applicationNullPointerException
- if the given Window
is null
.public boolean removeWindow(Window window)
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.window
- Window to be removed.public Collection<Window> getWindows()
public void focus()
AbstractComponent
Focusable
.focus
in interface Component.Focusable
focus
in class AbstractComponent
FieldEvents
,
FieldEvents.FocusEvent
,
FieldEvents.FocusListener
,
FieldEvents.BlurEvent
,
FieldEvents.BlurListener
public void setFocusedComponent(Component.Focusable focusable)
Component.Focusable
.focusable
- to be focused on next paintpublic void scrollIntoView(Component component) throws IllegalArgumentException
component
- the component to be scrolled into viewIllegalArgumentException
- if component
does not belong to this UIpublic void doInit(VaadinRequest request, int uiId, String embedId)
request
- the initialization requestuiId
- the id of the new uiembedId
- the embed id of this UI, or null
if no id is
knowngetUIId()
,
getEmbedId()
protected abstract void init(VaadinRequest request)
The VaadinRequest
can be used to get information about the
request that caused this UI to be created.
request
- the Vaadin request that caused this UI to be createdpublic void doRefresh(VaadinRequest request)
request
- the request that caused this UI to be reloadedprotected void refresh(VaadinRequest request)
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.
request
- the request that caused this UI to be reloadedpublic static void setCurrent(UI ui)
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.
ui
- the UI to register as the current UIgetCurrent()
,
ThreadLocal
public static UI getCurrent()
The UI is stored using a weak reference to avoid leaking memory in case it is not explicitly cleared.
null
setCurrent(UI)
public void setScrollTop(int scrollTop)
scrollTop
- public int getScrollTop()
public void setScrollLeft(int scrollLeft)
scrollLeft
- public int getScrollLeft()
protected ActionManager getActionManager()
AbstractComponent
ActionManager
used to manage the
ShortcutListener
s added to this component.getActionManager
in class AbstractComponent
public <T extends Action & Action.Listener> void addAction(T action)
addAction
in interface Action.Notifier
public <T extends Action & Action.Listener> void removeAction(T action)
removeAction
in interface Action.Notifier
public void addActionHandler(Action.Handler actionHandler)
Action.Container
addActionHandler
in interface Action.Container
actionHandler
- the new handler to be added.public void removeActionHandler(Action.Handler actionHandler)
Action.Container
removeActionHandler
in interface Action.Container
actionHandler
- the handler to be removed.public void setResizeLazy(boolean resizeLazy)
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.
resizeLazy
- true to use a delay before recalculating sizes, false to
calculate immediately.public boolean isResizeLazy()
true
if lazy resize is enabled, false
if lazy resize is not enabledpublic Registration addClickListener(MouseEvents.ClickListener listener)
listener
- The listener to add, not nullRegistration
@Deprecated public void removeClickListener(MouseEvents.ClickListener listener)
Registration.remove()
in the
registration object returned from
#removeClickListener(ClickListener)
.#addListener(ClickListener)
.listener
- The listener to removepublic boolean isConnectorEnabled()
ClientConnector
isConnectorEnabled
in interface ClientConnector
isConnectorEnabled
in class AbstractComponent
public ConnectorTracker getConnectorTracker()
public Page getPage()
public Navigator getNavigator()
public void setNavigator(Navigator navigator)
navigator
- @Deprecated public void setCaption(String caption)
Page.setTitle(String)
setCaption
in interface Component
setCaption
in class AbstractComponent
caption
- the new caption for the component. If the caption is
null
, no caption is shown and it does not normally
take any space@Deprecated public void showNotification(String caption)
caption
- The messageshowNotification(Notification)
,
Notification
@Deprecated public void showNotification(String caption, Notification.Type type)
Notification
, for instance Notification.TYPE_WARNING_MESSAGE.
Care should be taken to to avoid XSS vulnerabilities as the caption is
rendered as html.caption
- The messagetype
- The message typeshowNotification(Notification)
,
Notification
@Deprecated public void showNotification(String caption, String description)
caption
- The caption of the messagedescription
- The message descriptionshowNotification(Notification)
,
Notification
@Deprecated public void showNotification(String caption, String description, Notification.Type type)
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.caption
- The caption of the messagedescription
- The message descriptiontype
- The message typeshowNotification(Notification)
,
Notification
@Deprecated public void showNotification(String caption, String description, Notification.Type type, boolean htmlContentAllowed)
Notification
,
for instance Notification.TYPE_WARNING_MESSAGE.
Care should be taken to avoid XSS vulnerabilities if html content is
allowed.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 textshowNotification(Notification)
,
Notification
@Deprecated public void showNotification(Notification notification)
notification
- The notification message to showNotification
,
showNotification(String)
,
#showNotification(String, int)
,
showNotification(String, String)
,
#showNotification(String, String, int)
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
getCurrent()
does not return this 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
getCurrent()
does not return this UI.
lastHeartbeat
- The time the last heartbeat request occurred, in milliseconds
since the epoch.public String getTheme()
public void setTheme(String theme)
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.
theme
- The new theme namepublic void close()
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 a DetachListener
used.
public boolean isClosing()
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.
close()
public void attach()
init
method is
called.attach
in interface ClientConnector
attach
in interface Component
attach
in class AbstractComponent
Component.attach()
public void detach()
closed
.
Note that when a UI is detached, any changes made in the detach
methods of any children or DetachListener
s that would be
communicated to the client are silently ignored.
detach
in interface ClientConnector
detach
in class AbstractComponent
public void setContent(Component content)
AbstractSingleComponentContainer
VerticalLayout
with margins
enabled as the default content but that is no longer the case.setContent
in interface SingleComponentContainer
setContent
in class AbstractSingleComponentContainer
content
- a component (typically a layout) to use as contentpublic void setTabIndex(int tabIndex)
Component.Focusable
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.
setTabIndex
in interface Component.Focusable
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.Component.Focusable.getTabIndex()
public int getTabIndex()
Component.Focusable
Focusable
component.getTabIndex
in interface Component.Focusable
Focusable
componentComponent.Focusable.setTabIndex(int)
public void accessSynchronously(Runnable runnable) throws UIDetachedException
It is generally recommended to use access(Runnable)
instead of
this method for accessing a session from a different thread as
access(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.
This method behaves differently than access(Runnable)
in some
situations:
accessSynchronously(Runnable)
runs the task right away whereas
access(Runnable)
defers the task to a later point in time.accessSynchronously(Runnable)
blocks while waiting for the lock
to be available whereas access(Runnable)
defers the task to a
later point in time.runnable
- the runnable which accesses the UIUIDetachedException
- 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 sessionaccess(Runnable)
,
VaadinSession.accessSynchronously(Runnable)
public Future<Void> access(Runnable runnable)
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()
and
VaadinService.getCurrent()
are set according to this UI before
executing the command. Other standard CurrentInstance values such as
VaadinService.getCurrentRequest()
and
VaadinService.getCurrentResponse()
will not be defined.
The returned future can be used to check for task completion and to cancel the task.
runnable
- the runnable which accesses the UIUIDetachedException
- if the UI is not attached to a session (and locking can
therefore not be done)getCurrent()
,
accessSynchronously(Runnable)
,
VaadinSession.access(Runnable)
,
VaadinSession.lock()
public TooltipConfiguration getTooltipConfiguration()
public NotificationConfiguration getNotificationConfiguration()
public LoadingIndicatorConfiguration getLoadingIndicatorConfiguration()
public void push()
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 use access(Runnable)
.
IllegalStateException
- if push is disabled.UIDetachedException
- if this UI is not attached to a session.getPushConfiguration()
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
getCurrent()
does not return this 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 this UIpublic void setPollInterval(int intervalInMillis)
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.
intervalInMillis
- The interval (in ms) with which the UI should poll the server
or -1 to disable pollingpublic int getPollInterval()
public Registration addPollListener(UIEvents.PollListener listener)
UIEvents.PollNotifier
The listener is called whenever the client polls the server for asynchronous UI updates.
addPollListener
in interface UIEvents.PollNotifier
listener
- the UIEvents.PollListener
to add, not nullsetPollInterval(int)
,
#removePollListener(PollListener)
,
Registration
@Deprecated public void removePollListener(UIEvents.PollListener listener)
UIEvents.PollNotifier
removePollListener
in interface UIEvents.PollNotifier
listener
- the listener to be removed#addPollListener(PollListener)
public PushConfiguration getPushConfiguration()
public ReconnectDialogConfiguration getReconnectDialogConfiguration()
public String getOverlayContainerLabel()
public void setOverlayContainerLabel(String overlayContainerLabel)
This is helpful for users of assistive devices, as this element is reachable for them.
overlayContainerLabel
- label to use for the containerpublic LocaleService getLocaleService()
public String getEmbedId()
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.null
if no id knownpublic int getLastProcessedClientToServerId()
public void setLastProcessedClientToServerId(int lastProcessedClientToServerId)
lastProcessedServerMessageId
- the id of the last processed server messagepublic Registration addWindowOrderUpdateListener(UI.WindowOrderUpdateListener listener)
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)
listener
- the WindowModeChangeListener to add.Window.addWindowOrderChangeListener(WindowOrderChangeListener)
public void setActiveDragSource(DragSourceExtension<? extends AbstractComponent> extension)
extension
- Extension of the drag source component.DragSourceExtension
public DragSourceExtension<? extends AbstractComponent> getActiveDragSource()
DragSourceExtension
public boolean isMobileHtml5DndEnabled()
DragSourceExtension
and
DropTargetExtension
and alike should be enabled for mobile
devices.
By default, it is disabled.
true
if enabled, false
if notsetMobileHtml5DndEnabled(boolean)
public void setMobileHtml5DndEnabled(boolean enabled)
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
and
DropTargetExtension
(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
and DropTargetExtension
(and
subclasses) that have been previously added. Those extensions should be
explicitly removed to make sure user cannot perform DnD operations
anymore.
enabled
- true
if enabled, false
if notCopyright © 2017 Vaadin Ltd. All rights reserved.