|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.vaadin.server.AbstractClientConnector
com.vaadin.ui.AbstractComponent
com.vaadin.ui.AbstractSingleComponentContainer
com.vaadin.ui.UI
public abstract class UI
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, all
UIProviders registered to the current VaadinServiceSession
are queried for the UI class that should be used. The selection is by defaylt
based on the 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 AbstractSingleComponentContainer.setContent(Component) or to the constructor of the UI.
init(VaadinRequest),
UIProvider,
Serialized Form| Nested Class Summary | |
|---|---|
static class |
UI.CleanupEvent
Event fired when a UI is removed from the application. |
static interface |
UI.CleanupListener
Interface for listening UI cleanup events. |
| Nested classes/interfaces inherited from class com.vaadin.ui.AbstractComponent |
|---|
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler |
| Nested classes/interfaces inherited from interface com.vaadin.server.VariableOwner |
|---|
VariableOwner.ErrorEvent |
| Nested classes/interfaces inherited from interface com.vaadin.ui.Component |
|---|
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener |
| Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable |
|---|
Sizeable.Unit |
| Nested classes/interfaces inherited from interface com.vaadin.ui.HasComponents |
|---|
HasComponents.ComponentAttachDetachNotifier, HasComponents.ComponentAttachEvent, HasComponents.ComponentAttachListener, HasComponents.ComponentDetachEvent, HasComponents.ComponentDetachListener |
| Field Summary | |
|---|---|
protected ActionManager |
actionManager
Keeps track of the Actions added to this component, and manages the painting and handling as well. |
| 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 |
| Constructor Summary | |
|---|---|
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. |
|
| Method Summary | ||
|---|---|---|
|
addAction(T action)
|
|
void |
addActionHandler(Action.Handler actionHandler)
Registers a new action handler for this container |
|
void |
addCleanupListener(UI.CleanupListener listener)
Adds a cleanup listener to the UI. |
|
void |
addClickListener(MouseEvents.ClickListener listener)
Add a click listener to the UI. |
|
void |
addListener(MouseEvents.ClickListener listener)
Deprecated. Since 7.0, replaced by #addClickListener(ClickListener) |
|
void |
addWindow(Window window)
Adds a window as a subwindow inside this UI. |
|
void |
changeVariables(java.lang.Object source,
java.util.Map<java.lang.String,java.lang.Object> variables)
Called when one or more variables handled by the implementing class are changed. |
|
void |
doInit(VaadinRequest request,
int uiId)
Internal initialization method, should not be overridden. |
|
void |
fireCleanupEvent()
For internal use only. |
|
void |
focus()
Sets the focus for this component if the component is Focusable. |
|
protected ActionManager |
getActionManager()
Gets the ActionManager used to manage the
ShortcutListeners added to this Field. |
|
int |
getComponentCount()
Gets the number of children this SingleComponentContainer has. |
|
ConnectorTracker |
getConnectorTracker()
|
|
static UI |
getCurrent()
Gets the currently used UI. |
|
long |
getLastHeartbeatTime()
Returns the timestamp (milliseconds since the epoch) of the last received heartbeat for this UI. |
|
long |
getLastUidlRequestTime()
Returns the timestamp (milliseconds since the epoch) of the last received UIDL request for this UI. |
|
Navigator |
getNavigator()
Returns the navigator attached to this UI or null if there is no navigator. |
|
Page |
getPage()
|
|
VaadinServiceSession |
getSession()
Gets the application object to which the component is attached. |
|
protected com.vaadin.shared.ui.ui.UIState |
getState()
Returns the shared state bean with information to be sent from the server to the client. |
|
java.lang.Class<? extends com.vaadin.shared.ui.ui.UIState> |
getStateType()
Returns the type of the shared state for this connector |
|
java.lang.String |
getTheme()
Gets the theme that was used when the UI was initialized. |
|
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. |
|
java.util.Collection<Window> |
getWindows()
Gets all the windows added to this UI. |
|
protected abstract void |
init(VaadinRequest request)
Initializes this UI. |
|
boolean |
isConnectorEnabled()
Checks if the communicator is enabled. |
|
boolean |
isResizeLazy()
Checks whether lazy resize is enabled. |
|
java.util.Iterator<Component> |
iterator()
Gets an iterator to the collection of contained components. |
|
void |
paintContent(PaintTarget target)
Paints the Paintable into a UIDL stream. |
|
|
removeAction(T action)
|
|
void |
removeActionHandler(Action.Handler actionHandler)
Removes a previously registered action handler for the contents of this container. |
|
void |
removeCleanupListener(UI.CleanupListener listener)
Removes a cleanup listener from the UI, if previously added with addCleanupListener(CleanupListener). |
|
void |
removeClickListener(MouseEvents.ClickListener listener)
Remove a click listener from the UI. |
|
void |
removeListener(MouseEvents.ClickListener listener)
Deprecated. Since 7.0, replaced by #removeClickListener(ClickListener) |
|
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 |
setCaption(java.lang.String caption)
Deprecated. as of 7.0.0, use Page.setTitle(String) |
|
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 |
setLastHeartbeatTime(long lastHeartbeat)
Sets the last heartbeat request timestamp for this UI. |
|
void |
setLastUidlRequestTime(long lastUidlRequest)
Sets the last UIDL request timestamp for this UI. |
|
void |
setNavigator(Navigator navigator)
For internal use only. |
|
void |
setResizeLazy(boolean resizeLazy)
Should resize operations be lazy, i.e. |
|
void |
setScrollTop(int scrollTop)
|
|
void |
setSession(VaadinServiceSession session)
Sets the application to which this UI is assigned. |
|
void |
showNotification(Notification notification)
Deprecated. As of 7.0, use Notification.show instead |
|
void |
showNotification(java.lang.String caption)
Deprecated. As of 7.0, use Notification.show instead but be aware that Notification.show does not allow HTML. |
|
void |
showNotification(java.lang.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(java.lang.String caption,
java.lang.String description)
Deprecated. As of 7.0, use new Notification(...).show(Page) instead but be aware that HTML by default not allowed. |
|
void |
showNotification(java.lang.String caption,
java.lang.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(java.lang.String caption,
java.lang.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, isComponentVisible, removeComponentAttachListener, removeComponentDetachListener, removeFromParent, setContent, setHeight, setVisible, setWidth |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.vaadin.ui.LegacyComponent |
|---|
markAsDirty |
| Methods inherited from interface com.vaadin.server.VariableOwner |
|---|
isEnabled, isImmediate |
| Methods inherited from interface com.vaadin.ui.Component |
|---|
addListener, addStyleName, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setEnabled, setIcon, setId, setPrimaryStyleName, setReadOnly, setStyleName, setVisible |
| Methods inherited from interface com.vaadin.server.ClientConnector |
|---|
beforeClientResponse, detach, encodeState, getExtensions, handleConnectorRequest, markAsDirtyRecursive, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setParent |
| Methods inherited from interface com.vaadin.shared.Connector |
|---|
getConnectorId |
| Methods inherited from interface com.vaadin.server.RpcTarget |
|---|
getRpcManager |
| Methods inherited from interface com.vaadin.server.Sizeable |
|---|
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setSizeFull, setSizeUndefined, setWidth, setWidth |
| Field Detail |
|---|
protected ActionManager actionManager
| Constructor Detail |
|---|
public UI()
AbstractSingleComponentContainer.setContent(Component) before using the UI.
public UI(Component content)
content - the component to use as this UIs content.AbstractSingleComponentContainer.setContent(Component)| Method Detail |
|---|
protected com.vaadin.shared.ui.ui.UIState getState()
AbstractComponent
getState in class AbstractComponentpublic java.lang.Class<? extends com.vaadin.shared.ui.ui.UIState> getStateType()
ClientConnector
getStateType in interface ClientConnectorgetStateType in class AbstractClientConnectorpublic UI getUI()
getUI in interface ClientConnectorgetUI in interface ComponentgetUI in class AbstractClientConnectorAbstractClientConnector.getUI()public VaadinServiceSession 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 VaadinServiceSession.getCurrent()
to retrieve the application instance that the current request relates to.
Another way is to move the problematic initialization to
AbstractComponent.attach(), as described in the documentation of the method.
getSession in class AbstractClientConnectornull.AbstractComponent.attach()
public void paintContent(PaintTarget target)
throws PaintException
LegacyComponentPaints 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 LegacyComponenttarget - the target UIDL stream where the component should paint itself
to.
PaintException - if the paint operation failed.public void fireCleanupEvent()
public void changeVariables(java.lang.Object source,
java.util.Map<java.lang.String,java.lang.Object> variables)
VariableOwner
changeVariables in interface VariableOwnersource - 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 java.util.Iterator<Component> iterator()
HasComponents
iterator in interface HasComponentsiterator in interface java.lang.Iterable<Component>iterator in class AbstractSingleComponentContainerpublic int getComponentCount()
SingleComponentContainerSingleComponentContainer 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 SingleComponentContainergetComponentCount in class AbstractSingleComponentContainerpublic void setSession(VaadinServiceSession session)
null application.
This method is mainly intended for internal use by the framework.
session - the application to set
java.lang.IllegalStateException - if the application has already been setgetSession()public int getUIId()
VaadinService.findUI(VaadinRequest) uses this id to find the
route to which the request belongs.
public void addWindow(Window window)
throws java.lang.IllegalArgumentException,
java.lang.NullPointerException
UIProvider.
window -
java.lang.IllegalArgumentException - if the window is already added to an application
java.lang.NullPointerException - if the given Window is null.public boolean removeWindow(Window window)
Window.CloseListeners 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 java.util.Collection<Window> getWindows()
public void focus()
AbstractComponentFocusable.
focus in class AbstractComponentpublic void setFocusedComponent(Component.Focusable focusable)
Focusable.
focusable - to be focused on next paint
public void scrollIntoView(Component component)
throws java.lang.IllegalArgumentException
component - the component to be scrolled into view
java.lang.IllegalArgumentException - if component does not belong to this UI
public void doInit(VaadinRequest request,
int uiId)
request - the initialization requestuiId - the id of the new uiprotected 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 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.
uI - the UI to register as the current UIgetCurrent(),
ThreadLocalpublic static UI getCurrent()
nullsetCurrent(UI)public void setScrollTop(int scrollTop)
protected ActionManager getActionManager()
AbstractComponentActionManager used to manage the
ShortcutListeners added to this Field.
getActionManager in class AbstractComponentpublic <T extends Action & Action.Listener> void addAction(T action)
addAction in interface Action.Notifierpublic <T extends Action & Action.Listener> void removeAction(T action)
removeAction in interface Action.Notifierpublic void addActionHandler(Action.Handler actionHandler)
Action.Container
addActionHandler in interface Action.ContaineractionHandler - the new handler to be added.public void removeActionHandler(Action.Handler actionHandler)
Action.Container
removeActionHandler in interface Action.ContaineractionHandler - the handler to be removed.public void setResizeLazy(boolean resizeLazy)
Default value: false
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 void addClickListener(MouseEvents.ClickListener listener)
#removeListener(ClickListener) to remove the listener.
listener - The listener to addpublic void addCleanupListener(UI.CleanupListener listener)
listener - The CleanupListener that should be added.@Deprecated public void addListener(MouseEvents.ClickListener listener)
#addClickListener(ClickListener)
public void removeClickListener(MouseEvents.ClickListener listener)
#addListener(ClickListener).
listener - The listener to removepublic void removeCleanupListener(UI.CleanupListener listener)
addCleanupListener(CleanupListener).
listener - The CleanupListener that should be removed@Deprecated public void removeListener(MouseEvents.ClickListener listener)
#removeClickListener(ClickListener)
public boolean isConnectorEnabled()
ClientConnector
isConnectorEnabled in interface ClientConnectorisConnectorEnabled in class AbstractComponentpublic ConnectorTracker getConnectorTracker()
public Page getPage()
public Navigator getNavigator()
public void setNavigator(Navigator navigator)
navigator - @Deprecated public void setCaption(java.lang.String caption)
Page.setTitle(String)
setCaption in interface ComponentsetCaption in class AbstractComponentcaption - the new caption String for the component.@Deprecated public void showNotification(java.lang.String caption)
caption - The messageshowNotification(Notification),
Notification
@Deprecated
public void showNotification(java.lang.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(java.lang.String caption,
java.lang.String description)
caption - The caption of the messagedescription - The message descriptionshowNotification(Notification),
Notification
@Deprecated
public void showNotification(java.lang.String caption,
java.lang.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(java.lang.String caption,
java.lang.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 getLastHeartbeatTime()
#heartbeat(),
VaadinServiceSession.cleanupInactiveUIs()public long getLastUidlRequestTime()
public void setLastHeartbeatTime(long lastHeartbeat)
public void setLastUidlRequestTime(long lastUidlRequest)
public java.lang.String getTheme()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||