net.sf.click.util
Class PageImports

java.lang.Object
  extended bynet.sf.click.util.PageImports

public class PageImports
extends Object

Provides a utility object for rendering a Page's HTML header imports and its control HTML header imports.

A PageImports instance is automatically added to the Velocity Context for Velocity templates, or as a request attribute for JSP pages using the key name "imports".

PageImports Examples

To use the PageImports object simply reference it your page header section. For example:
 <html>
  <head>
   $imports
  </head>
  <body>
   $form
  <body>
 </html> 
"imports" include all javascript and stylesheet imports.

PageImports also provides a way of including the javascript and stylesheet separately using the key names "cssImports" and "jsImports".

You should follow the performance best practice by importing CSS includes in the head section, then include the JS imports after the html body. For example:

 <html>
  <head>
   $cssImports
  </head>
  <body>
   $form
   <br/>
   $table
  <body>
 </html>
 $jsImports
 
Please also see Page.getHtmlImports() and Control.getHtmlImports().

Author:
Malcolm Edgar
See Also:
Format

Field Summary
protected  List cssImports
          The list of CSS import lines.
protected  boolean initialized
          The page imports initialized flag.
protected  List jsImports
          The list of JS import lines.
protected  List jsScripts
          The list of JS script block lines.
protected  Page page
          The page instance.
 
Constructor Summary
PageImports(Page page)
          Create a page control HTML includes object.
 
Method Summary
 void addImport(String value)
          Process the given control HTML import line.
protected  void addToList(String item, List list)
          Add the given string item to the list if it is not already present.
protected  String getAllIncludes()
          Return a HTML string of all the page's HTML imports, including: CSS imports, JS imports and JS script blocks.
protected  String getCssImports()
          Return a HTML string of all the page's HTML CSS imports.
protected  String getJsImports()
          Return a HTML string of all the page's HTML JS imports and scripts.
 boolean isInitialized()
          Return true if the page imports have been initialized.
 void popuplateRequest(HttpServletRequest request, Map model)
          Populate the specified request with html import keys.
 void popuplateTemplateModel(Map model)
          Populate the specified model with html import keys.
protected  void processPageControls()
          Process the Page's set of control HTML head imports.
 void setInitialized(boolean initialized)
          Set whether the page imports have been initialized.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

initialized

protected boolean initialized
The page imports initialized flag.


cssImports

protected List cssImports
The list of CSS import lines.


jsImports

protected List jsImports
The list of JS import lines.


jsScripts

protected List jsScripts
The list of JS script block lines.


page

protected final Page page
The page instance.

Constructor Detail

PageImports

public PageImports(Page page)
Create a page control HTML includes object.

Parameters:
page - the page to provide HTML includes for
Method Detail

addImport

public void addImport(String value)
Process the given control HTML import line.

Parameters:
value - the HTML import line to process

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

popuplateTemplateModel

public void popuplateTemplateModel(Map model)
Populate the specified model with html import keys.

Parameters:
model - the model to populate with html import keys

popuplateRequest

public void popuplateRequest(HttpServletRequest request,
                             Map model)
Populate the specified request with html import keys.

Parameters:
request - the http request to populate
model - the model to populate with html import keys

getAllIncludes

protected String getAllIncludes()
Return a HTML string of all the page's HTML imports, including: CSS imports, JS imports and JS script blocks.

Returns:
a HTML string of all the page's HTML imports, including: CSS imports, JS imports and JS script blocks.

getCssImports

protected String getCssImports()
Return a HTML string of all the page's HTML CSS imports.

Returns:
a HTML string of all the page's HTML CSS imports.

getJsImports

protected String getJsImports()
Return a HTML string of all the page's HTML JS imports and scripts.

Returns:
a HTML string of all the page's HTML JS imports and scripts.

processPageControls

protected void processPageControls()
Process the Page's set of control HTML head imports.


addToList

protected void addToList(String item,
                         List list)
Add the given string item to the list if it is not already present.

Parameters:
item - the line item to add
list - the list to add the item to