org.openfaces.util
Class Resources

java.lang.Object
  extended by org.openfaces.util.Resources

public class Resources
extends java.lang.Object


Field Summary
static java.lang.String AJAX_UTIL_JS_PATH
           
static java.lang.String HEADER_JS_LIBRARIES
           
static java.lang.String JSON_JS_PATH
           
static java.lang.String LIBRARY_NAME
           
static java.lang.String POSTPONE_JS_LINK_RENDERING
           
static java.lang.String RENDERED_JS_LINKS
           
static java.lang.String UTIL_JS_PATH
           
 
Method Summary
static void addHeaderInitScript(javax.faces.context.FacesContext context, Script script)
           
static void addHeaderResource(javax.faces.context.FacesContext context, java.lang.String resourceName, java.lang.String library)
           
static java.lang.String getAjaxUtilJsURL(javax.faces.context.FacesContext context)
          Return URL of ajaxUtil.js file.
static java.lang.String getApplicationURL(javax.faces.context.FacesContext context, java.lang.String resourcePath)
          Get path to application resource according to context and resource path
static java.lang.String getFiltersJsURL(javax.faces.context.FacesContext context)
           
static java.lang.String getInternalURL(javax.faces.context.FacesContext context, java.lang.String resourcePath)
           
static java.lang.String getJsonJsURL(javax.faces.context.FacesContext context)
          Return URL of json javascript file
static JSONObject getNumberFormatSettings(java.util.Locale locale)
           
static java.lang.String getPackageName(java.lang.Class aClass)
          Return full package name for Class
static java.util.List<java.lang.String> getRegisteredJsLibraries()
           
static java.util.List<java.lang.String> getRegisteredJsLibraries(java.util.Map<java.lang.String,java.lang.Object> requestMap)
           
static java.util.List<java.lang.String> getRenderedJsLinks(javax.faces.context.FacesContext context)
          Return list of already rendered javascript links
static java.lang.String getURL(javax.faces.context.FacesContext context, java.lang.String userSpecifiedUrl, java.lang.String defaultResourceFileName)
          This method returns the URL string ready for rendering into HTML based on the URL specified by the user.
static java.lang.String getURL(javax.faces.context.FacesContext context, java.lang.String userSpecifiedUrl, java.lang.String defaultResourceFileName, boolean prependContextPath)
           
static java.lang.String getUtilJsURL(javax.faces.context.FacesContext context)
          Return URL of util.js file
static java.lang.String getVersionString()
          Return version of OpenFaces
static void includeJQuery()
           
static void includeJQuery(javax.faces.context.FacesContext context)
           
static void registerJavascriptLibrary(javax.faces.context.FacesContext context, java.lang.String jsFileUrl)
          Register javascript library to future adding to response
static void renderJSLinkIfNeeded(javax.faces.context.FacesContext context, java.lang.String jsFile)
          Render javascript file link, if not rendered early
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HEADER_JS_LIBRARIES

public static final java.lang.String HEADER_JS_LIBRARIES
See Also:
Constant Field Values

RENDERED_JS_LINKS

public static final java.lang.String RENDERED_JS_LINKS
See Also:
Constant Field Values

POSTPONE_JS_LINK_RENDERING

public static final java.lang.String POSTPONE_JS_LINK_RENDERING
See Also:
Constant Field Values

LIBRARY_NAME

public static final java.lang.String LIBRARY_NAME
See Also:
Constant Field Values

UTIL_JS_PATH

public static final java.lang.String UTIL_JS_PATH
See Also:
Constant Field Values

JSON_JS_PATH

public static final java.lang.String JSON_JS_PATH
See Also:
Constant Field Values

AJAX_UTIL_JS_PATH

public static final java.lang.String AJAX_UTIL_JS_PATH
See Also:
Constant Field Values
Method Detail

getURL

public static java.lang.String getURL(javax.faces.context.FacesContext context,
                                      java.lang.String userSpecifiedUrl,
                                      java.lang.String defaultResourceFileName)
This method returns the URL string ready for rendering into HTML based on the URL specified by the user. If URL is not specified by the user explicitly then URL to a default internal resource is returned instead.

Parameters:
userSpecifiedUrl - optional resource url as specified by the user. This can be a relative URL, or an absolute URL
defaultResourceFileName - file name for a resource which should be provided if userSpecifiedUrl is null or empty string
Returns:

getURL

public static java.lang.String getURL(javax.faces.context.FacesContext context,
                                      java.lang.String userSpecifiedUrl,
                                      java.lang.String defaultResourceFileName,
                                      boolean prependContextPath)
Parameters:
userSpecifiedUrl - optional resource url as specified by the user. This can be a relative URL, or an absolute URL
defaultResourceFileName - file name for a resource which should be provided if userSpecifiedUrl is null (or empty string). Empty string is also considered as signal for returning the default resource here because null is auto-converted to an empty string when passed through a string binding
prependContextPath - use true here if you render the attribute yourself, and false if you use pass this URL to HtmlGraphicImage or similar component

getApplicationURL

public static java.lang.String getApplicationURL(javax.faces.context.FacesContext context,
                                                 java.lang.String resourcePath)
Get path to application resource according to context and resource path

Parameters:
context - faces context provided by application
resourcePath - path to resource - either absolute (starting with a slash) in the scope of application context, or relative to the current page
Returns:
full URL to resource ready for rendering as src or href attribute's value.

getInternalURL

public static java.lang.String getInternalURL(javax.faces.context.FacesContext context,
                                              java.lang.String resourcePath)
Parameters:
context - Current FacesContext
resourcePath - Path to the resource file
Returns:
The requested URL

getVersionString

public static java.lang.String getVersionString()
Return version of OpenFaces

Returns:
requested version of OpenFaces

getNumberFormatSettings

public static JSONObject getNumberFormatSettings(java.util.Locale locale)
                                          throws java.io.IOException,
                                                 JSONException
Throws:
java.io.IOException
JSONException

getUtilJsURL

public static java.lang.String getUtilJsURL(javax.faces.context.FacesContext context)
Return URL of util.js file

Parameters:
context - FacesContext for the current request
Returns:
requested URL of util.js file

getFiltersJsURL

public static java.lang.String getFiltersJsURL(javax.faces.context.FacesContext context)

getAjaxUtilJsURL

public static java.lang.String getAjaxUtilJsURL(javax.faces.context.FacesContext context)
Return URL of ajaxUtil.js file. Keep in mind that ajaxUtil.js depends on util.js. Don't forget to include util.js as well before including this URL.

Parameters:
context - FacesContext for the current request
Returns:
requested URL of ajaxUtil.js file

getJsonJsURL

public static java.lang.String getJsonJsURL(javax.faces.context.FacesContext context)
Return URL of json javascript file

Parameters:
context - FacesContext for the current request
Returns:
requested URL of json javascript file

getPackageName

public static java.lang.String getPackageName(java.lang.Class aClass)
Return full package name for Class

Parameters:
aClass - The Class object
Returns:
full package name for given Class

registerJavascriptLibrary

public static void registerJavascriptLibrary(javax.faces.context.FacesContext context,
                                             java.lang.String jsFileUrl)
Register javascript library to future adding to response

Parameters:
context - FacesContext for the current request
jsFileUrl - Url for the javascript file

getRegisteredJsLibraries

public static java.util.List<java.lang.String> getRegisteredJsLibraries()

getRegisteredJsLibraries

public static java.util.List<java.lang.String> getRegisteredJsLibraries(java.util.Map<java.lang.String,java.lang.Object> requestMap)

renderJSLinkIfNeeded

public static void renderJSLinkIfNeeded(javax.faces.context.FacesContext context,
                                        java.lang.String jsFile)
                                 throws java.io.IOException
Render javascript file link, if not rendered early

Parameters:
context - FacesContext for the current request
jsFile - Javascript file to include
Throws:
java.io.IOException - if an input/output error occurs

getRenderedJsLinks

public static java.util.List<java.lang.String> getRenderedJsLinks(javax.faces.context.FacesContext context)
Return list of already rendered javascript links

Parameters:
context - FacesContext for the current request
Returns:
list of already rendered javascript links

includeJQuery

public static void includeJQuery()

includeJQuery

public static void includeJQuery(javax.faces.context.FacesContext context)
                          throws java.io.IOException
Throws:
java.io.IOException

addHeaderResource

public static void addHeaderResource(javax.faces.context.FacesContext context,
                                     java.lang.String resourceName,
                                     java.lang.String library)

addHeaderInitScript

public static void addHeaderInitScript(javax.faces.context.FacesContext context,
                                       Script script)


Copyright © 1998-2010 TeamDev Ltd. All Rights Reserved.