com.itmill.toolkit.terminal.web
Class ThemeFunctionLibrary

java.lang.Object
  extended by com.itmill.toolkit.terminal.web.ThemeFunctionLibrary

public class ThemeFunctionLibrary
extends Object

This a function library that can be used from the theme XSL-files. It provides easy access to current application, window, theme, webbrowser and session. The internal threadlocal state must be maintained by the webadapter in order to guarantee that it works.

Since:
3.0
Version:
4.1.4
Author:
IT Mill Ltd.

Constructor Summary
ThemeFunctionLibrary()
           
 
Method Summary
static Application application()
          Returns a reference to the application object associated with the session that the call came from.
static WebBrowser browser()
          Returns a reference to the browser object associated with the session that the call came from.
protected static void cleanState()
           
protected static String generateWindowScript(Window window, Application app, ApplicationServlet wa, WebBrowser browser)
           
static String getCssLinksForHead()
          Generates the links for CSS files to be included in html head.
static int getFirstDayOfWeek()
          Gets the name of first day of the week.
static String getFormAction()
          Gets Form Action URL for the requested window.
static String getJavaScriptLinksForHead()
          Generates the links for JavaScript files to be included in html head.
static String getLocaleCountryId()
          Returns the country and region code for current application locale.
static String getLocaleLanguageId()
          Returns the language code for current application locale.
static String getMonth(int month)
          Gets the name for month.
static String getSecurityKey()
           
static String getShortMonth(int month)
          Gets the short name for month.
static String getShortWeekday(int dayOfWeek)
          Gets the name for week day.
protected static String getWindowRefreshScript(Application application, Window window, WebBrowser browser)
          Generates the JavaScript for updating given window.
static String getWindowTargetName()
          Returns an unique target name for current window.
static String getWindowTargetName(Application application, Window window)
          Returns an unique target name for a given window name.
static String getWindowTargetName(String name)
          Returns an unique target name for current window.
static boolean probeClient()
          Generates the JavaScript for page that performs client-side combility checks.
static String resource(String resource)
          Returns an URI to the named resource.
static String resource(String resource, String theme)
          Returns an URI to the named resource from the named theme.
static HttpSession session()
          Returns a reference to the current servlet http session object that is associated with the session that the call came from.
protected static void setState(Application application, Window window, WebBrowser webBrowser, HttpSession session, ApplicationServlet webAdapterServlet, String theme)
           
static String theme()
          Returns a reference to the current theme name that is associated with the session that the call came from.
static Window window()
          Returns a reference to the current window object associated with the session that the call came from.
static String windowScript()
          Generates the JavaScript for page header that handles window refreshing, opening and closing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThemeFunctionLibrary

public ThemeFunctionLibrary()
Method Detail

setState

protected static void setState(Application application,
                               Window window,
                               WebBrowser webBrowser,
                               HttpSession session,
                               ApplicationServlet webAdapterServlet,
                               String theme)
Parameters:
application -
window -
webBrowser -
session -
webAdapterServlet -
theme -

cleanState

protected static void cleanState()

application

public static Application application()
Returns a reference to the application object associated with the session that the call came from.


window

public static Window window()
Returns a reference to the current window object associated with the session that the call came from.


browser

public static WebBrowser browser()
Returns a reference to the browser object associated with the session that the call came from.


session

public static HttpSession session()
Returns a reference to the current servlet http session object that is associated with the session that the call came from.


theme

public static String theme()
Returns a reference to the current theme name that is associated with the session that the call came from.


resource

public static String resource(String resource,
                              String theme)
Returns an URI to the named resource from the named theme.

Parameters:
resource -
theme -

resource

public static String resource(String resource)
Returns an URI to the named resource.

Parameters:
resource -

probeClient

public static boolean probeClient()
Generates the JavaScript for page that performs client-side combility checks.


windowScript

public static String windowScript()
Generates the JavaScript for page header that handles window refreshing, opening and closing. Generates script that:

generateWindowScript

protected static String generateWindowScript(Window window,
                                             Application app,
                                             ApplicationServlet wa,
                                             WebBrowser browser)
Parameters:
window -
app -
wa -
browser -
Returns:

getWindowTargetName

public static String getWindowTargetName(Application application,
                                         Window window)
Returns an unique target name for a given window name.

Parameters:
application -
window - the Name of the window.
Returns:
An unique ID for window target.

getWindowTargetName

public static String getWindowTargetName()
Returns an unique target name for current window.

Returns:
An unique ID for window target.

getWindowTargetName

public static String getWindowTargetName(String name)
Returns an unique target name for current window.

Parameters:
name - the name of the window.
Returns:
An unique ID for window target.

getLocaleCountryId

public static String getLocaleCountryId()
Returns the country and region code for current application locale.

Returns:
the language Country code of the current application locale.
See Also:
Locale#getCountry()

getLocaleLanguageId

public static String getLocaleLanguageId()
Returns the language code for current application locale.

Returns:
the Language code for current application locale.
See Also:
Locale#getLanguage()

getFirstDayOfWeek

public static int getFirstDayOfWeek()
Gets the name of first day of the week.

Returns:

getShortWeekday

public static String getShortWeekday(int dayOfWeek)
Gets the name for week day.

Parameters:
dayOfWeek - the Number of week day. 0 sunday, 1 monday, ...
Returns:
the Name of week day in applications current locale.

getShortMonth

public static String getShortMonth(int month)
Gets the short name for month.

Parameters:
month - the Number of month. 0 is January, 1 is February, and so on.
Returns:
the Name of month in applications current locale.

getMonth

public static String getMonth(int month)
Gets the name for month.

Parameters:
month - the Number of month. 0 is January, 1 is February, and so on.
Returns:
the Name of month in applications current locale.

getFormAction

public static String getFormAction()
Gets Form Action URL for the requested window.

This returns the action for the window main form. This action can be set through WebApplicationContect setWindowFormAction method..

Returns:
the Form action for the current window.

getSecurityKey

public static String getSecurityKey()

getCssLinksForHead

public static String getCssLinksForHead()
Generates the links for CSS files to be included in html head.

Returns:

getJavaScriptLinksForHead

public static String getJavaScriptLinksForHead()
Generates the links for JavaScript files to be included in html head.

Returns:

getWindowRefreshScript

protected static String getWindowRefreshScript(Application application,
                                               Window window,
                                               WebBrowser browser)
Generates the JavaScript for updating given window.

Parameters:
application -
window -
browser -
Returns:


Copyright © 2000-2008 IT Mill Ltd. All Rights Reserved.