com.vaadin.terminal
Class Page

java.lang.Object
  extended by com.vaadin.terminal.Page
All Implemented Interfaces:
Serializable

public class Page
extends Object
implements Serializable

See Also:
Serialized Form

Nested Class Summary
 class Page.BrowserWindowResizeEvent
          Event that is fired when a browser window containing a root is resized.
static interface Page.BrowserWindowResizeListener
          Listener that gets notified when the size of the browser window containing the root has changed.
 class Page.FragmentChangedEvent
          Event fired when uri fragment changes.
static interface Page.FragmentChangedListener
          Listener that listens changes in URI fragment.
 
Field Summary
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.
 
Constructor Summary
Page(Root root)
           
 
Method Summary
 void addListener(Page.BrowserWindowResizeListener resizeListener)
          Adds a new Page.BrowserWindowResizeListener to this root.
 void addListener(Page.FragmentChangedListener listener)
           
 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.
static Page getCurrent()
          Gets the Page to which the current root belongs.
 String getFragment()
          Gets currently set URI fragment.
 JavaScript getJavaScript()
           
 WebBrowser getWebBrowser()
           
 void init(WrappedRequest request)
           
 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)
           
 void removeListener(Page.BrowserWindowResizeListener resizeListener)
          Removes a Page.BrowserWindowResizeListener from this root.
 void removeListener(Page.FragmentChangedListener listener)
           
 void setBrowserWindowSize(Integer width, Integer height)
           
 void setFragment(String newFragment)
          Sets URI fragment.
 void setFragment(String newFragment, boolean fireEvents)
          Sets URI fragment.
 void setTitle(String title)
          Sets the page title.
 void showNotification(Notification notification)
          Deprecated. Use Notification.show(Page) instead.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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
Constructor Detail

Page

public Page(Root root)
Method Detail

addListener

public void addListener(Page.FragmentChangedListener listener)

removeListener

public void removeListener(Page.FragmentChangedListener listener)

setFragment

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

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

setFragment

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

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

getFragment

public String getFragment()
Gets currently set URI fragment.

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

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

init

public void init(WrappedRequest request)

getWebBrowser

public WebBrowser getWebBrowser()

setBrowserWindowSize

public void setBrowserWindowSize(Integer width,
                                 Integer height)

addListener

public void addListener(Page.BrowserWindowResizeListener resizeListener)
Adds a new Page.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(Page.BrowserWindowResizeListener resizeListener)
Removes a Page.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

getJavaScript

public JavaScript getJavaScript()

paintContent

public void paintContent(PaintTarget target)
                  throws PaintException
Throws:
PaintException

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

showNotification

@Deprecated
public void showNotification(Notification notification)
Deprecated. Use Notification.show(Page) instead.

Shows a notification message.

Parameters:
notification - The notification message to show
See Also:
Notification

getCurrent

public static Page getCurrent()
Gets the Page to which the current root belongs. This 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 page instance if available, otherwise null
See Also:
Root.getCurrent()

setTitle

public void setTitle(String title)
Sets the page title. The page title is displayed by the browser e.g. as the title of the browser window or as the title of the tab.

Parameters:
title - the new page title to set


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