|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface JavaScriptSupport
An environmental that acts as a replacement for the RenderSupport
environmental, renaming and streamlining
the key methods. JavaScriptSupport is very stateful, accumulating JavaScript stacks, libraries and initialization
code until the end of the main page render; it then updates the rendered DOM (adding <script> tags to the
<head> and <body>) before the document is streamed to the client.
Environmental
annotation on a
component field. In addition, JavaScriptSupport may also be accessed as a service (the service
internally delegates to the current environmental instance), which is useful
for service-layer objects.
The term "import" is used on many methods to indicate that the indicated resource (stack, library or stylesheet) will
only be added to the final Document once.
The name is slightly a misnomer, since there's a side-line of
importStylesheet(StylesheetLink) as well.
JavaScriptSupport works equally well inside an Ajax request that produces a JSON-formatted partial page update response.
DocumentLinker
Method Summary | |
---|---|
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 |
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 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 |
importJavaScriptLibrary(Asset asset)
Imports a JavaScript library as part of the rendered page. |
void |
importJavaScriptLibrary(String libraryURL)
Import a Javascript library with an arbitrary URL. |
void |
importStack(String stackName)
Imports a JavaScriptStack by name, a related set of JavaScript libraries and stylesheets. |
void |
importStylesheet(Asset stylesheet)
A convenience method that wraps the Asset as a StylesheetLink . |
void |
importStylesheet(StylesheetLink stylesheetLink)
Imports a Cascading Style Sheet file as part of the rendered page. |
Method Detail |
---|
String allocateClientId(String id)
id
- the component id from which a unique id will be generated
IdAllocator
String allocateClientId(ComponentResources resources)
allocateClientId(String)
but uses the id of the component extracted from the resources.
resources
- of the component which requires an id
void addScript(String format, Object... arguments)
InitializationPriority.NORMAL
priority.
format
- format string (as per String.format(String, Object...)
arguments
- arguments referenced by format specifiersvoid addScript(InitializationPriority priority, String format, Object... arguments)
priority
- priority to use when adding the scriptformat
- format string (as per String.format(String, Object...)
arguments
- arguments referenced by format specifiersvoid addInitializerCall(String functionName, JSONObject parameter)
InitializationPriority.NORMAL
priority.
functionName
- name of client-side function (within Tapestry.Initializer namespace) to executeparameter
- object to pass to the client-side functionvoid addInitializerCall(String functionName, JSONArray parameter)
InitializationPriority.NORMAL
priority.
functionName
- name of client-side function (within Tapestry.Initializer namespace) to executeparameter
- array of parameters to pass to the client-side functionvoid addInitializerCall(InitializationPriority priority, String functionName, JSONArray parameter)
InitializationPriority.NORMAL
priority.
functionName
- name of client-side function (within Tapestry.Initializer namespace) to executeparameter
- array of parameters to pass to the client-side functionvoid addInitializerCall(InitializationPriority priority, String functionName, JSONObject parameter)
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 functionvoid addInitializerCall(String functionName, String parameter)
InitializationPriority.NORMAL
priority.
functionName
- name of client-side function (within Tapestry.Initializer namespace) to executeparameter
- string to pass to function (typically, a client id)void addInitializerCall(InitializationPriority priority, String functionName, String parameter)
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)void importJavaScriptLibrary(Asset asset)
Import
void importStylesheet(Asset stylesheet)
StylesheetLink
.
stylesheet
- asset for the stylesheetimportStylesheet(StylesheetLink)
void importStylesheet(StylesheetLink stylesheetLink)
stylesheetLink
- encapsulates the link URL plus any additional optionsvoid importStack(String stackName)
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.
stackName
- the name of the stack (case is ignored); the stack must existvoid importJavaScriptLibrary(String libraryURL)
void autofocus(FieldFocusPriority priority, String fieldId)
FieldFocusPriority.OVERRIDE
can be used to force a particular field to receive
focus.
priority
- focus is set only if the provided priority is greater than the current priorityfieldId
- id of client-side element to take focus
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |