com.vaadin.ui
Class Root

java.lang.Object
  extended by com.vaadin.ui.AbstractComponent
      extended by com.vaadin.ui.AbstractComponentContainer
          extended by com.vaadin.ui.Root
All Implemented Interfaces:
Action.Container, Action.Notifier, MethodEventSource, Connector, ClientConnector, RpcTarget, Sizeable, Vaadin6Component, VariableOwner, Component, ComponentContainer, HasComponents, Serializable, Iterable<Component>, EventListener
Direct Known Subclasses:
Root.LegacyWindow

public abstract class Root
extends AbstractComponentContainer
implements Action.Container, Action.Notifier, Vaadin6Component

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.

Since:
7.0
See Also:
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
<T extends Action & Action.Listener>
void
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.
<T extends Action & Action.Listener>
void
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 com.vaadin.ui.AbstractComponent
addListener, addListener, addListener, addListener, addListener, addMethodInvocationToQueue, addShortcutListener, addStyleName, findAncestor, fireComponentErrorEvent, fireComponentEvent, fireEvent, getCaption, getComponentError, getConnectorId, getData, getDebugId, getDescription, getErrorHandler, getErrorMessage, getHeight, getHeightUnits, getIcon, getListeners, getLocale, getParent, getRpcManager, getRpcProxy, getStyle, getStyleName, getWidth, getWidthUnits, handleError, hasListeners, isEnabled, isImmediate, isReadOnly, isVisible, registerRpc, registerRpc, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeShortcutListener, removeStyleName, requestRepaint, retrievePendingRpcCalls, setCaption, setComponentError, setData, setDebugId, setDescription, setEnabled, setErrorHandler, setHeight, setIcon, setImmediate, setLocale, setParent, setReadOnly, setSizeFull, setSizeUndefined, setStyle, setStyleName, setWidth, updateState
 
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

BORDER_NONE

public static final int BORDER_NONE
A border style used for opening resources in a window without a border.

See Also:
Constant Field Values

BORDER_MINIMAL

public static final int BORDER_MINIMAL
A border style used for opening resources in a window with a minimal border.

See Also:
Constant Field Values

BORDER_DEFAULT

public static final int BORDER_DEFAULT
A border style that indicates that the default border style should be used when opening resources.

See Also:
Constant Field Values

actionManager

protected ActionManager actionManager
Keeps track of the Actions added to this component, and manages the painting and handling as well.

Constructor Detail

Root

public Root()
Creates a new empty root without a caption. This root will have a VerticalLayout with margins enabled as its content.


Root

public Root(ComponentContainer content)
Creates a new root with the given component container as its content.

Parameters:
content - the content container to use as this roots content.
See Also:
setContent(ComponentContainer)

Root

public Root(String caption)
Creates a new empty root with the given caption. This root will have a VerticalLayout with margins enabled as its content.

Parameters:
caption - the caption of the root, used as the page title if there's nothing but the application on the web page
See Also:
AbstractComponent.setCaption(String)

Root

public Root(String caption,
            ComponentContainer content)
Creates a new root with the given caption and content.

Parameters:
caption - the caption of the root, used as the page title if there's nothing but the application on the web page
content - the content container to use as this roots content.
See Also:
setContent(ComponentContainer), AbstractComponent.setCaption(String)
Method Detail

getState

public RootState getState()
Description copied from class: AbstractComponent
Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().

Specified by:
getState in interface Connector
Specified by:
getState in interface Component
Overrides:
getState in class AbstractComponent
Returns:
updated component shared state

createState

protected ComponentState createState()
Description copied from class: AbstractComponent
Creates the shared state bean to be used in server to client communication.

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().

Overrides:
createState in class AbstractComponent
Returns:
new shared state object

getRoot

public Root getRoot()
Overridden to return a value instead of referring to the parent.

Specified by:
getRoot in interface Component
Overrides:
getRoot in class AbstractComponent
Returns:
this root
See Also:
AbstractComponent.getRoot()

replaceComponent

public void replaceComponent(Component oldComponent,
                             Component newComponent)
Description copied from interface: ComponentContainer
Replaces the component in the container with another one without changing position.

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.

Specified by:
replaceComponent in interface ComponentContainer
Parameters:
oldComponent - the old component that will be replaced.
newComponent - the new component to be replaced.

getApplication

public Application getApplication()
Description copied from class: AbstractComponent
Gets the application object to which the component is attached.

The method will return null if the component is not currently attached to an application. 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.

Specified by:
getApplication in interface Component
Overrides:
getApplication in class AbstractComponent
Returns:
the parent application of the component or null.
See Also:
AbstractComponent.attach()

paintContent

public void paintContent(PaintTarget target)
                  throws PaintException
Description copied from interface: 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.

Specified by:
paintContent in interface Vaadin6Component
Parameters:
target - the target UIDL stream where the component should paint itself to.
Throws:
PaintException - if the paint operation failed.

changeVariables

public void changeVariables(Object source,
                            Map<String,Object> variables)
Description copied from interface: VariableOwner
Called when one or more variables handled by the implementing class are changed.

Specified by:
changeVariables in interface VariableOwner
Parameters:
source - the Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.
variables - the Mapping from variable names to new variable values.

getComponentIterator

public Iterator<Component> getComponentIterator()
Description copied from interface: HasComponents
Gets an iterator to the collection of contained components. Using this iterator it is possible to step through all components contained in this container.

Specified by:
getComponentIterator in interface HasComponents
Returns:
the component iterator.

getComponentCount

public int getComponentCount()
Description copied from interface: ComponentContainer
Gets the number of children this ComponentContainer has. This must be symmetric with what HasComponents.getComponentIterator() returns.

Specified by:
getComponentCount in interface ComponentContainer
Returns:
The number of child components this container has.

setApplication

public void setApplication(Application application)
Sets the application to which this root is assigned. It is not legal to change the application once it has been set nor to set a null application.

This method is mainly intended for internal use by the framework.

Parameters:
application - the application to set
Throws:
IllegalStateException - if the application has already been set
See Also:
getApplication()

setRootId

public void setRootId(int rootId)
Sets the id of this root within its application. The root id is used to route requests to the right root.

This method is mainly intended for internal use by the framework.

Parameters:
rootId - the id of this root
Throws:
IllegalStateException - if the root id has already been set
See Also:
getRootId()

getRootId

public int getRootId()
Gets the id of the root, used to identify this root within its application when processing requests. The root id should be present in every request to the server that originates from this root. Application.getRootForRequest(WrappedRequest) uses this id to find the route to which the request belongs.

Returns:

addWindow

public void addWindow(Window window)
               throws IllegalArgumentException,
                      NullPointerException
Adds a window as a subwindow inside this root. To open a new browser window or tab, you should instead use open(Resource) with an url pointing to this application and ensure Application.getRoot(WrappedRequest) returns an appropriate root for the request.

Parameters:
window -
Throws:
IllegalArgumentException - if the window is already added to an application
NullPointerException - if the given Window is null.

removeWindow

public boolean removeWindow(Window window)
Remove the given subwindow from this root. Since Vaadin 6.5, 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.

Parameters:
window - Window to be removed.
Returns:
true if the subwindow was removed, false otherwise

getWindows

public Collection<Window> getWindows()
Gets all the windows added to this root.

Returns:
an unmodifiable collection of windows

focus

public void focus()
Description copied from class: AbstractComponent
Sets the focus for this component if the component is Focusable.

Overrides:
focus in class AbstractComponent

setFocusedComponent

public void setFocusedComponent(Component.Focusable focusable)
This method is used by Component.Focusable objects to request focus to themselves. Focus renders must be handled at window level (instead of Component.Focusable) due we want the last focused component to be focused in client too. Not the one that is rendered last (the case we'd get if implemented in Focusable only). To focus component from Vaadin application, use Focusable.focus(). See Focusable.

Parameters:
focusable - to be focused on next paint

showNotification

public void showNotification(String caption)
Shows a notification message on the middle of the root. The message automatically disappears ("humanized message"). Care should be taken to to avoid XSS vulnerabilities as the caption is rendered as html.

Parameters:
caption - The message
See Also:
showNotification(Notification), Notification

showNotification

public void showNotification(String caption,
                             int type)
Shows a notification message the root. The position and behavior of the message depends on the type, which is one of the basic types defined in Notification, for instance Notification.TYPE_WARNING_MESSAGE. Care should be taken to to avoid XSS vulnerabilities as the caption is rendered as html.

Parameters:
caption - The message
type - The message type
See Also:
showNotification(Notification), Notification

showNotification

public void showNotification(String caption,
                             String description)
Shows a notification consisting of a bigger caption and a smaller description on the middle of the root. The message automatically disappears ("humanized message"). Care should be taken to to avoid XSS vulnerabilities as the caption and description are rendered as html.

Parameters:
caption - The caption of the message
description - The message description
See Also:
showNotification(Notification), Notification

showNotification

public void showNotification(String caption,
                             String description,
                             int type)
Shows a notification consisting of a bigger caption and a smaller description. The position and behavior of the message depends on the type, which is one of the basic types defined in Notification, for instance Notification.TYPE_WARNING_MESSAGE. Care should be taken to to avoid XSS vulnerabilities as the caption and description are rendered as html.

Parameters:
caption - The caption of the message
description - The message description
type - The message type
See Also:
showNotification(Notification), Notification

showNotification

public void showNotification(String caption,
                             String description,
                             int type,
                             boolean htmlContentAllowed)
Shows a notification consisting of a bigger caption and a smaller description. The position and behavior of the message depends on the type, which is one of the basic types defined in Notification, for instance Notification.TYPE_WARNING_MESSAGE. Care should be taken to avoid XSS vulnerabilities if html content is allowed.

Parameters:
caption - The message caption
description - The message description
type - The type of message
htmlContentAllowed - Whether html in the caption and description should be displayed as html or as plain text
See Also:
showNotification(Notification), Notification

showNotification

public void showNotification(Notification notification)
Shows a notification message.

Parameters:
notification - The notification message to show
See Also:
Notification, showNotification(String), showNotification(String, int), showNotification(String, String), showNotification(String, String, int)

executeJavaScript

public void executeJavaScript(String script)
Executes JavaScript in this root.

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.

Parameters:
script - JavaScript snippet that will be executed.

scrollIntoView

public void scrollIntoView(Component component)
                    throws IllegalArgumentException
Scrolls any component between the component and root to a suitable position so the component is visible to the user. The given component must belong to this root.

Parameters:
component - the component to be scrolled into view
Throws:
IllegalArgumentException - if component does not belong to this root

getContent

public ComponentContainer getContent()
Gets the content of this root. The content is a component container that serves as the outermost item of the visual contents of this root.

Returns:
a component container to use as content
See Also:
setContent(ComponentContainer), createDefaultLayout()

setContent

public void setContent(ComponentContainer content)
Sets the content of this root. The content is a component container that serves as the outermost item of the visual contents of this root. If no content has been set, a VerticalLayout with margins enabled will be used by default - see createDefaultLayout(). The content can also be set in a constructor.

See Also:
Root(ComponentContainer), createDefaultLayout()

addComponent

public void addComponent(Component component)
Adds a component to this root. The component is not added directly to the root, but instead to the content container (getContent()).

Specified by:
addComponent in interface ComponentContainer
Overrides:
addComponent in class AbstractComponentContainer
Parameters:
component - the component to add to this root
See Also:
getContent()

removeComponent

public void removeComponent(Component component)
This implementation removes the component from the content container ( getContent()) instead of from the actual root.

Specified by:
removeComponent in interface ComponentContainer
Overrides:
removeComponent in class AbstractComponentContainer
Parameters:
component - the component to be removed.
See Also:
ComponentContainer.removeComponent(Component)

removeAllComponents

public void removeAllComponents()
This implementation removes the components from the content container ( getContent()) instead of from the actual root.

Specified by:
removeAllComponents in interface ComponentContainer
Overrides:
removeAllComponents in class AbstractComponentContainer

doInit

public void doInit(WrappedRequest request)
Internal initialization method, should not be overridden. This method is not declared as final because that would break compatibility with e.g. CDI.

Parameters:
request - the initialization request

init

protected abstract void init(WrappedRequest request)
Initializes this root. This method is intended to be overridden by subclasses to build the view and configure non-component functionality. Performing the initialization in a constructor is not suggested as the state of the root is not properly set up when the constructor is invoked.

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.

Parameters:
request - the wrapped request that caused this root to be created

setCurrentRoot

public static void setCurrentRoot(Root root)
Sets the thread local for the current root. This method is used by the framework to set the current application whenever a new request is processed and it is cleared when the request has been processed.

The application developer can also use this method to define the current root outside the normal request handling, e.g. when initiating custom background threads.

Parameters:
root - the root to register as the current root
See Also:
getCurrentRoot(), ThreadLocal

getCurrentRoot

public static Root getCurrentRoot()
Gets the currently used root. The current root is automatically defined when processing requests to the server. In other cases, (e.g. from background threads), the current root is not automatically defined.

Returns:
the current root instance if available, otherwise null
See Also:
setCurrentRoot(Root)

open

public void open(Resource resource)
Opens the given resource in this root. The contents of this Root is replaced by the Resource.

Parameters:
resource - the resource to show in this root

open

public void open(Resource resource,
                 String windowName)
Opens the given resource in a window with the given name.

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.

Parameters:
resource - the resource.
windowName - the name of the window.

open

public 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. For more information on the meaning of windowName, see open(Resource, String).

Parameters:
resource - the resource.
windowName - the name of the window.
width - the width of the window in pixels
height - the height of the window in pixels
border - the border style of the window. See Window.BORDER_* constants

setScrollTop

public void setScrollTop(int scrollTop)

getActionManager

protected ActionManager getActionManager()
Description copied from class: AbstractComponent
Gets the ActionManager used to manage the ShortcutListeners added to this Field.

Overrides:
getActionManager in class AbstractComponent
Returns:
the ActionManager in use

addAction

public <T extends Action & Action.Listener> void addAction(T action)
Specified by:
addAction in interface Action.Notifier

removeAction

public <T extends Action & Action.Listener> void removeAction(T action)
Specified by:
removeAction in interface Action.Notifier

addActionHandler

public void addActionHandler(Action.Handler actionHandler)
Description copied from interface: Action.Container
Registers a new action handler for this container

Specified by:
addActionHandler in interface Action.Container
Parameters:
actionHandler - the new handler to be added.

removeActionHandler

public void removeActionHandler(Action.Handler actionHandler)
Description copied from interface: Action.Container
Removes a previously registered action handler for the contents of this container.

Specified by:
removeActionHandler in interface Action.Container
Parameters:
actionHandler - the handler to be removed.

setResizeLazy

public void setResizeLazy(boolean resizeLazy)
Should resize operations be lazy, i.e. should there be a delay before layout sizes are recalculated. Speeds up resize operations in slow UIs with the penalty of slightly decreased usability.

Default value: false

Parameters:
resizeLazy - true to use a delay before recalculating sizes, false to calculate immediately.

isResizeLazy

public boolean isResizeLazy()
Checks whether lazy resize is enabled.

Returns:
true if lazy resize is enabled, false if lazy resize is not enabled

addListener

public void addListener(MouseEvents.ClickListener listener)
Add a click listener to the Root. The listener is called whenever the user clicks inside the Root. Also when the click targets a component inside the Root, provided the targeted component does not prevent the click event from propagating. Use #removeListener(ClickListener) to remove the listener.

Parameters:
listener - The listener to add

removeListener

public void removeListener(MouseEvents.ClickListener listener)
Remove a click listener from the Root. The listener should earlier have been added using #addListener(ClickListener).

Parameters:
listener - The listener to remove

addListener

public void addListener(Root.FragmentChangedListener listener)

removeListener

public void removeListener(Root.FragmentChangedListener listener)

setFragment

public void setFragment(String newFragment,
                        boolean fireEvents)
Sets URI fragment. Optionally fires a Root.FragmentChangedEvent

Parameters:
newFragment - id of the new fragment
fireEvent - true to fire event
See Also:
Root.FragmentChangedEvent, Root.FragmentChangedListener

setFragment

public void setFragment(String newFragment)
Sets URI fragment. This method fires a Root.FragmentChangedEvent

Parameters:
newFragment - id of the new fragment
See Also:
Root.FragmentChangedEvent, Root.FragmentChangedListener

getFragment

public String getFragment()
Gets currently set URI fragment.

To listen changes in fragment, hook a Root.FragmentChangedListener.

Returns:
the current fragment in browser uri or null if not known

addListener

public void addListener(Root.BrowserWindowResizeListener resizeListener)
Adds a new Root.BrowserWindowResizeListener to this root. The listener will be notified whenever the browser window within which this root resides is resized.

Parameters:
resizeListener - the listener to add
See Also:
BrowserWindowResizeListener#browserWindowResized(BrowserWindowResizeEvent), setResizeLazy(boolean)

removeListener

public void removeListener(Root.BrowserWindowResizeListener resizeListener)
Removes a Root.BrowserWindowResizeListener from this root. The listener will no longer be notified when the browser window is resized.

Parameters:
resizeListener - the listener to remove

getBrowserWindowHeight

public int getBrowserWindowHeight()
Gets the last known height of the browser window in which this root resides.

Returns:
the browser window height in pixels

getBrowserWindowWidth

public int getBrowserWindowWidth()
Gets the last known width of the browser window in which this root resides.

Returns:
the browser window width in pixels

attach

public void attach()
Notifies the child components and windows that the root is attached to the application.

Specified by:
attach in interface Component
Overrides:
attach in class AbstractComponentContainer
See Also:
Component.attach()

detach

public void detach()
Notifies the child components and windows that the root is detached from the application.

Specified by:
detach in interface Component
Overrides:
detach in class AbstractComponentContainer
See Also:
Component.detach()

isConnectorEnabled

public boolean isConnectorEnabled()
Description copied from interface: ClientConnector
Checks if the communicator is enabled. An enabled communicator is allowed to receive messages from its counter-part.

Specified by:
isConnectorEnabled in interface ClientConnector
Overrides:
isConnectorEnabled in class AbstractComponent
Returns:
true if the connector can receive messages, false otherwise

getDirtyConnectorTracker

public DirtyConnectorTracker getDirtyConnectorTracker()

componentAttached

public void componentAttached(Component component)

componentDetached

public void componentDetached(Component component)


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.