org.apache.tapestry5.internal.services
Class RenderSupportImpl

java.lang.Object
  extended by org.apache.tapestry5.internal.services.RenderSupportImpl
All Implemented Interfaces:
RenderSupport

public class RenderSupportImpl
extends Object
implements RenderSupport


Constructor Summary
RenderSupportImpl(DocumentLinker linker, SymbolSource symbolSource, AssetSource assetSource, IdAllocator idAllocator, String... coreScripts)
           
RenderSupportImpl(DocumentLinker linker, SymbolSource symbolSource, AssetSource assetSource, String... coreScripts)
           
 
Method Summary
 void addClasspathScriptLink(String... classpaths)
          Used to add scripts that are stored on the classpath.
 void addInit(String functionName, JSONArray parameterList)
          Add an initialization call.
 void addInit(String functionName, JSONObject parameter)
          Alternate version of RenderSupport.addInit(String, org.apache.tapestry5.json.JSONArray) where just a single object is passed.
 void addInit(String functionName, String... parameters)
          Alternate version of RenderSupport.addInit(String, org.apache.tapestry5.json.JSONArray) where one or more strings are passed.
 void addScript(String script)
          Adds a script statement to the page's script block.
 void addScript(String format, Object... arguments)
          Adds a script statement to the page's script block.
 void addScriptLink(Asset... scriptAssets)
          Adds one or more new script assets to the page.
 void addScriptLink(String... scriptURLs)
          Adds some number of script links as strings representations of URLs.
 void addStylesheetLink(Asset stylesheet, String media)
          Adds a link to a CSS stylesheet.
 void addStylesheetLink(String stylesheetURL, String media)
          Adds a stylesheet as a URL.
 String allocateClientId(ComponentResources resources)
          As with RenderSupport.allocateClientId(String) but uses the id of the component extracted from the resources.
 String allocateClientId(String id)
          Allocates a unique id based on the component's id.
 void autofocus(FieldFocusPriority priority, String fieldId)
          Invoked to set focus on a rendered field.
 void commit()
          Commit any outstanding changes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RenderSupportImpl

public RenderSupportImpl(DocumentLinker linker,
                         SymbolSource symbolSource,
                         AssetSource assetSource,
                         String... coreScripts)
Parameters:
linker - Used to assemble JavaScript includes and snippets
symbolSource - Used to example symbols (in {@linkplain #addClasspathScriptLink(String...) in classpath scripts)
assetSource - Used to convert classpath scripts to Assets
coreScripts - core scripts (evaluated as classpaths scripts) that are added to any page that includes a script link or script block

RenderSupportImpl

public RenderSupportImpl(DocumentLinker linker,
                         SymbolSource symbolSource,
                         AssetSource assetSource,
                         IdAllocator idAllocator,
                         String... coreScripts)
Parameters:
linker - Used to assemble JavaScript includes and snippets
symbolSource - Used to example symbols (in {@linkplain #addClasspathScriptLink(String...) in classpath scripts)
assetSource - Used to convert classpath scripts to Assets
idAllocator - Used to allocate unique client ids during the render
coreScripts - core scripts (evaluated as classpaths scripts) that are added to any page that includes a script link or script block
Method Detail

allocateClientId

public String allocateClientId(String id)
Description copied from interface: RenderSupport
Allocates a unique id based on the component's id. In some cases, the return value will not precisely match the input value (an underscore and a unique index value may be appended).

Specified by:
allocateClientId in interface RenderSupport
Parameters:
id - the component id from which a unique id will be generated
Returns:
a unique id for this rendering of the page
See Also:
IdAllocator

allocateClientId

public String allocateClientId(ComponentResources resources)
Description copied from interface: RenderSupport
As with RenderSupport.allocateClientId(String) but uses the id of the component extracted from the resources.

Specified by:
allocateClientId in interface RenderSupport
Parameters:
resources - of the component which requires an id
Returns:
a unique id for this rendering of the page

addScriptLink

public void addScriptLink(Asset... scriptAssets)
Description copied from interface: RenderSupport
Adds one or more new script assets to the page. Assets are added uniquely, and appear as <script> elements just inside the <body> element of the rendered page. Duplicate requests to add the same script are quietly ignored.

Specified by:
addScriptLink in interface RenderSupport
Parameters:
scriptAssets - asset to the script to add

addScriptLink

public void addScriptLink(String... scriptURLs)
Description copied from interface: RenderSupport
Adds some number of script links as strings representations of URLs. The scripts are passed down to the client as-is. Note that Tapestry generates relative URLs for assets because the base URL varies dependending on the page and its activation context; scripts added with this method will not be adjusted in anyway. Typically, this is used to reference a script stored outside the web application entirely.

Specified by:
addScriptLink in interface RenderSupport
Parameters:
scriptURLs - URL strings of scripts

addClasspathScriptLink

public void addClasspathScriptLink(String... classpaths)
Description copied from interface: RenderSupport
Used to add scripts that are stored on the classpath. Each element has symbols expanded, then is converted to an asset and added as a script link.

Specified by:
addClasspathScriptLink in interface RenderSupport
Parameters:
classpaths - array of paths. Symbols in the paths are expanded, then the paths are each converted into an asset.

addScript

public void addScript(String script)
Description copied from interface: RenderSupport
Adds a script statement to the page's script block. A newline will be added after the script statement.

Specified by:
addScript in interface RenderSupport
Parameters:
script - text to be added to the script block

addScript

public void addScript(String format,
                      Object... arguments)
Description copied from interface: RenderSupport
Adds a script statement to the page's script block. The parameters are passed to String.format(String, Object[]) before being added to the script block. A newline will be added after the formatted statement.

Specified by:
addScript in interface RenderSupport
Parameters:
format - base string format, to be passed through String.format
arguments - additional arguments formatted to form the final script

addInit

public void addInit(String functionName,
                    JSONArray parameterList)
Description copied from interface: RenderSupport
Add an initialization call.

Specified by:
addInit in interface RenderSupport
Parameters:
functionName - the name of the function (on the client-side Tapestry.Initializer object) to invoke.
parameterList - list of parameters for the method invocation.
See Also:
RenderSupport.addScript(String, Object[])

addInit

public void addInit(String functionName,
                    JSONObject parameter)
Description copied from interface: RenderSupport
Alternate version of RenderSupport.addInit(String, org.apache.tapestry5.json.JSONArray) where just a single object is passed.

Specified by:
addInit in interface RenderSupport
Parameters:
functionName - the name of the function (on the client-side Tapestry object) to invoke.
parameter - the object to pass to the function

addInit

public void addInit(String functionName,
                    String... parameters)
Description copied from interface: RenderSupport
Alternate version of RenderSupport.addInit(String, org.apache.tapestry5.json.JSONArray) where one or more strings are passed. A single string is added to the initialization call as itself; otherwise, the parameters are combined to form a JSONArray.

Specified by:
addInit in interface RenderSupport
Parameters:
functionName - the name of the function (on the client-side Tapestry object) to invoke.

autofocus

public void autofocus(FieldFocusPriority priority,
                      String fieldId)
Description copied from interface: RenderSupport
Invoked to set focus on a rendered field. Takes into account priority, meaning that a field with errors will take precendence over a merely required field, and over a field that is optional.

Specified by:
autofocus in interface RenderSupport
Parameters:
priority - focus is set only if the provided priority is greater than the current priority
fieldId - id of client-side element to take focus

commit

public void commit()
Commit any outstanding changes.


addStylesheetLink

public void addStylesheetLink(Asset stylesheet,
                              String media)
Description copied from interface: RenderSupport
Adds a link to a CSS stylesheet. As with JavaScript libraries, each stylesheet is added at most once. Stylesheets added this way will be ordered before any other content in the <head> element of the document. The <head> element will be created, if necessary.

Specified by:
addStylesheetLink in interface RenderSupport
Parameters:
stylesheet - the asset referencing the stylesheet
media - the media value for the stylesheet, or null to not specify a specific media type

addStylesheetLink

public void addStylesheetLink(String stylesheetURL,
                              String media)
Description copied from interface: RenderSupport
Adds a stylesheet as a URL. See notes in RenderSupport.addScriptLink(String[]).

Specified by:
addStylesheetLink in interface RenderSupport
Parameters:
stylesheetURL - URL string of stylesheet
media - media value fo the stylesheet, or null to not specify a specific media type


Copyright © 2006-2009 Apache Software Foundation. All Rights Reserved.