java.lang.Object
org.apache.wicket.core.util.string.JavaScriptUtils
Provide some helpers to write javascript related tags to the response object.
- Author:
- Juergen Donnerstag
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
Script close tag including content suffixstatic final String
Prefix for JavaScript CDATA content.static final String
Suffix for JavaScript CDATA content.static final String
Script open tag including content prefix -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic CharSequence
escapeQuotes
(CharSequence input) Escape single and double quotes so that they can be part of e.g. an alert call.static void
writeCloseTag
(Response response) Write close script tag for inline script.static void
writeInlineScript
(Response response, CharSequence text, AttributeMap attributes) Write the simple text to the response object surrounded by a script tag.static void
writeJavaScript
(Response response, CharSequence text) Write the simple text to the response object surrounded by a script tag.static void
writeOpenTag
(Response response, AttributeMap attributes) Write open script tag for inline script.static void
writeScript
(Response response, AttributeMap attributes) Write a reference to a javascript file to the response object
-
Field Details
-
SCRIPT_CONTENT_PREFIX
Prefix for JavaScript CDATA content. If this is changed, also update Wicket.Head.Contributor.processScript() function from wicket-ajax-jquery.js- See Also:
-
SCRIPT_CONTENT_SUFFIX
Suffix for JavaScript CDATA content. If this is changed, also update Wicket.Head.Contributor.processScript() function from wicket-ajax-jquery.js- See Also:
-
SCRIPT_OPEN_TAG
Script open tag including content prefix- See Also:
-
SCRIPT_CLOSE_TAG
Script close tag including content suffix- See Also:
-
ATTR_ID
- See Also:
-
ATTR_TYPE
- See Also:
-
ATTR_SCRIPT_SRC
- See Also:
-
ATTR_SCRIPT_DEFER
- See Also:
-
ATTR_SCRIPT_ASYNC
- See Also:
-
ATTR_CSP_NONCE
- See Also:
-
ATTR_CROSS_ORIGIN
- See Also:
-
ATTR_INTEGRITY
- See Also:
-
-
Constructor Details
-
JavaScriptUtils
public JavaScriptUtils()
-
-
Method Details
-
escapeQuotes
Escape single and double quotes so that they can be part of e.g. an alert call. Note: JSON values need to escape only the double quote, so this method wont help.- Parameters:
input
- the JavaScript which needs to be escaped- Returns:
- Escaped version of the input
-
writeScript
Write a reference to a javascript file to the response object- Parameters:
response
- The HTTP responseattributes
- Extra tag attributes
-
writeInlineScript
Write the simple text to the response object surrounded by a script tag.- Parameters:
response
- The HTTP: responsetext
- The text to added in between the script tagsattributes
- Extra tag attributes
-
writeJavaScript
Write the simple text to the response object surrounded by a script tag.- Parameters:
response
- The HTTP: responsetext
- The text to added in between the script tags
-
writeOpenTag
Write open script tag for inline script. Content is prefixed withSCRIPT_CONTENT_PREFIX
.- Parameters:
response
- the response to write toattributes
- Tag attributes map
-
writeCloseTag
Write close script tag for inline script. The close tag is prefixed withSCRIPT_CONTENT_SUFFIX
- Parameters:
response
- the response to write to
-