com.sun.webui.theme
Interface Theme


public interface Theme

The Theme interface defines a set of methods that return resources that define a theme; for example a set of name value pairs defined in properties files representing strings and data, such as messages, image, CSS style sheet and JavaScript file paths. These resources are collectively known as a "Theme" and are typically bundled together in a Jar file. Themes based on the same set of name value pairs should be swappable allowing an application to switch from one Theme to another.

Themes may consist of resources that are used directly by the Java classes at runtime (for example ResourceBundles and Properties files) and resources that are requested by the application users' browser (for example image files). In order to make Theme resources available over HTTP, you can configure the ThemeServlet in the Web UI web application on the server.

For more information on how to configure a Web UI web application w.r.t. Themes, see the documentation for see ThemeServlet.

A Theme implementation instance is used to obtain the resources defined by a concrete Theme, like the "suntheme". A Theme instance is obtained from a ThemeFactory implementation. A web application can define the the ThemeFactory class that should be used by Web UI components to obtain a Theme instance.

Typically implementations will provide support for Locale variants for all resources that it provides, as appropriate.


Field Summary
static java.lang.String THEME_ATTR
          Deprecated.  
 
Method Summary
 java.lang.String[] getGlobalJSFiles()
          Returns a String array of URIs to the JavaScript files to be included in every application page.
 java.lang.String[] getGlobalStylesheets()
          Returns a String array of URIs to the CSS style sheet files to be included in every application page.
 com.sun.webui.theme.ThemeImage getImage(java.lang.String key)
          Return a ThemeImage instance for an image identified by key.
 java.lang.String getImagePath(java.lang.String key)
          Return a String URI that can be used to access the physical image resource.
 java.lang.String getImageString(java.lang.String key)
          Returns the literal String value of the key image theme property.
 java.lang.String getJSString(java.lang.String key)
          Returns the literal String value of the key JavaScript theme property.
 java.lang.String[] getMasterStylesheets()
          Returns a String array of URIs to the CSS style sheet files to be included in every application page.
 java.lang.String getMessage(java.lang.String key)
          Returns a literal message value defined by key.
 java.lang.String getMessage(java.lang.String key, java.lang.Object[] params)
          Return a message that has been formatted using MessageFormat to substitute params for placeholders in the literal value of key.
 boolean getMessageBoolean(java.lang.String key, boolean defaultValue)
          Return a boolean value for key.
 int getMessageInt(java.lang.String key, int defaultValue)
          Return an int value for key.
 java.lang.String getPathToJSFile(java.lang.String key)
          Returns a String URI to a JavaScript file defined by key.
 java.lang.String getPathToTemplate(java.lang.String key)
          Returns a String URI that represents a path to the HTML template defined by key.
 java.lang.String getStyleClass(java.lang.String key)
          Returns a CSS selector defined by key, unless key does not exist, in which case key is returned.
 java.lang.String[] getStylesheets(java.lang.String key)
          Returns a String array of URIs to the CSS style sheet files to be included in every application page, defined by key.
 

Field Detail

THEME_ATTR

static final java.lang.String THEME_ATTR
Deprecated. 
Attribute name used to store the user's theme name in the Session

See Also:
Constant Field Values
Method Detail

getGlobalJSFiles

java.lang.String[] getGlobalJSFiles()
Returns a String array of URIs to the JavaScript files to be included in every application page.

Note that an implementation may return a value that is not the literal value defined in a theme resource bundle. For example an implementation may return the literal value prepended with a web application context.

Returns:
String array of URIs to JavaScript files or null.

getPathToJSFile

java.lang.String getPathToJSFile(java.lang.String key)
Returns a String URI to a JavaScript file defined by key.

Note that an implementation may return a value that is not the literal value defined in a theme resource bundle. For example an implementation may return the literal value prepended with a web application context.

Parameters:
key - Defines a JavaScript file path.
Returns:
a String URI to a JavaScript file or null.

getJSString

java.lang.String getJSString(java.lang.String key)
Returns the literal String value of the key JavaScript theme property.

Parameters:
key - Defines a JavaScript theme property.
Returns:
the value of key or null.

getMasterStylesheets

java.lang.String[] getMasterStylesheets()
Returns a String array of URIs to the CSS style sheet files to be included in every application page.

The implicatation of a Master style sheet is that these style sheets should be loaded first, before any other style sheets.

Note that an implementation may return a value that is not the literal value defined in a theme resource bundle. For example an implementation may return the literal value prepended with a web application context.

Returns:
String array of URIs to master style sheets

getGlobalStylesheets

java.lang.String[] getGlobalStylesheets()
Returns a String array of URIs to the CSS style sheet files to be included in every application page.

Note that an implementation may return a value that is not the literal value defined in a theme resource bundle. For example an implementation may return the literal value prepended with a web application context.

Returns:
String array of URIs to the style sheets

getStylesheets

java.lang.String[] getStylesheets(java.lang.String key)
Returns a String array of URIs to the CSS style sheet files to be included in every application page, defined by key.

Note that these style sheets should be loaded after the Master and Global style sheets.

Note that an implementation may return a value that is not the literal value defined in a theme resource bundle. For example an implementation may return the literal value prepended with a web application context.

Parameters:
key - Defines a style sheet file path.
Returns:
String array of URIs to the style sheets or null.

getPathToTemplate

java.lang.String getPathToTemplate(java.lang.String key)
Returns a String URI that represents a path to the HTML template defined by key. Note that an implementation may return a value that is not the literal value defined in a theme resource bundle. For example an implementation may return the literal value prepended with a web application context.

Parameters:
key - Defines an HTML template file path.
Returns:
A String URI defined by key.

getStyleClass

java.lang.String getStyleClass(java.lang.String key)
Returns a CSS selector defined by key, unless key does not exist, in which case key is returned.

Parameters:
key - Defines a CSS selector.
Returns:
the name of a CSS selector or key.

getMessage

java.lang.String getMessage(java.lang.String key)
Returns a literal message value defined by key.

Parameters:
key - Defines a theme message or string.
Returns:
A message string

getMessage

java.lang.String getMessage(java.lang.String key,
                            java.lang.Object[] params)
Return a message that has been formatted using MessageFormat to substitute params for placeholders in the literal value of key.

Parameters:
key - Defines a theme message or string.
params - Substitution parameters suitable for use by a MessageFormat.format call.
Returns:
A formatted message string

getMessageBoolean

boolean getMessageBoolean(java.lang.String key,
                          boolean defaultValue)
Return a boolean value for key. If key is not defined, return defaultValue. If defaultValue is null and key is not defined RuntimeException is thrown.

Parameters:
key - Defines a boolean value.
defaultValue - The value to return if key is not defined.
Returns:
A boolean value for key

getMessageInt

int getMessageInt(java.lang.String key,
                  int defaultValue)
Return an int value for key. If key is not defined, return defaultValue.

Parameters:
key - Defines an int value.
defaultValue - The value to return if key is not defined.
Returns:
A int value for key

getImagePath

java.lang.String getImagePath(java.lang.String key)
Return a String URI that can be used to access the physical image resource.

For example an implementation used by a web application might prepend a servlet context path suitable for delivery by ThemeServlet

Parameters:
key - Defines an image path
Returns:
a path that can be used to access the physical resource.
Throws:
java.lang.RuntimeException - if key cannot be found.

getImage

com.sun.webui.theme.ThemeImage getImage(java.lang.String key)
Return a ThemeImage instance for an image identified by key.

Parameters:
key - Defines an image resource.
Returns:
an instance of ThemeImage or null if key cannot be found.

getImageString

java.lang.String getImageString(java.lang.String key)
Returns the literal String value of the key image theme property.

Parameters:
key - Defines an image resource.
Returns:
The literal value of key.
Throws:
java.lang.RuntimeException - if key cannot be found.


Copyright © 2008 Sun Microsystems, Inc. All Rights Reserved.