public class JavaScriptSupportImpl extends Object implements JavaScriptSupport
Constructor and Description |
---|
JavaScriptSupportImpl(DocumentLinker linker,
JavaScriptStackSource javascriptStackSource,
JavaScriptStackPathConstructor stackPathConstructor,
BooleanHook suppressCoreStylesheetsHook) |
JavaScriptSupportImpl(DocumentLinker linker,
JavaScriptStackSource javascriptStackSource,
JavaScriptStackPathConstructor stackPathConstructor,
IdAllocator idAllocator,
boolean partialMode,
BooleanHook suppressCoreStylesheetsHook) |
Modifier and Type | Method and Description |
---|---|
void |
addInitializerCall(InitializationPriority priority,
String functionName,
JSONArray parameter)
Adds a call to a client-side function inside the Tapestry.Initializer namespace.
|
void |
addInitializerCall(InitializationPriority priority,
String functionName,
JSONObject parameter)
Adds a call to a client-side function inside the Tapestry.Initializer namespace.
|
void |
addInitializerCall(InitializationPriority priority,
String functionName,
String parameter)
Adds a call to a client-side function inside the Tapestry.Initializer namespace.
|
void |
addInitializerCall(String functionName,
JSONArray parameter)
Adds a call to a client-side function inside the Tapestry.Initializer namespace.
|
void |
addInitializerCall(String functionName,
JSONObject parameter)
Adds a call to a client-side function inside the Tapestry.Initializer namespace.
|
void |
addInitializerCall(String functionName,
String parameter)
Adds a call to a client-side function inside the Tapestry.Initializer namespace.
|
void |
addModuleConfigurationCallback(ModuleConfigurationCallback callback)
Adds a module configuration callback for this request.
|
void |
addScript(InitializationPriority priority,
String format,
Object... arguments)
Adds initialization script at the specified priority.
|
void |
addScript(String format,
Object... arguments)
Adds initialization script at
InitializationPriority.NORMAL priority. |
String |
allocateClientId(ComponentResources resources)
As with
JavaScriptSupport.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.
|
JavaScriptSupport |
autofocus(FieldFocusPriority priority,
String fieldId)
Invoked to set focus on a rendered field.
|
void |
commit() |
JavaScriptSupport |
importJavaScriptLibrary(Asset asset)
Imports a JavaScript library as part of the rendered page.
|
JavaScriptSupport |
importJavaScriptLibrary(String libraryURL)
Import a Javascript library with an arbitrary URL.
|
JavaScriptSupport |
importStack(String stackName)
Imports a
JavaScriptStack by name, a related set of JavaScript libraries and stylesheets. |
JavaScriptSupport |
importStylesheet(Asset stylesheet)
A convenience method that wraps the Asset as a
StylesheetLink . |
JavaScriptSupport |
importStylesheet(StylesheetLink stylesheetLink)
Imports a Cascading Style Sheet file as part of the rendered page.
|
Initialization |
require(String moduleName)
Requires a JavaScript module by name.
|
public JavaScriptSupportImpl(DocumentLinker linker, JavaScriptStackSource javascriptStackSource, JavaScriptStackPathConstructor stackPathConstructor, BooleanHook suppressCoreStylesheetsHook)
public JavaScriptSupportImpl(DocumentLinker linker, JavaScriptStackSource javascriptStackSource, JavaScriptStackPathConstructor stackPathConstructor, IdAllocator idAllocator, boolean partialMode, BooleanHook suppressCoreStylesheetsHook)
linker
- responsible for assembling all the information gathered by JavaScriptSupport and
attaching it to the Document (for a full page render) or to the JSON response (in a partial render)javascriptStackSource
- source of information about JavaScriptStack
s, used when handling the import
of libraries and stacks (often, to handle transitive dependencies)stackPathConstructor
- encapsulates the knowledge of how to represent a stack (which may be converted
from a series of JavaScript libraries into a single virtual JavaScript library)idAllocator
- used when allocating unique ids (it is usually pre-initialized in an Ajax request to ensure
that newly allocated ids do not conflict with previous renders and partial updates)partialMode
- if true, then the JSS configures itself for a partial page render (part of an Ajax request)
which automatically assumes the "core" library has been added (to the original page render)suppressCoreStylesheetsHook
- a hook that enables ignoring CSS files on the core stackpublic void commit()
public void addInitializerCall(InitializationPriority priority, String functionName, JSONObject parameter)
JavaScriptSupport
addInitializerCall
in interface JavaScriptSupport
priority
- priority to use when adding the scriptfunctionName
- name of client-side function (within Tapestry.Initializer namespace) to executeparameter
- object to pass to the client-side functionpublic void addInitializerCall(String functionName, JSONArray parameter)
JavaScriptSupport
InitializationPriority.NORMAL
priority.addInitializerCall
in interface JavaScriptSupport
functionName
- name of client-side function (within Tapestry.Initializer namespace) to executeparameter
- array of parameters to pass to the client-side functionpublic void addInitializerCall(InitializationPriority priority, String functionName, JSONArray parameter)
JavaScriptSupport
InitializationPriority.NORMAL
priority.addInitializerCall
in interface JavaScriptSupport
functionName
- name of client-side function (within Tapestry.Initializer namespace) to executeparameter
- array of parameters to pass to the client-side functionpublic void addInitializerCall(String functionName, JSONObject parameter)
JavaScriptSupport
InitializationPriority.NORMAL
priority.addInitializerCall
in interface JavaScriptSupport
functionName
- name of client-side function (within Tapestry.Initializer namespace) to executeparameter
- object to pass to the client-side functionpublic void addInitializerCall(InitializationPriority priority, String functionName, String parameter)
JavaScriptSupport
addInitializerCall
in interface JavaScriptSupport
priority
- priority to use when adding the scriptfunctionName
- name of client-side function (within Tapestry.Initializer namespace) to executeparameter
- string to pass to function (typically, a client id)public void addInitializerCall(String functionName, String parameter)
JavaScriptSupport
InitializationPriority.NORMAL
priority.addInitializerCall
in interface JavaScriptSupport
functionName
- name of client-side function (within Tapestry.Initializer namespace) to executeparameter
- string to pass to function (typically, a client id)public void addScript(InitializationPriority priority, String format, Object... arguments)
JavaScriptSupport
addScript
in interface JavaScriptSupport
priority
- priority to use when adding the scriptformat
- format string (as per String.format(String, Object...)
arguments
- arguments referenced by format specifierspublic void addScript(String format, Object... arguments)
JavaScriptSupport
InitializationPriority.NORMAL
priority.addScript
in interface JavaScriptSupport
format
- format string (as per String.format(String, Object...)
arguments
- arguments referenced by format specifierspublic void addModuleConfigurationCallback(ModuleConfigurationCallback callback)
JavaScriptSupport
addModuleConfigurationCallback
in interface JavaScriptSupport
callback
- a ModuleConfigurationCallback
. It cannot be null.DocumentLinker.addModuleConfigurationCallback(ModuleConfigurationCallback)
public String allocateClientId(ComponentResources resources)
JavaScriptSupport
JavaScriptSupport.allocateClientId(String)
but uses the id of the component extracted from the resources.allocateClientId
in interface JavaScriptSupport
resources
- of the component which requires an idpublic String allocateClientId(String id)
JavaScriptSupport
allocateClientId
in interface JavaScriptSupport
id
- the component id from which a unique id will be generatedIdAllocator
public JavaScriptSupport importJavaScriptLibrary(Asset asset)
JavaScriptSupport
importJavaScriptLibrary
in interface JavaScriptSupport
Import
public JavaScriptSupport importJavaScriptLibrary(String libraryURL)
JavaScriptSupport
importJavaScriptLibrary
in interface JavaScriptSupport
public JavaScriptSupport importStylesheet(Asset stylesheet)
JavaScriptSupport
StylesheetLink
.importStylesheet
in interface JavaScriptSupport
stylesheet
- asset for the stylesheetJavaScriptSupport.importStylesheet(StylesheetLink)
public JavaScriptSupport importStylesheet(StylesheetLink stylesheetLink)
JavaScriptSupport
importStylesheet
in interface JavaScriptSupport
stylesheetLink
- encapsulates the link URL plus any additional optionspublic JavaScriptSupport importStack(String stackName)
JavaScriptSupport
JavaScriptStack
by name, a related set of JavaScript libraries and stylesheets.
Stacks are contributions to the JavaScriptStackSource
service. When
JavaScript aggregation in enabled, the stack will be represented by
a single virtual URL; otherwise the individual asset URLs of the stack
will be added to the document.
Please refer to the notes about libraries vs. modules.importStack
in interface JavaScriptSupport
stackName
- the name of the stack (case is ignored); the stack must existpublic JavaScriptSupport autofocus(FieldFocusPriority priority, String fieldId)
JavaScriptSupport
FieldFocusPriority.OVERRIDE
can be used to force a particular field to receive
focus.autofocus
in interface JavaScriptSupport
priority
- focus is set only if the provided priority is greater than the current priorityfieldId
- id of client-side element to take focuspublic Initialization require(String moduleName)
JavaScriptSupport
require()
the module and
(optionally) de-reference a function exported by the module (or, treat the module as exporting a single
implicit function). The function will be invoked. Use the returned Initialization
to specify the function name
to invoke, and the parameters to pass to the function.
In some cases, a module exports no functions, but performs some initialization (typically, adding document-level
event handlers), in which case a call to require() is sufficient. In cases where the module, or a function
within the module, are invoked with no parameters, the calls will be collapsed into a single invocation.
If the module is part of a JavaScript stack,
then the stack will be imported; this is important when JavaScript aggregation is enabled,
but also ensures that libraries in the stack are loaded before the module (for cases where the
module has dependencies on libraries not wrapped as AMD modules).require
in interface JavaScriptSupport
moduleName
- the name of the module to require${project.version} - Copyright © 2003-2015 The Apache Software Foundation.