|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.kuali.rice.krad.uif.util.ScriptUtils
public class ScriptUtils
Utility class for generating JavaScript
Constructor Summary | |
---|---|
ScriptUtils()
|
Method Summary | |
---|---|
static String |
appendScript(String script,
String appendScript)
Will append the second script parameter to the first if the first is not empty, also checks to see if the first script needs an end semi-colon added |
static String |
buildEventHandlerScript(String id,
String eventName,
String eventScript)
Builds the JavaScript string for binding the given script to the component with the given id for the given event name (using jQuery) |
static String |
buildFunctionCall(String functionName,
Object... arguments)
Helper method to build a JS string that will invoke the given function with the given arguments |
static String |
convertStringListToJsArray(List<String> list)
Converts a list of string to a valid js string array |
static String |
convertToJsValue(Map<String,String> stringMap)
Converts a map of string values to a json equivalent by converting the string values through the convertToJsValue(String) method; this will output a string representation of the map in json format |
static String |
convertToJsValue(String value)
Convert a string to a javascript value - especially for use for options used to initialize widgets such as the tree and rich table |
static List<String> |
escapeHtml(List<String> strings)
escape an array of strings |
static String |
escapeHtml(String string)
escapes a string using StringEscapeUtils.escapeHtml(String) |
static String |
escapeJSONString(String jsonString)
Escapes double quotes present in the given string |
static String |
escapeName(String name)
Escapes the ' character present in collection names so it can be properly used in js without causing javascript errors due to an early completion of a ' string. |
static String |
toJSON(Map<String,String> map)
Builds a JSON string form the given map |
static String |
translateValue(Object value)
Translates an Object to a String for representing the given Object as a JavaScript value |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ScriptUtils()
Method Detail |
---|
public static String translateValue(Object value)
Handles null, List, Map, and Set collections, along with non quoting for numeric and boolean types. Complex types are treated as a String value using toString
value
- Object instance to translate
public static String toJSON(Map<String,String> map)
map
- map to translate
public static String escapeJSONString(String jsonString)
jsonString
- string to escape
public static String convertToJsValue(Map<String,String> stringMap)
stringMap
- the map of String values to convert to a simple json object representation
public static String convertToJsValue(String value)
value
- the string to be converted
public static String escapeName(String name)
name
- name to escape
public static String convertStringListToJsArray(List<String> list)
list
- list of Strings to be converted
public static String escapeHtml(String string)
StringEscapeUtils.escapeHtml(String)
The apostrophe character is included as StringEscapeUtils#escapeHtml(String)
does not consider it a legal entity.
string
- the string to be escaped
public static List<String> escapeHtml(List<String> strings)
strings
- an array of strings to escape
public static String appendScript(String script, String appendScript)
script
- script that will be added to (null is allowed and converted to empty string)appendScript
- script to append
public static String buildFunctionCall(String functionName, Object... arguments)
functionName
- name of the JS function to invokearguments
- zero or more arguments to pass, each will be converted to the corresponding
JS type
public static String buildEventHandlerScript(String id, String eventName, String eventScript)
id
- id of the element to handle the event foreventName
- name of the event the script will handleeventScript
- script to be executed when the event is thrown, if blank an empty string
will be returned
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |