org.apache.myfaces.component.html.util
Class AddResource
public final
class
AddResource
extends Object
This is a utility class to render link to resources used by custom components.
Mostly used to avoid having to include
in the head of the pages before using a component.
Version: $Revision: 265021 $ $Date: 2005-08-31 13:40:37 +0200 (Wed, 31 Aug 2005) $
Author: Sylvain Vieujot (latest modification by $Author: svieujot $)
Method Summary |
static void | addInlineStyleToHeader(String inlineStyle, FacesContext context)
Adds the given Style Sheet to the document Header.
|
static void | addJavaScriptHere(Class componentClass, String resourceFileName, FacesContext context, UIComponent component)
Adds the given Javascript resource to the document body. |
static void | addJavaScriptHere(Class componentClass, String resourceFileName, FacesContext context)
Adds the given Javascript resource to the document body, without passing UIComponent. |
static void | addJavaScriptToHeader(Class componentClass, String resourceFileName, FacesContext context)
Adds the given Javascript resource to the document Header.
|
static void | addJavaScriptToHeader(Class componentClass, String resourceFileName, boolean defer, FacesContext context)
Adds the given Javascript resource to the document Header.
|
static void | addStyleSheet(Class componentClass, String resourceFileName, FacesContext context)
Adds the given Style Sheet to the document Header.
|
protected static String | getComponentName(Class componentClass) |
static String | getResourceMappedPath(Class componentClass, String resourceFileName, FacesContext context)
Get the Path used to retrieve an internal resource for a custom component.
|
protected static String | getResourceMappedPath(String componentName, String resourceFileName, String contextPath) |
static boolean | hasAdditionalHeaderInfoToRender(HttpServletRequest request) |
static boolean | isResourceMappedPath(HttpServletRequest request) |
static void | serveResource(HttpServletRequest request, HttpServletResponse response) |
static void | writeWithFullHeader(HttpServletRequest request, ExtensionsResponseWrapper responseWrapper, HttpServletResponse response)
Add the resources to the <head> of the page.
|
protected static final Log log
public static void addInlineStyleToHeader(String inlineStyle, FacesContext context)
Adds the given Style Sheet to the document Header.
If the style sheet is already has already been referenced, it's added only once.
public static void addJavaScriptHere(Class componentClass, String resourceFileName, FacesContext context, UIComponent component)
Adds the given Javascript resource to the document body.
public static void addJavaScriptHere(Class componentClass, String resourceFileName, FacesContext context)
Adds the given Javascript resource to the document body, without passing UIComponent.
public static void addJavaScriptToHeader(Class componentClass, String resourceFileName, FacesContext context)
Adds the given Javascript resource to the document Header.
If the script is already has already been referenced, it's added only once.
public static void addJavaScriptToHeader(Class componentClass, String resourceFileName, boolean defer, FacesContext context)
Adds the given Javascript resource to the document Header.
If the script is already has already been referenced, it's added only once.
public static void addStyleSheet(Class componentClass, String resourceFileName, FacesContext context)
Adds the given Style Sheet to the document Header.
If the style sheet is already has already been referenced, it's added only once.
protected static String getComponentName(Class componentClass)
public static String getResourceMappedPath(Class componentClass, String resourceFileName, FacesContext context)
Get the Path used to retrieve an internal resource for a custom component.
Example : You can use this to initialize javascript scripts so that they know the path of some other resources
(image, css, ...).
AddResource.addJavaScriptOncePerPage(HtmlCalendarRenderer.class, "popcalendar.js", facesContext,
"jscalendarSetImageDirectory("+AddResource.getResourceMappedPath(HtmlCalendarRenderer.class, "DB", facesContext)+")");
Note : set context to null if you want the path after the application context path.
protected static String getResourceMappedPath(String componentName, String resourceFileName, String contextPath)
public static boolean hasAdditionalHeaderInfoToRender(HttpServletRequest request)
public static boolean isResourceMappedPath(HttpServletRequest request)
public static void serveResource(HttpServletRequest request, HttpServletResponse response)
public static void writeWithFullHeader(HttpServletRequest request,
ExtensionsResponseWrapper responseWrapper, HttpServletResponse response)
Add the resources to the <head> of the page.
If the head tag is missing, but the <body> tag is present, the head tag is added.
If both are missing, no resources is added.
TODO : Change the ordering so that the user header CSS & JS override MyFaces' ones.