com.ibm.commerce.tools.util
Class UIUtil

java.lang.Object
  |
  +--com.ibm.commerce.tools.util.UIUtil

public class UIUtil
extends java.lang.Object

Utility class used by the UI Elements (in Java Server Pages and Entity Beans).


Field Summary
static java.lang.String COPYRIGHT
          The IBM copyright notice field.
 
Constructor Summary
UIUtil()
           
 
Method Summary
static java.lang.String change(java.lang.String source, java.lang.String pattern, java.lang.String replacement)
          Replaces the occurrences of a substring with a new substring
static java.lang.String getCSSFile(java.util.Locale locale)
          Returns the Cascading Style Sheets filename depending on locale.
static java.lang.String getFulfillmentCenterId(javax.servlet.http.HttpServletRequest request)
          Returns the fulfillment center ID, which is set in the cookies when WebSphere Commerce Accelerator is launched.
static java.lang.String getWebappPath(HttpServletRequest req)
          Returns the webapp path.
static java.lang.String getWebPrefix(HttpServletRequest req)
          Returns the web prefix.
static void processParameters( TypedProperty property)
          Parses the request for the XML and XMLObject properties and stores them in appropriate storeage variables.
static java.lang.String replaceURLVariables(java.lang.String url)
          Replaces variables in a URL.
static java.lang.String replaceURLVariables(java.lang.String url, java.util.Locale loc, java.lang.Integer storeId)
          Replaces variables in an URL.
static void setNonJSConvertibleMethods(java.util.Vector methods)
          Sets a list of method names that should not be converted to JavaScript during the calls of addToJS,
static java.lang.String toHTML(java.lang.String result)
          Takes an input string and replaces the problem characters for a HTML input attribute value.
static java.lang.String toJavaScript(java.lang.Object result)
          Converts target object to a string that is acceptable by JavaScript.
static java.lang.String toJavaScript(java.lang.String result)
          Converts target string to a string acceptable by JavaScript.
static java.lang.String toJS(java.lang.String key, java.lang.Object target)
          Converts the target model to a JavaScript representation of that model.
static java.lang.String toJS(java.lang.String key, java.lang.Object target, int stoplevel)
          Converts the target model to a JavaScript representation of that model.
static java.lang.String toJSVector(java.lang.String key, java.lang.Object target)
          Converts the target model to a JavaScript representation of that model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail
public static final java.lang.String COPYRIGHT
The IBM copyright notice field.
See Also:
Constant Field Values
Constructor Detail

UIUtil

public UIUtil()
Method Detail

change

public static java.lang.String change(java.lang.String source,
                                      java.lang.String pattern,
                                      java.lang.String replacement)
Replaces the occurrences of a substring with a new substring
Parameters:
source - the original string
pattern - the pattern to be replaced
replacement - the replacement for pattern
Returns:
The new changed string.

getCSSFile

public static java.lang.String getCSSFile(java.util.Locale locale)
                                   throws ECSystemException
Returns the Cascading Style Sheets filename depending on locale. It falls back to centre.css if center_locale.css does not exist.
Returns:
The path of the local dependent Cascading Style Sheets file.
Throws:
ECSystemException - If an error occurs, throw an exception.

getFulfillmentCenterId

public static java.lang.String getFulfillmentCenterId(javax.servlet.http.HttpServletRequest request)
                                               throws ECSystemException
Returns the fulfillment center ID, which is set in the cookies when WebSphere Commerce Accelerator is launched.
Parameters:
request - the HTTP request
Returns:
The fulfillment center ID.
Throws:
ECSystemException - If an error occurs, throw an exception.

processParameters

public static final void processParameters(TypedProperty property)
                                    throws ECSystemException
Parses the request for the XML and XMLObject properties and stores them in appropriate storeage variables.
Parameters:
property - the request object
Throws:
ECSystemException - If an error occurs, throw an exception.

replaceURLVariables

public static final java.lang.String replaceURLVariables(java.lang.String url)
                                                  throws ECSystemException
Replaces variables in a URL. The variables to replace and their values are defined in an XML file.
Parameters:
url - the url which needs its variables be replaced
Returns:
The new url with the variables replaced.
Throws:
ECSystemException - If an error occurs, throw an exception.

replaceURLVariables

public static final java.lang.String replaceURLVariables(java.lang.String url,
                                                         java.util.Locale loc,
                                                         java.lang.Integer storeId)
                                                  throws ECSystemException
Replaces variables in an URL. The variables to replace and their values are defined in a XML file. This version also replaces two additional variables, $storeId$ and $locale$, with the store ID and the locale (for example: en_US) respectively.
Parameters:
url - the URL which needs its variables to be replaced
Returns:
The new URL with the variables replaced.
Throws:
ECSystemException - If an error occurs, throw an exception.

toHTML

public static java.lang.String toHTML(java.lang.String result)
Takes an input string and replaces the problem characters for a HTML input attribute value.

& replaced & " replaced &qout;

Note: All HTML attribute values are assumed to be delimited by double quote.

Parameters:
result - the string to be converted
Returns:
The converted string.

toJavaScript

public static java.lang.String toJavaScript(java.lang.Object result)
Converts target object to a string that is acceptable by JavaScript.
Parameters:
result - the object to be converted into JavaScript.
Returns:
A valid JavaScript string.

toJavaScript

public static java.lang.String toJavaScript(java.lang.String result)
Converts target string to a string acceptable by JavaScript.
Parameters:
result - the object to be converted into JavaScript
Returns:
A valid JavaScript string.

toJS

public static final java.lang.String toJS(java.lang.String key,
                                          java.lang.Object target)
                                   throws ECSystemException
Converts the target model to a JavaScript representation of that model.
Parameters:
key - the prefix you wish to have prepended to the creation of the JavaScript object
target - the object to be converted to JavaScript
Returns:
A string of JavaScript representation.
Throws:
ECSystemException - If an error occurs, throw an exception.

toJS

public static final java.lang.String toJS(java.lang.String key,
                                          java.lang.Object target,
                                          int stoplevel)
                                   throws ECSystemException
Converts the target model to a JavaScript representation of that model.
Parameters:
key - the prefix you wish to have prepended to the creation of your JavaScript object
target - the object to be converted to JavaScript
stoplevel - the number of levels up to stop getting the objects parents class
Returns:
A string of JavaScript representation.
Throws:
ECSystemException - If an error occurs, throw an exception.

toJSVector

public static java.lang.String toJSVector(java.lang.String key,
                                          java.lang.Object target)
                                   throws ECSystemException
Converts the target model to a JavaScript representation of that model.
Parameters:
key - the prefix to prepend to the creation of the JavaScript object
target - the object to be converted to JavaScript
Returns:
A string of JavaScript vector representation.
Throws:
ECSystemException - If an error occurs, throw an exception.

setNonJSConvertibleMethods

public static void setNonJSConvertibleMethods(java.util.Vector methods)
Sets a list of method names that should not be converted to JavaScript during the calls of addToJS,
Parameters:
methods - method names to be ignored in a vector

getWebPrefix

public static java.lang.String getWebPrefix(HttpServletRequest req)
Returns the web prefix.
Parameters:
req - the request object
Returns:
The web prefix.

getWebappPath

public static java.lang.String getWebappPath(HttpServletRequest req)
Returns the webapp path.
Parameters:
req - the request object
Returns:
The webapp path.