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 JavaScriptStacks, 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)
JavaScriptSupportaddInitializerCall in interface JavaScriptSupportpriority - 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)
JavaScriptSupportInitializationPriority.NORMAL priority.addInitializerCall in interface JavaScriptSupportfunctionName - 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)
JavaScriptSupportInitializationPriority.NORMAL priority.addInitializerCall in interface JavaScriptSupportfunctionName - 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)
JavaScriptSupportInitializationPriority.NORMAL priority.addInitializerCall in interface JavaScriptSupportfunctionName - 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)
JavaScriptSupportaddInitializerCall in interface JavaScriptSupportpriority - 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)
JavaScriptSupportInitializationPriority.NORMAL priority.addInitializerCall in interface JavaScriptSupportfunctionName - 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)
JavaScriptSupportaddScript in interface JavaScriptSupportpriority - 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)
JavaScriptSupportInitializationPriority.NORMAL priority.addScript in interface JavaScriptSupportformat - format string (as per String.format(String, Object...)arguments - arguments referenced by format specifierspublic void addModuleConfigurationCallback(ModuleConfigurationCallback callback)
JavaScriptSupportaddModuleConfigurationCallback in interface JavaScriptSupportcallback - a ModuleConfigurationCallback. It cannot be null.DocumentLinker.addModuleConfigurationCallback(ModuleConfigurationCallback)public String allocateClientId(ComponentResources resources)
JavaScriptSupportJavaScriptSupport.allocateClientId(String) but uses the id of the component extracted from the resources.allocateClientId in interface JavaScriptSupportresources - of the component which requires an idpublic String allocateClientId(String id)
JavaScriptSupportallocateClientId in interface JavaScriptSupportid - the component id from which a unique id will be generatedIdAllocatorpublic JavaScriptSupport importJavaScriptLibrary(Asset asset)
JavaScriptSupportimportJavaScriptLibrary in interface JavaScriptSupportImportpublic JavaScriptSupport importJavaScriptLibrary(String libraryURL)
JavaScriptSupportimportJavaScriptLibrary in interface JavaScriptSupportpublic JavaScriptSupport importStylesheet(Asset stylesheet)
JavaScriptSupportStylesheetLink.importStylesheet in interface JavaScriptSupportstylesheet - asset for the stylesheetJavaScriptSupport.importStylesheet(StylesheetLink)public JavaScriptSupport importStylesheet(StylesheetLink stylesheetLink)
JavaScriptSupportimportStylesheet in interface JavaScriptSupportstylesheetLink - encapsulates the link URL plus any additional optionspublic JavaScriptSupport importStack(String stackName)
JavaScriptSupportJavaScriptStack 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 JavaScriptSupportstackName - the name of the stack (case is ignored); the stack must existpublic JavaScriptSupport autofocus(FieldFocusPriority priority, String fieldId)
JavaScriptSupportFieldFocusPriority.OVERRIDE can be used to force a particular field to receive
focus.autofocus in interface JavaScriptSupportpriority - 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)
JavaScriptSupportrequire() 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 JavaScriptSupportmoduleName - the name of the module to require5.6.4 - Copyright © 2003-2021 The Apache Software Foundation.