|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.vaadin.terminal.AbstractClientConnector com.vaadin.ui.AbstractComponent com.vaadin.ui.AbstractComponentContainer com.vaadin.ui.Root
public abstract class Root
The topmost component in any component hierarchy. There is one root for every Vaadin instance in a browser window. A root may either represent an entire browser window (or tab) or some part of a html page where a Vaadin application is embedded.
The root 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 application instance is needed, typically because the user opens
the application in a browser window,
Application#gerRoot(WrappedRequest)
is invoked to get a root. That
method does by default create a root according to the
parameter from web.xml.
After a root has been created by the application, it is initialized using
init(WrappedRequest)
. 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 is initialized by
passing a ComponentContainer
with the main layout of the view to
setContent(ComponentContainer)
.
If a EagerInit
annotation is present on a class extending
Root
, the framework will use a faster initialization method
which will not ensure that WrappedRequest.BrowserDetails
are present in the
WrappedRequest
passed to the init method.
init(WrappedRequest)
,
Application.getRoot(WrappedRequest)
,
Serialized FormNested Class Summary | |
---|---|
static class |
Root.LegacyWindow
Deprecated. |
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractComponent |
---|
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler |
Nested classes/interfaces inherited from interface com.vaadin.terminal.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.terminal.Sizeable |
---|
Sizeable.Unit |
Nested classes/interfaces inherited from interface com.vaadin.ui.ComponentContainer |
---|
ComponentContainer.ComponentAttachEvent, ComponentContainer.ComponentAttachListener, ComponentContainer.ComponentDetachEvent, ComponentContainer.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.terminal.Sizeable |
---|
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS |
Constructor Summary | |
---|---|
Root()
Creates a new empty root without a caption. |
|
Root(ComponentContainer content)
Creates a new root with the given component container as its content. |
|
Root(String caption)
Creates a new empty root with the given caption. |
|
Root(String caption,
ComponentContainer content)
Creates a new root with the given caption and content. |
Method Summary | ||
---|---|---|
|
addAction(T action)
|
|
void |
addActionHandler(Action.Handler actionHandler)
Registers a new action handler for this container |
|
void |
addComponent(Component component)
Adds a component to this root. |
|
void |
addListener(MouseEvents.ClickListener listener)
Add a click listener to the Root. |
|
void |
addWindow(Window window)
Adds a window as a subwindow inside this root. |
|
void |
changeVariables(Object source,
Map<String,Object> variables)
Called when one or more variables handled by the implementing class are changed. |
|
void |
doInit(WrappedRequest request)
Internal initialization 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 Field . |
|
Application |
getApplication()
Gets the application object to which the component is attached. |
|
int |
getComponentCount()
Gets the number of children this ComponentContainer has. |
|
Iterator<Component> |
getComponentIterator()
Gets an iterator to the collection of contained components. |
|
ConnectorTracker |
getConnectorTracker()
|
|
ComponentContainer |
getContent()
Gets the content of this root. |
|
static Root |
getCurrent()
Gets the currently used root. |
|
Page |
getPage()
|
|
Root |
getRoot()
Overridden to return a value instead of referring to the parent. |
|
int |
getRootId()
Gets the id of the root, used to identify this root within its application when processing requests. |
|
RootState |
getState()
Returns the shared state bean with information to be sent from the server to the client. |
|
Class<? extends RootState> |
getStateType()
Returns the type of the shared state for this connector |
|
Collection<Window> |
getWindows()
Gets all the windows added to this root. |
|
protected abstract void |
init(WrappedRequest request)
Initializes this root. |
|
boolean |
isConnectorEnabled()
Checks if the communicator is enabled. |
|
boolean |
isResizeLazy()
Checks whether lazy resize is enabled. |
|
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 |
removeAllComponents()
This implementation removes the components from the content container ( getContent() ) instead of from the actual root. |
|
void |
removeComponent(Component component)
This implementation removes the component from the content container ( getContent() ) instead of from the actual root. |
|
void |
removeListener(MouseEvents.ClickListener listener)
Remove a click listener from the Root. |
|
boolean |
removeWindow(Window window)
Remove the given subwindow from this root. |
|
void |
replaceComponent(Component oldComponent,
Component newComponent)
Replaces the component in the container with another one without changing position. |
|
void |
scrollIntoView(Component component)
Scrolls any component between the component and root to a suitable position so the component is visible to the user. |
|
void |
setApplication(Application application)
Sets the application to which this root is assigned. |
|
void |
setCaption(String caption)
Deprecated. as of 7.0.0, use Page.setTitle(String) |
|
void |
setContent(ComponentContainer content)
Sets the content of this root. |
|
static void |
setCurrent(Root root)
Sets the thread local for the current root. |
|
void |
setFocusedComponent(Component.Focusable focusable)
This method is used by Component.Focusable objects to request focus to themselves. |
|
void |
setResizeLazy(boolean resizeLazy)
Should resize operations be lazy, i.e. |
|
void |
setRootId(int rootId)
Sets the id of this root within its application. |
|
void |
setScrollTop(int scrollTop)
|
|
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,
int 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,
int 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,
int type,
boolean htmlContentAllowed)
Deprecated. As of 7.0, use new Notification(...).show(Page). |
Methods inherited from class com.vaadin.ui.AbstractComponentContainer |
---|
addListener, addListener, fireComponentAttachEvent, fireComponentDetachEvent, isComponentVisible, iterator, moveComponentsFrom, removeListener, removeListener, setHeight, setVisible, setWidth |
Methods inherited from class com.vaadin.terminal.AbstractClientConnector |
---|
addExtension, addMethodInvocationToQueue, createState, getAllChildrenIterable, getConnectorId, getExtensions, getRpcManager, getRpcProxy, registerRpc, registerRpc, removeExtension, requestRepaintAll, retrievePendingRpcCalls |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.vaadin.terminal.VariableOwner |
---|
isEnabled, isImmediate |
Methods inherited from interface com.vaadin.ui.Component |
---|
addListener, addStyleName, attach, getCaption, getDebugId, getIcon, getLocale, getParent, getStyleName, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setDebugId, setEnabled, setIcon, setReadOnly, setStyleName, setVisible, updateState |
Methods inherited from interface com.vaadin.terminal.gwt.server.ClientConnector |
---|
detach, getExtensions, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setParent |
Methods inherited from interface com.vaadin.terminal.gwt.client.Connector |
---|
getConnectorId |
Methods inherited from interface com.vaadin.terminal.gwt.server.RpcTarget |
---|
getRpcManager |
Methods inherited from interface com.vaadin.terminal.Sizeable |
---|
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setSizeFull, setSizeUndefined, setWidth, setWidth |
Field Detail |
---|
protected ActionManager actionManager
Constructor Detail |
---|
public Root()
VerticalLayout
with margins enabled as its content.
public Root(ComponentContainer content)
content
- the content container to use as this roots content.setContent(ComponentContainer)
public Root(String caption)
VerticalLayout
with margins enabled as its content.
caption
- the caption of the root, used as the page title if there's
nothing but the application on the web pagesetCaption(String)
public Root(String caption, ComponentContainer content)
caption
- the caption of the root, used as the page title if there's
nothing but the application on the web pagecontent
- the content container to use as this roots content.setContent(ComponentContainer)
,
setCaption(String)
Method Detail |
---|
public RootState getState()
AbstractComponent
getState
in interface Connector
getState
in interface Component
getState
in class AbstractComponent
public Class<? extends RootState> getStateType()
ClientConnector
getStateType
in interface ClientConnector
getStateType
in class AbstractClientConnector
public Root getRoot()
getRoot
in interface ClientConnector
getRoot
in interface Component
getRoot
in class AbstractComponent
AbstractComponent.getRoot()
public void replaceComponent(Component oldComponent, Component newComponent)
ComponentContainer
This method replaces component with another one is such way that the new component overtakes the position of the old component. If the old component is not in the container, the new component is added to the container. If the both component are already in the container, their positions are swapped. Component attach and detach events should be taken care as with add and remove.
replaceComponent
in interface ComponentContainer
oldComponent
- the old component that will be replaced.newComponent
- the new component to be replaced.public Application getApplication()
AbstractComponent
The method will return null
if the component is not currently
attached to an application. This is often a problem in constructors of
regular components and in the initializers of custom composite
components. A standard workaround is to move the problematic
initialization to AbstractComponent.attach()
, as described in the documentation of
the method.
This method is not meant to be overridden. Due to CDI requirements we cannot declare it as final even though it should be final.
getApplication
in interface Component
getApplication
in class AbstractComponent
null
.AbstractComponent.attach()
public void paintContent(PaintTarget target) throws PaintException
Vaadin6Component
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 Vaadin6Component
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> getComponentIterator()
HasComponents
getComponentIterator
in interface HasComponents
public int getComponentCount()
ComponentContainer
ComponentContainer
has. This
must be symmetric with what HasComponents.getComponentIterator()
returns.
getComponentCount
in interface ComponentContainer
public void setApplication(Application application)
null
application.
This method is mainly intended for internal use by the framework.
application
- the application to set
IllegalStateException
- if the application has already been setgetApplication()
public void setRootId(int rootId)
This method is mainly intended for internal use by the framework.
rootId
- the id of this root
IllegalStateException
- if the root id has already been setgetRootId()
public int getRootId()
Application.getRootForRequest(WrappedRequest)
uses this id to
find the route to which the request belongs.
public void addWindow(Window window) throws IllegalArgumentException, NullPointerException
open(Resource)
with an url
pointing to this application and ensure
Application.getRoot(WrappedRequest)
returns an appropriate root
for the request.
window
-
IllegalArgumentException
- if the window is already added to an application
NullPointerException
- 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 class AbstractComponent
public void setFocusedComponent(Component.Focusable focusable)
Focusable
.
focusable
- to be focused on next paintpublic void scrollIntoView(Component component) throws IllegalArgumentException
component
- the component to be scrolled into view
IllegalArgumentException
- if component
does not belong to this rootpublic ComponentContainer getContent()
setContent(ComponentContainer)
,
createDefaultLayout()
public void setContent(ComponentContainer content)
VerticalLayout
with margins enabled will
be used by default - see createDefaultLayout()
. The content can
also be set in a constructor.
Root(ComponentContainer)
,
createDefaultLayout()
public void addComponent(Component component)
getContent()
).
addComponent
in interface ComponentContainer
addComponent
in class AbstractComponentContainer
component
- the component to add to this rootgetContent()
public void removeComponent(Component component)
getContent()
) instead of from the actual root.
removeComponent
in interface ComponentContainer
removeComponent
in class AbstractComponentContainer
component
- the component to be removed.ComponentContainer.removeComponent(Component)
public void removeAllComponents()
getContent()
) instead of from the actual root.
removeAllComponents
in interface ComponentContainer
removeAllComponents
in class AbstractComponentContainer
public void doInit(WrappedRequest request)
request
- the initialization requestprotected abstract void init(WrappedRequest request)
The WrappedRequest
can be used to get information about the
request that caused this root to be created. By default, the
WrappedRequest.BrowserDetails
will be available in the request. If the browser
details are not required, loading the application in the browser can take
some shortcuts giving a faster initial rendering. This can be indicated
by adding the EagerInit
annotation to the Root class.
request
- the wrapped request that caused this root to be createdpublic static void setCurrent(Root root)
The application developer can also use this method to define the current root outside the normal request handling, e.g. when initiating custom background threads.
root
- the root to register as the current rootgetCurrent()
,
ThreadLocal
public static Root getCurrent()
null
setCurrent(Root)
public void setScrollTop(int scrollTop)
protected ActionManager getActionManager()
AbstractComponent
ActionManager
used to manage the
ShortcutListener
s added to this Field
.
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
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 addListener(MouseEvents.ClickListener listener)
#removeListener(ClickListener)
to remove the listener.
listener
- The listener to addpublic void removeListener(MouseEvents.ClickListener listener)
#addListener(ClickListener)
.
listener
- The listener to removepublic boolean isConnectorEnabled()
ClientConnector
isConnectorEnabled
in interface ClientConnector
isConnectorEnabled
in class AbstractComponent
public ConnectorTracker getConnectorTracker()
public Page getPage()
@Deprecated public void setCaption(String caption)
Page.setTitle(String)
setCaption
in interface Component
setCaption
in class AbstractComponent
caption
- the new caption String
for the component.@Deprecated public void showNotification(String caption)
caption
- The messageshowNotification(Notification)
,
Notification
@Deprecated public void showNotification(String caption, int 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, int 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, int 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)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |