|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.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 Form| Nested Class Summary | |
|---|---|
class |
Root.BrowserWindowResizeEvent
Event that is fired when a browser window containing a root is resized. |
static interface |
Root.BrowserWindowResizeListener
Listener that gets notified when the size of the browser window containing the root has changed. |
class |
Root.FragmentChangedEvent
Event fired when uri fragment changes. |
static interface |
Root.FragmentChangedListener
Listener that listens changes in URI fragment. |
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, Component.RepaintRequestEvent, Component.RepaintRequestListener |
| 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. |
static int |
BORDER_DEFAULT
A border style that indicates that the default border style should be used when opening resources. |
static int |
BORDER_MINIMAL
A border style used for opening resources in a window with a minimal border. |
static int |
BORDER_NONE
A border style used for opening resources in a window without a border. |
| 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 |
addListener(Root.BrowserWindowResizeListener resizeListener)
Adds a new Root.BrowserWindowResizeListener to this root. |
|
void |
addListener(Root.FragmentChangedListener listener)
|
|
void |
addWindow(Window window)
Adds a window as a subwindow inside this root. |
|
void |
attach()
Notifies the child components and windows that the root is attached to the application. |
|
void |
changeVariables(Object source,
Map<String,Object> variables)
Called when one or more variables handled by the implementing class are changed. |
|
void |
componentAttached(Component component)
|
|
void |
componentDetached(Component component)
|
|
protected ComponentState |
createState()
Creates the shared state bean to be used in server to client communication. |
|
void |
detach()
Notifies the child components and windows that the root is detached from the application. |
|
void |
doInit(WrappedRequest request)
Internal initialization method, should not be overridden. |
|
void |
executeJavaScript(String script)
Executes JavaScript in this root. |
|
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. |
|
Application |
getApplication()
Gets the application object to which the component is attached. |
|
int |
getBrowserWindowHeight()
Gets the last known height of the browser window in which this root resides. |
|
int |
getBrowserWindowWidth()
Gets the last known width of the browser window in which this root resides. |
|
int |
getComponentCount()
Gets the number of children this ComponentContainer has. |
|
Iterator<Component> |
getComponentIterator()
Gets an iterator to the collection of contained components. |
|
ComponentContainer |
getContent()
Gets the content of this root. |
|
static Root |
getCurrentRoot()
Gets the currently used root. |
|
DirtyConnectorTracker |
getDirtyConnectorTracker()
|
|
String |
getFragment()
Gets currently set URI fragment. |
|
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. |
|
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 |
open(Resource resource)
Opens the given resource in this root. |
|
void |
open(Resource resource,
String windowName)
Opens the given resource in a window with the given name. |
|
void |
open(Resource resource,
String windowName,
int width,
int height,
int border)
Opens the given resource in a window with the given size, border and name. |
|
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. |
|
void |
removeListener(Root.BrowserWindowResizeListener resizeListener)
Removes a Root.BrowserWindowResizeListener from this root. |
|
void |
removeListener(Root.FragmentChangedListener listener)
|
|
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 |
setContent(ComponentContainer content)
Sets the content of this root. |
|
static void |
setCurrentRoot(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 |
setFragment(String newFragment)
Sets URI fragment. |
|
void |
setFragment(String newFragment,
boolean fireEvents)
Sets URI fragment. |
|
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)
Shows a notification message. |
|
void |
showNotification(String caption)
Shows a notification message on the middle of the root. |
|
void |
showNotification(String caption,
int type)
Shows a notification message the root. |
|
void |
showNotification(String caption,
String description)
Shows a notification consisting of a bigger caption and a smaller description on the middle of the root. |
|
void |
showNotification(String caption,
String description,
int type)
Shows a notification consisting of a bigger caption and a smaller description. |
|
void |
showNotification(String caption,
String description,
int type,
boolean htmlContentAllowed)
Shows a notification consisting of a bigger caption and a smaller description. |
|
| Methods inherited from class com.vaadin.ui.AbstractComponentContainer |
|---|
addListener, addListener, fireComponentAttachEvent, fireComponentDetachEvent, isComponentVisible, iterator, moveComponentsFrom, removeListener, removeListener, requestRepaintAll, requestRepaintAll, 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.terminal.VariableOwner |
|---|
isEnabled, isImmediate |
| Methods inherited from interface com.vaadin.ui.Component |
|---|
addListener, addListener, addStyleName, getCaption, getDebugId, getIcon, getLocale, getParent, getStyleName, isEnabled, isReadOnly, isVisible, removeListener, removeListener, removeStyleName, requestRepaint, setCaption, setDebugId, setEnabled, setIcon, setParent, setReadOnly, setStyleName, setVisible, updateState |
| Methods inherited from interface com.vaadin.terminal.gwt.server.ClientConnector |
|---|
retrievePendingRpcCalls |
| 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 |
|---|
public static final int BORDER_NONE
public static final int BORDER_MINIMAL
public static final int BORDER_DEFAULT
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 pageAbstractComponent.setCaption(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),
AbstractComponent.setCaption(String)| Method Detail |
|---|
public RootState getState()
AbstractComponent
getState in interface ConnectorgetState in interface ComponentgetState in class AbstractComponentprotected ComponentState createState()
AbstractComponent
By default a state object of the defined return type of
AbstractComponent.getState() is created. Subclasses can override this method and
return a new instance of the correct state class but this should rarely
be necessary.
No configuration of the values of the state should be performed in
AbstractComponent.createState().
createState in class AbstractComponentpublic Root getRoot()
getRoot in interface ComponentgetRoot in class AbstractComponentAbstractComponent.getRoot()
public void replaceComponent(Component oldComponent,
Component newComponent)
ComponentContainerThis 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 ComponentContaineroldComponent - 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 ComponentgetApplication in class AbstractComponentnull.AbstractComponent.attach()
public void paintContent(PaintTarget target)
throws PaintException
Vaadin6ComponentPaints 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 Vaadin6Componenttarget - 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 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 Iterator<Component> getComponentIterator()
HasComponents
getComponentIterator in interface HasComponentspublic int getComponentCount()
ComponentContainerComponentContainer has. This
must be symmetric with what HasComponents.getComponentIterator() returns.
getComponentCount in interface ComponentContainerpublic 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.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 Collection<Window> getWindows()
public void focus()
AbstractComponentFocusable.
focus in class AbstractComponentpublic void setFocusedComponent(Component.Focusable focusable)
Focusable.
focusable - to be focused on next paintpublic void showNotification(String caption)
caption - The messageshowNotification(Notification),
Notification
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
public void showNotification(String caption,
String description)
caption - The caption of the messagedescription - The message descriptionshowNotification(Notification),
Notification
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
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),
Notificationpublic void showNotification(Notification notification)
notification - The notification message to showNotification,
showNotification(String),
showNotification(String, int),
showNotification(String, String),
showNotification(String, String, int)public void executeJavaScript(String script)
This method allows one to inject javascript from the server to client. A client implementation is not required to implement this functionality, but currently all web-based clients do implement this.
Executing javascript this way often leads to cross-browser compatibility issues and regressions that are hard to resolve. Use of this method should be avoided and instead it is recommended to create new widgets with GWT. For more info on creating own, reusable client-side widgets in Java, read the corresponding chapter in Book of Vaadin.
script - JavaScript snippet that will be executed.
public 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 ComponentContaineraddComponent in class AbstractComponentContainercomponent - the component to add to this rootgetContent()public void removeComponent(Component component)
getContent()) instead of from the actual root.
removeComponent in interface ComponentContainerremoveComponent in class AbstractComponentContainercomponent - the component to be removed.ComponentContainer.removeComponent(Component)public void removeAllComponents()
getContent()) instead of from the actual root.
removeAllComponents in interface ComponentContainerremoveAllComponents in class AbstractComponentContainerpublic 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 setCurrentRoot(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 rootgetCurrentRoot(),
ThreadLocalpublic static Root getCurrentRoot()
nullsetCurrentRoot(Root)public void open(Resource resource)
Resource.
resource - the resource to show in this root
public void open(Resource resource,
String windowName)
The supplied windowName is used as the target name in a
window.open call in the client. This means that special values such as
"_blank", "_self", "_top", "_parent" have special meaning. An empty or
null window name is also a special case.
"", null and "_self" as windowName all causes the resource to be
opened in the current window, replacing any old contents. For
downloadable content you should avoid "_self" as "_self" causes the
client to skip rendering of any other changes as it considers them
irrelevant (the page will be replaced by the resource). This can speed up
the opening of a resource, but it might also put the client side into an
inconsistent state if the window content is not completely replaced e.g.,
if the resource is downloaded instead of displayed in the browser.
"_blank" as windowName causes the resource to always be opened in
a new window or tab (depends on the browser and browser settings).
"_top" and "_parent" as windowName works as specified by the HTML
standard.
Any other windowName will open the resource in a window with that
name, either by opening a new window/tab in the browser or by replacing
the contents of an existing window with that name.
resource - the resource.windowName - the name of the window.
public void open(Resource resource,
String windowName,
int width,
int height,
int border)
windowName, see
open(Resource, String).
resource - the resource.windowName - the name of the window.width - the width of the window in pixelsheight - the height of the window in pixelsborder - the border style of the window. See Window.BORDER_* constantspublic 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 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 void addListener(Root.FragmentChangedListener listener)
public void removeListener(Root.FragmentChangedListener listener)
public void setFragment(String newFragment,
boolean fireEvents)
Root.FragmentChangedEvent
newFragment - id of the new fragmentfireEvent - true to fire eventRoot.FragmentChangedEvent,
Root.FragmentChangedListenerpublic void setFragment(String newFragment)
Root.FragmentChangedEvent
newFragment - id of the new fragmentRoot.FragmentChangedEvent,
Root.FragmentChangedListenerpublic String getFragment()
To listen changes in fragment, hook a Root.FragmentChangedListener.
public void addListener(Root.BrowserWindowResizeListener resizeListener)
Root.BrowserWindowResizeListener to this root. The listener
will be notified whenever the browser window within which this root
resides is resized.
resizeListener - the listener to addBrowserWindowResizeListener#browserWindowResized(BrowserWindowResizeEvent),
setResizeLazy(boolean)public void removeListener(Root.BrowserWindowResizeListener resizeListener)
Root.BrowserWindowResizeListener from this root. The
listener will no longer be notified when the browser window is resized.
resizeListener - the listener to removepublic int getBrowserWindowHeight()
public int getBrowserWindowWidth()
public void attach()
attach in interface Componentattach in class AbstractComponentContainerComponent.attach()public void detach()
detach in interface Componentdetach in class AbstractComponentContainerComponent.detach()public boolean isConnectorEnabled()
ClientConnector
isConnectorEnabled in interface ClientConnectorisConnectorEnabled in class AbstractComponentpublic DirtyConnectorTracker getDirtyConnectorTracker()
public void componentAttached(Component component)
public void componentDetached(Component component)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||