org.apache.wicket.util.string
Class JavascriptUtils

java.lang.Object
  extended by org.apache.wicket.util.string.JavascriptUtils

public class JavascriptUtils
extends java.lang.Object

Provide some helpers to write javascript related tags to the response object.

Author:
Juergen Donnerstag

Field Summary
static java.lang.String SCRIPT_CLOSE_TAG
          Script close tag
static java.lang.String SCRIPT_CONTENT_PREFIX
          Script open tag.
static java.lang.String SCRIPT_CONTENT_SUFFIX
          Script close tag.
static java.lang.String SCRIPT_OPEN_TAG
          Script open tag
 
Constructor Summary
JavascriptUtils(Response response)
          Constructor without id for backward compatibility
JavascriptUtils(Response response, java.lang.String id)
          Construct.
 
Method Summary
 void close()
          Write the script close tag to the response.
static java.lang.CharSequence escapeQuotes(java.lang.CharSequence input)
          Escape quotes and double quotes so that they can be part of e.g.
 void println(java.lang.CharSequence script)
           
 void write(java.lang.CharSequence script)
           
static void writeCloseTag(Response response)
           
static void writeJavascript(Response response, java.lang.CharSequence text)
          Write the simple text to the response object surrounded by a script tag.
static void writeJavascript(Response response, java.lang.CharSequence text, java.lang.String id)
          Write the simple text to the response object surrounded by a script tag.
static void writeJavascriptUrl(Response response, java.lang.CharSequence url)
          Write a reference to a javascript file to the response object
static void writeJavascriptUrl(Response response, java.lang.CharSequence url, java.lang.String id)
          Write a reference to a javascript file to the response object
static void writeOpenTag(Response response)
           
static void writeOpenTag(Response response, java.lang.String id)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCRIPT_OPEN_TAG

public static final java.lang.String SCRIPT_OPEN_TAG
Script open tag

See Also:
Constant Field Values

SCRIPT_CLOSE_TAG

public static final java.lang.String SCRIPT_CLOSE_TAG
Script close tag

See Also:
Constant Field Values

SCRIPT_CONTENT_PREFIX

public static final java.lang.String SCRIPT_CONTENT_PREFIX
Script open tag. If this tag is changed, also update Wicket.Head.Contributor.processScript() function from wicket-ajax.js

See Also:
Constant Field Values

SCRIPT_CONTENT_SUFFIX

public static final java.lang.String SCRIPT_CONTENT_SUFFIX
Script close tag. If this tag is changed, also update Wicket.Head.Contributor.processScript() function from wicket-ajax.js

See Also:
Constant Field Values
Constructor Detail

JavascriptUtils

public JavascriptUtils(Response response,
                       java.lang.String id)
Construct.

Parameters:
response - The response object
id -

JavascriptUtils

public JavascriptUtils(Response response)
Constructor without id for backward compatibility

Parameters:
response - The response object
Method Detail

escapeQuotes

public static java.lang.CharSequence escapeQuotes(java.lang.CharSequence input)
Escape quotes and double quotes so that they can be part of e.g. an alert call.

Parameters:
input - input
Returns:
Escaped version of the input

writeJavascriptUrl

public static void writeJavascriptUrl(Response response,
                                      java.lang.CharSequence url,
                                      java.lang.String id)
Write a reference to a javascript file to the response object

Parameters:
response - The HTTP response
url - The javascript file URL
id - Unique identifier of element

writeJavascriptUrl

public static void writeJavascriptUrl(Response response,
                                      java.lang.CharSequence url)
Write a reference to a javascript file to the response object

Parameters:
response - The HTTP response
url - The javascript file URL

writeJavascript

public static void writeJavascript(Response response,
                                   java.lang.CharSequence text,
                                   java.lang.String id)
Write the simple text to the response object surrounded by a script tag.

Parameters:
response - The HTTP: response
text - The text to added in between the script tags
id - Unique identifier of element

writeJavascript

public static void writeJavascript(Response response,
                                   java.lang.CharSequence text)
Write the simple text to the response object surrounded by a script tag.

Parameters:
response - The HTTP: response
text - The text to added in between the script tags

writeOpenTag

public static void writeOpenTag(Response response,
                                java.lang.String id)
Parameters:
response -
id -

writeOpenTag

public static void writeOpenTag(Response response)
Parameters:
response -

writeCloseTag

public static void writeCloseTag(Response response)
Parameters:
response -

write

public void write(java.lang.CharSequence script)
Parameters:
script -
See Also:
Response.write(java.lang.CharSequence)

println

public void println(java.lang.CharSequence script)
Parameters:
script -
See Also:
Response.println(java.lang.CharSequence)

close

public void close()
Write the script close tag to the response. The response output stream remains open.



Copyright © 2004-2010 Apache Software Foundation. All Rights Reserved.