Class PageImports
- java.lang.Object
-
- org.openidentityplatform.openam.click.util.PageImports
-
public class PageImports extends Object
Provides a utility object for rendering a Page's HEAD elements and control HEAD elements.PageImports automatically makes the HEAD elements available to Velocity templates and JSP pages through the following variables:
- $headElements - this variable includes all HEAD elements except JavaScript elements
- $jsElements - this variable includes only JavaScript elements
To use the HEAD elements simply reference them in your page template. For example:
<html> <head> $headElements </head> <body> $form $jsElements <body> </html>
Its not always possible to move the JavaScript elements to the bottom of the Page, for example there might be JavaScript scoping issues. In those situations you can simply place the JavaScript elements variable in the Page HEAD section:<html> <head> $headElements $jsElements </head> <body> $form <body> </html>
Please note: the variables $headElements and $jsElements are new in Click 2.1.0. For backwards compatibility the HEAD elements are also available through the following variables:- $imports - this variable includes all HEAD elements including JavaScript and Css elements
- $cssImports - this variable includes only Css elements
- $jsImports - this variable includes only Javascript elements
Page.getHeadElements(),Control.getHeadElements().
-
-
Field Summary
Fields Modifier and Type Field Description protected List<CssImport>cssImportsThe list of CSS import lines.protected List<CssStyle>cssStylesThe list of CSS styles.protected List<Element>headElementsThe list of head elements.protected booleaninitializedThe page imports initialized flag.protected List<JsImport>jsImportsThe list of JS import lines.protected List<JsScript>jsScriptsThe list of JS script block lines.protected org.openidentityplatform.openam.click.PagepageThe page instance.
-
Constructor Summary
Constructors Constructor Description PageImports(org.openidentityplatform.openam.click.Page page)Create a page control HTML includes object.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadd(Element element)Add the given Element to the Page HEAD elements.voidaddAll(List<Element> elements)Add the given list of Elements to the Page HEAD elements.List<Element>getHeadElements()Return the list of processed HEAD elements, excluding any JavaScript elements.List<Element>getJsElements()Return the list of processed JavaScript elements.booleanisInitialized()Return true if the page imports have been initialized.voidpopulateRequest(jakarta.servlet.http.HttpServletRequest request, Map<String,Object> model)Populate the specified request with html import keys.voidpopulateTemplateModel(Map<String,Object> model)Populate the specified model with html import keys.voidprocessControl(org.openidentityplatform.openam.click.Control control)Process the given control HEAD elements.voidprocessControls(List<org.openidentityplatform.openam.click.Control> controls)Process the HEAD elements of the given list of Controls.protected voidprocessHeadElements(List<Element> elements)Process the given list of HEAD elements.protected voidprocessPageControls()Process the Page's set of control HEAD elements.protected voidrenderAllIncludes(HtmlStringBuffer buffer)Deprecated.protected voidrenderCssElements(HtmlStringBuffer buffer)protected voidrenderHeadElements(HtmlStringBuffer buffer)Render an HTML representation of all the page's HTML head elements, including: CSS imports, CSS styles, Title and Meta elements.protected voidrenderJsElements(HtmlStringBuffer buffer)voidsetInitialized(boolean initialized)Set whether the page imports have been initialized.
-
-
-
Method Detail
-
add
public void add(Element element)
Add the given Element to the Page HEAD elements.- Parameters:
element- the Element to add- Throws:
IllegalArgumentException- if the Element is null
-
addAll
public void addAll(List<Element> elements)
Add the given list of Elements to the Page HEAD elements.- Parameters:
elements- the list of Elements to add to the Page HEAD elements- Throws:
IllegalArgumentException- is the list of Elements are null
-
isInitialized
public boolean isInitialized()
Return true if the page imports have been initialized.- Returns:
- true if the page imports have been initialized
-
setInitialized
public void setInitialized(boolean initialized)
Set whether the page imports have been initialized.- Parameters:
initialized- the page imports have been initialized flag
-
populateTemplateModel
public void populateTemplateModel(Map<String,Object> model)
Populate the specified model with html import keys.- Parameters:
model- the model to populate with html import keys
-
populateRequest
public void populateRequest(jakarta.servlet.http.HttpServletRequest request, Map<String,Object> model)Populate the specified request with html import keys.- Parameters:
request- the http request to populatemodel- the model to populate with html import keys
-
processControls
public void processControls(List<org.openidentityplatform.openam.click.Control> controls)
Process the HEAD elements of the given list of Controls. You can retrieve the processed HEAD elements throughgetHeadElements()andgetJsElements().This method delegates to
processControl(Control)to add the given Control's HEAD elements to the Page imports.- Parameters:
controls- the list of Controls which HEAD elements to process
-
processControl
public void processControl(org.openidentityplatform.openam.click.Control control)
Process the given control HEAD elements. This method will recursively process Containers and all child controls. You can retrieve the processed HEAD elements throughgetHeadElements()andgetJsElements().This method delegates to
processHeadElements(List)to add the HEAD elements to the Page imports.- Parameters:
control- the control to process
-
getHeadElements
public final List<Element> getHeadElements()
Return the list of processed HEAD elements, excluding any JavaScript elements. To retrieve JavaScript elements please seegetJsElements().- Returns:
- the list of processed HEAD elements
-
getJsElements
public final List<Element> getJsElements()
Return the list of processed JavaScript elements.- Returns:
- the list of processed JavaScript elements
-
renderHeadElements
protected void renderHeadElements(HtmlStringBuffer buffer)
Render an HTML representation of all the page's HTML head elements, including: CSS imports, CSS styles, Title and Meta elements.- Parameters:
buffer- the specified buffer to render the page's HTML imports to
-
renderAllIncludes
protected void renderAllIncludes(HtmlStringBuffer buffer)
Deprecated.Render an HTML representation of all the page's HTML imports, including: CSS imports, CSS styles, JS imports and JS scripts.- Parameters:
buffer- the specified buffer to render the page's HTML imports to
-
renderCssElements
protected void renderCssElements(HtmlStringBuffer buffer)
- Parameters:
buffer- the specified buffer to render the page's HTML imports to
-
renderJsElements
protected void renderJsElements(HtmlStringBuffer buffer)
- Parameters:
buffer- the specified buffer to render the page's HTML imports to
-
processPageControls
protected void processPageControls()
Process the Page's set of control HEAD elements.
-
processHeadElements
protected void processHeadElements(List<Element> elements)
Process the given list of HEAD elements.This method invokes
add(Element)for everyElemententry in the specified list.- Parameters:
elements- the list of HEAD elements to process
-
-