com.plumtree.uiinfrastructure.statichelpers
Class JSHelper

java.lang.Object
  extended by com.plumtree.uiinfrastructure.statichelpers.JSHelper

public class JSHelper
extends java.lang.Object

Javascript helper functions

Author:
adolfoc, robertz

Field Summary
static java.lang.String ALIDOJO_OBJECT
          rob: Initialized in common-jsdojo build bea/dnd/dnd.js, probably should move to init.js
static java.lang.String SAFEJSVAR_CONTAINER_NAME
          Name of the safe javascript var container variable
 
Constructor Summary
JSHelper()
           
 
Method Summary
static HTMLScript AddSafeJSVariable(java.lang.String strName, java.lang.String strValue)
          Helper function to define a safe javascript variable.
static java.lang.String escapeJS(java.lang.String s)
          Escape JavaScript strings.
static java.lang.String GetSafeJSVariable(java.lang.String strName)
          Helper function to retrieve a safe javascript variable.
static java.lang.String GetSafeJSVariableWarn(java.lang.String strName)
          Helper function to retrieve a safe javascript variable.
static HTMLScript InitializeSafeJSVarElements()
          Create the container to hold the safe variables.
static java.lang.String JSEncodeString(java.lang.String strIn)
          Escape single and double quotes, neccessary for javascript variable values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SAFEJSVAR_CONTAINER_NAME

public static final java.lang.String SAFEJSVAR_CONTAINER_NAME
Name of the safe javascript var container variable

See Also:
Constant Field Values

ALIDOJO_OBJECT

public static final java.lang.String ALIDOJO_OBJECT
rob: Initialized in common-jsdojo build bea/dnd/dnd.js, probably should move to init.js

See Also:
Constant Field Values
Constructor Detail

JSHelper

public JSHelper()
Method Detail

JSEncodeString

public static java.lang.String JSEncodeString(java.lang.String strIn)
Escape single and double quotes, neccessary for javascript variable values.

Parameters:
strIn - String to escape
Returns:
String with escaped single and double quotes

AddSafeJSVariable

public static HTMLScript AddSafeJSVariable(java.lang.String strName,
                                           java.lang.String strValue)
Helper function to define a safe javascript variable. The safe variable will be defined in its on javascript block, so it won't affect any other javascript if the assigned value is invalid. Reference it by using the javascript getSafeVariable or getSafeVariableWarn helper functions or GetSafeJSVariable or GetSafeJSVariableWarn java helper functions to generate the javascript calls. NOTE: The strValue is the string with the javascript value so don't surround it with quotes unless you want the value to be a string. E.g. strValue = "new Object()" - will assign a new object to the variable while strValue = "'new Object()'" - will assign the string 'new Object()'

Parameters:
strName -
strValue -
Returns:
HTMLScript

GetSafeJSVariable

public static java.lang.String GetSafeJSVariable(java.lang.String strName)
Helper function to retrieve a safe javascript variable. The javascript function will return false if it is unable to get the variable.

Parameters:
strName -
Returns:
String

GetSafeJSVariableWarn

public static java.lang.String GetSafeJSVariableWarn(java.lang.String strName)
Helper function to retrieve a safe javascript variable. The javascript function will show a javascript alert error with the name of the variable. Use for critical variables that absolutely need to be defined.

Parameters:
strName -
Returns:
String

InitializeSafeJSVarElements

public static HTMLScript InitializeSafeJSVarElements()
Create the container to hold the safe variables. The container is just a javascript object and we but the vars on it as object properties.

Returns:
HTMLScript

escapeJS

public static final java.lang.String escapeJS(java.lang.String s)
Escape JavaScript strings.




Copyright © 2002,2003,2004,2005 Plumtree Software, Inc., All Rights Reserved.