com.smartgwt.client.util
Class Page

java.lang.Object
  extended by com.smartgwt.client.util.Page

public class Page
extends Object

Provides information about the page you're loaded in. We define "page" here to be roughly equivalent to the browser window or frame the libraries have been loaded in.


Constructor Summary
Page()
           
 
Method Summary
static void checkBrowserAndRedirect()
          Check whether the browser is supported by the Isomorphic Smart GWT system.
static void checkBrowserAndRedirect(String URL)
          Check whether the browser is supported by the Isomorphic Smart GWT system.
static String getAppDir()
          Returns the base URL of the application, which is the page URL minus the last non-directory path component.
static void getAppFilesDir()
          Returns the directory for application-specific files (other than images).
static void getAppFilesDir(String URL)
          Returns the directory for application-specific files (other than images).
static String getAppImgDir()
          Return the directory for app-specific images.
static int getHeight()
          Get the height of the visible portion of the window, not including browser chrome or the scrollbar area.
static String getImgURL(String src)
          Return the full URL for app-specific or skin image.
static String getImgURL(String src, String imgDir)
          Return the full URL for app-specific or skin image.
static String getIsomorphicDir()
          Return the root directory for Isomorphic-specific files.
static int getScreenHeight()
          Get the height of the user's screen, in pixels.
static int getScreenWidth()
          Get the width of the user's screen, in pixels.
static int getScrollHeight()
          Get the height of the window contents as they have been drawn.
static int getScrollLeft()
          Get the amount that the browser window has been scrolled horizontally.
static int getScrollTop()
          Get the amount that the browser window has been scrolled vertically.
static int getScrollWidth()
          Get the width of the window contents as they have been drawn.
static String getSkinDir()
          Return the directory for media that's part of the skin
static String getSkinImgDir()
          Return the directory for a skin image.
static String getSkinImgDir(String imgDir)
          Return the directory for a skin image.
static String getUnsupportedBrowserPromptString()
          Returns the text for the prompt shown to user from checkBrowserAndRedirect() if they are accessing this page in an unsupported browser and com.smartgwt.client.util.Page#unsupportedBrowserAction is set to "confirm".
static String getURL(String fileName)
          Return a full URL for a relative path that uses a special prefix such as "[APPFILES]" or "[SKIN]".
static int getWidth()
          Get the width of the visible portion of the window, not including browser chrome or the scrollbar area.
static Boolean isLoaded()
          Has the page finished loading?
static Boolean isRTL()
          Return whether the page text direction is right to left.
static void loadStyleSheet(String styleSheetURL)
          Load a styleSheet for this application.
static void moveTo(int left, int top)
          Move the window to a specified top and left in screen coordinates.
static void registerKey(KeyIdentifier keyIdentifier, KeyCallback callback)
          Fire some action when the Page recieves a keyPress event from a certain key.
static void registerKey(String keyName, KeyCallback callback)
          Fire some action when the Page recieves a keyPress event from a certain key.
static void resizeTo(int width, int height)
          Resize the outer portion of the window to a specific width and height.
static void scrollTo(int left, int top)
          Scroll the window to a specified top and left coordinate.
static void setAppFilesDir()
          Specify the directory for miscellaneous app-specific files other than images, such as 'HTML fragments', ViewLoader, XML or JSON flat data files, videos, etc.
static void setAppFilesDir(String URL)
          Specify the directory for miscellaneous app-specific files other than images, such as 'HTML fragments', ViewLoader, XML or JSON flat data files, videos, etc.
static void setAppImgDir()
          Specify the directory for app-specific images.
static void setAppImgDir(String URL)
          Specify the directory for app-specific images.
static void setIsomorphicDir()
          Specify the root directory for Isomorphic-supplied files.
static void setIsomorphicDir(String URL)
          Specify the root directory for Isomorphic-supplied files.
static void setSkinDir()
          Specify the URL for media that's part of the skin
static void setSkinDir(String URL)
          Specify the URL for media that's part of the skin
static void setTitle(String title)
          Set the title of the page, which is typically shown as part of the browser window title
static void unregisterKey(String keyName)
          Clears an action registered to fire on a specific a keyPress event via the registerKey(String, KeyCallback) method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Page

public Page()
Method Detail

isLoaded

public static Boolean isLoaded()
Has the page finished loading?

Returns:
true == page is done loading

getAppDir

public static String getAppDir()
Returns the base URL of the application, which is the page URL minus the last non-directory path component. For example, if the page is loaded from http://foo.com/bar/zoo.jsp, appDir will be http://foo.com/bar/.

If other page-wide URLs such as setIsomorphicDir() are specified as relative paths, they are considered relative to this URL.

Returns:
URL for page-specific files.

setAppImgDir

public static void setAppImgDir()
Specify the directory for app-specific images.

This becomes the default location where any Smart GWT component will load images from unless the special "[SKIN]" prefix is used to indicate that an image is part of a skin.

Default is "[APP]images/"


setAppImgDir

public static void setAppImgDir(String URL)
Specify the directory for app-specific images.

This becomes the default location where any Smart GWT component will load images from unless the special "[SKIN]" prefix is used to indicate that an image is part of a skin.

Default is "[APP]images/"

Parameters:
URL - New imgDir URL.

getAppImgDir

public static String getAppImgDir()
Return the directory for app-specific images.

Returns:
URL for page-specific images.

setAppFilesDir

public static void setAppFilesDir()
Specify the directory for miscellaneous app-specific files other than images, such as 'HTML fragments', ViewLoader, XML or JSON flat data files, videos, etc.

This URL also becomes available via the prefix "[APPFILES]" for actionURL.

Defaults to the value of getAppDir(), that is, the current directory.


setAppFilesDir

public static void setAppFilesDir(String URL)
Specify the directory for miscellaneous app-specific files other than images, such as 'HTML fragments', ViewLoader, XML or JSON flat data files, videos, etc.

This URL also becomes available via the prefix "[APPFILES]" for actionURL.

Defaults to the value of getAppDir(), that is, the current directory.

Parameters:
URL - New app files URL.

getAppFilesDir

public static void getAppFilesDir()
Returns the directory for application-specific files (other than images).


getAppFilesDir

public static void getAppFilesDir(String URL)
Returns the directory for application-specific files (other than images).

Parameters:
URL - New app files URL.

setIsomorphicDir

public static void setIsomorphicDir()
Specify the root directory for Isomorphic-supplied files.


setIsomorphicDir

public static void setIsomorphicDir(String URL)
Specify the root directory for Isomorphic-supplied files.

Parameters:
URL - New IsomorphicDir URL.

getIsomorphicDir

public static String getIsomorphicDir()
Return the root directory for Isomorphic-specific files.

Returns:
IsomorphicDir URL.

setSkinDir

public static void setSkinDir()
Specify the URL for media that's part of the skin


setSkinDir

public static void setSkinDir(String URL)
Specify the URL for media that's part of the skin

Parameters:
URL - New skinDir URL

getSkinDir

public static String getSkinDir()
Return the directory for media that's part of the skin

Returns:
base URL for skin media

getSkinImgDir

public static String getSkinImgDir()
Return the directory for a skin image.

Returns:
URL for page-specific images.

getSkinImgDir

public static String getSkinImgDir(String imgDir)
Return the directory for a skin image.

Parameters:
imgDir - Partial URL (relative to Page._skinDir) where the image lives. If not supplied, will use "images/"
Returns:
URL for page-specific images.

getImgURL

public static String getImgURL(String src)
Return the full URL for app-specific or skin image.

To use a skin image, start the URL with "[SKIN]". Any other relative URL is assumed relative to the getAppImgDir().

Parameters:
src - Local file name for the image.
Returns:
URL for the image.

getImgURL

public static String getImgURL(String src,
                               String imgDir)
Return the full URL for app-specific or skin image.

To use a skin image, start the URL with "[SKIN]". Any other relative URL is assumed relative to the getAppImgDir().

Parameters:
src - Local file name for the image.
imgDir - User-specified image directory, local to
Returns:
URL for the image.

getURL

public static String getURL(String fileName)
Return a full URL for a relative path that uses a special prefix such as "[APPFILES]" or "[SKIN]".

For images, use getImgURL(java.lang.String) instead.

Parameters:
fileName - Local file name for the image.
Returns:
URL for the image.

isRTL

public static Boolean isRTL()
Return whether the page text direction is right to left. If you set "DIR=RTL" in the BODY tag of the page, then this method will return true. If you set "DIR=LTR" then this method will return false.

Returns:
true if Page text direction is RTL, false otherwise

loadStyleSheet

public static void loadStyleSheet(String styleSheetURL)
Load a styleSheet for this application. The styleSheetURL parameter can use any special directories, eg:
  Page.loadStylesheet("[SKIN]/skin_styles.css")
or
  Page.loadStylesheet("[APP]/app_styles.css").

If you don't specify a special directory, the app directory will be assumed.

Note: If the document's ONLOAD handler has already fired, this will have no effect.

Parameters:
styleSheetURL - URL to the stylesheet.

resizeTo

public static void resizeTo(int width,
                            int height)
Resize the outer portion of the window to a specific width and height.

Parameters:
width - new width for the window
height - new height for the window

moveTo

public static void moveTo(int left,
                          int top)
Move the window to a specified top and left in screen coordinates.

Parameters:
left - new left coordinate for window
top - new top coordinate for window

scrollTo

public static void scrollTo(int left,
                            int top)
Scroll the window to a specified top and left coordinate.

Parameters:
left - new left coordinate for window
top - new top coordinate for window

getScrollWidth

public static int getScrollWidth()
Get the width of the window contents as they have been drawn. If the page scrolls, this may be larger than the page.getWidth().

Returns:
width of the page as drawn

getScrollHeight

public static int getScrollHeight()
Get the height of the window contents as they have been drawn. If the page scrolls, this may be larger than the page.getHeight().

Returns:
height of the page as drawn

getScrollLeft

public static int getScrollLeft()
Get the amount that the browser window has been scrolled horizontally.

Returns:
horizontal scroll amount

getScrollTop

public static int getScrollTop()
Get the amount that the browser window has been scrolled vertically.

Returns:
vertical scroll amount

checkBrowserAndRedirect

public static void checkBrowserAndRedirect()
Check whether the browser is supported by the Isomorphic Smart GWT system. Behavior depends upon the value of com.smartgwt.client.util.Page#unsupportedBrowserAction: If redirecting to another page is necessary, and no explicit URL is provided we will use com.smartgwt.client.util.Page#defaultUnsupportedBrowserURL.

This method is commonly called as part of the 'skinning' logic after page load.


checkBrowserAndRedirect

public static void checkBrowserAndRedirect(String URL)
Check whether the browser is supported by the Isomorphic Smart GWT system. Behavior depends upon the value of com.smartgwt.client.util.Page#unsupportedBrowserAction: If redirecting to another page is necessary, and no explicit URL is provided we will use com.smartgwt.client.util.Page#defaultUnsupportedBrowserURL.

This method is commonly called as part of the 'skinning' logic after page load.

Parameters:
URL - URL of redirect page. May include Isomorphic special directories such as [SKIN].

getUnsupportedBrowserPromptString

public static String getUnsupportedBrowserPromptString()
Returns the text for the prompt shown to user from checkBrowserAndRedirect() if they are accessing this page in an unsupported browser and com.smartgwt.client.util.Page#unsupportedBrowserAction is set to "confirm". May be overridden to return a different message.

Returns:
Unsupported browser message.

registerKey

public static void registerKey(String keyName,
                               KeyCallback callback)
Fire some action when the Page recieves a keyPress event from a certain key. Note that if a widget has keyboard focus, this action will fire only after any widget-level keyPress handlers have fired and bubbled the event up to the top of their ancestor chain. Multiple actions can be registered to fire on a single keyPress using this method. This differs from calling Page.setEvent() with the "keyPress" events registered via setEvent() will fire before widget level handlers respond to the event, and will fire for every keyPress event, not just those triggerred by some specific key or key-combination.

Parameters:
keyName - the key name
callback - the callback function

registerKey

public static void registerKey(KeyIdentifier keyIdentifier,
                               KeyCallback callback)
Fire some action when the Page recieves a keyPress event from a certain key. Note that if a widget has keyboard focus, this action will fire only after any widget-level keyPress handlers have fired and bubbled the event up to the top of their ancestor chain. Multiple actions can be registered to fire on a single keyPress using this method. This differs from calling Page.setEvent() with the "keyPress" events registered via setEvent() will fire before widget level handlers respond to the event, and will fire for every keyPress event, not just those triggerred by some specific key or key-combination.

Parameters:
keyIdentifier - the key identifier
callback - the callback function

unregisterKey

public static void unregisterKey(String keyName)
Clears an action registered to fire on a specific a keyPress event via the registerKey(String, KeyCallback) method.

Parameters:
keyName - name of key to clear registry enties for

setTitle

public static void setTitle(String title)
Set the title of the page, which is typically shown as part of the browser window title

Parameters:
title - the page title

getWidth

public static int getWidth()
Get the width of the visible portion of the window, not including browser chrome or the scrollbar area.

Returns:
the width of the page

getHeight

public static int getHeight()
Get the height of the visible portion of the window, not including browser chrome or the scrollbar area.

Returns:
the height of the page

getScreenWidth

public static int getScreenWidth()
Get the width of the user's screen, in pixels.

Returns:
the screen width

getScreenHeight

public static int getScreenHeight()
Get the height of the user's screen, in pixels.

Returns:
the screen height