public class JavaScriptUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
SCRIPT_CLOSE_TAG
Script close tag including content suffix
|
static String |
SCRIPT_CONTENT_PREFIX
Prefix for JavaScript CDATA content.
|
static String |
SCRIPT_CONTENT_SUFFIX
Suffix for JavaScript CDATA content.
|
static String |
SCRIPT_OPEN_TAG
Script open tag including content prefix
|
| Constructor and Description |
|---|
JavaScriptUtils(Response response)
Constructor without id for backward compatibility
|
JavaScriptUtils(Response response,
String id)
Construct.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Write the script close tag to the response.
|
static CharSequence |
escapeQuotes(CharSequence input)
Escape single and double quotes so that they can be part of e.g.
|
void |
println(CharSequence script) |
void |
write(CharSequence script) |
static void |
writeCloseTag(Response response) |
static void |
writeJavaScript(Response response,
CharSequence text)
Write the simple text to the response object surrounded by a script tag.
|
static void |
writeJavaScript(Response response,
CharSequence text,
String id)
Write the simple text to the response object surrounded by a script tag.
|
static void |
writeJavaScriptUrl(Response response,
CharSequence url)
Write a reference to a javascript file to the response object
|
static void |
writeJavaScriptUrl(Response response,
CharSequence url,
String id)
Write a reference to a javascript file to the response object
|
static void |
writeJavaScriptUrl(Response response,
CharSequence url,
String id,
boolean defer,
String charset)
Write a reference to a javascript file to the response object
|
static void |
writeOpenTag(Response response) |
static void |
writeOpenTag(Response response,
String id) |
public static final String SCRIPT_CONTENT_PREFIX
public static final String SCRIPT_CONTENT_SUFFIX
public static final String SCRIPT_OPEN_TAG
public static final String SCRIPT_CLOSE_TAG
public JavaScriptUtils(Response response, String id)
response - The response objectid - public JavaScriptUtils(Response response)
response - The response objectpublic static CharSequence escapeQuotes(CharSequence input)
input - the JavaScript which needs to be escapedJSONObject.quote(String)public static void writeJavaScriptUrl(Response response, CharSequence url, String id)
response - The HTTP responseurl - The javascript file URLid - Unique identifier of elementpublic static void writeJavaScriptUrl(Response response, CharSequence url, String id, boolean defer, String charset)
response - The HTTP responseurl - The javascript file URLid - Unique identifier of elementdefer - specifies that the execution of a script should be deferred (delayed) until after
the page has been loaded.charset - a non null value specifies the charset attribute of the script tagpublic static void writeJavaScriptUrl(Response response, CharSequence url)
response - The HTTP responseurl - The javascript file URLpublic static void writeJavaScript(Response response, CharSequence text, String id)
response - The HTTP: responsetext - The text to added in between the script tagsid - Unique identifier of elementpublic static void writeJavaScript(Response response, CharSequence text)
response - The HTTP: responsetext - The text to added in between the script tagspublic static void writeOpenTag(Response response, String id)
response - id - public static void writeOpenTag(Response response)
response - public static void writeCloseTag(Response response)
response - public void write(CharSequence script)
script - Response.write(java.lang.CharSequence)public void println(CharSequence script)
script - Response.write(CharSequence)public void close()
Copyright © 2006–2014 Apache Software Foundation. All rights reserved.