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 JSPs, beans,etc)


Method Summary
static java.lang.String change(java.lang.String source, java.lang.String pattern, java.lang.String replacement)
          Replaces the occurences of a substring with a new substring
static java.lang.String getCSSFile(java.util.Locale locale)
          Return the CSS filename depending on locale fallback to centre.css if center_locale.css doesn't exist
static java.lang.String getFulfillmentCenterId(javax.servlet.http.HttpServletRequest request)
          Returns the fulfillment center id, which was set in the cookies when CSA was launched
static void processParameters(TypedProperty property)
          Parses the request for the XML and XMLObject properties and stores them in appropraite storeage variables.
static java.lang.String replaceURLVariables(java.lang.String url)
          Replace variables in a URL.
static java.lang.String replaceURLVariables(java.lang.String url, java.util.Locale loc, java.lang.Integer storeId)
          Replace variables in a URL.
static java.lang.String toHTML(java.lang.String result)
          Takes an input string and replaces the problem characters for an html input attribute value.
static java.lang.String toJavaScript(java.lang.Object result)
          Converts target to a string acceptable by javascript.
static java.lang.String toJavaScript(java.lang.String result)
          Converts target 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
 

Method Detail

change

public static java.lang.String change(java.lang.String source,
                                      java.lang.String pattern,
                                      java.lang.String replacement)
Replaces the occurences 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
Return the CSS filename depending on locale fallback to centre.css if center_locale.css doesn't exist
Parameters:
local - The local for which the CSS file should be fetched.
Returns:
The path of the local dependent CSS file.
Throws:
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 was set in the cookies when CSA was launched
Parameters:
request - The HTTP request.
Returns:
The fulfillment center ID.
Throws:
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 appropraite storeage variables.
Parameters:
property - The request object.
Throws:
If - an error occurs, throw an exception.

replaceURLVariables

public static final java.lang.String replaceURLVariables(java.lang.String url)
                                                  throws ECSystemException
Replace variables in a URL. The variables to replace and their values are defined in an xml file.
Parameters:
url - java.lang.String The url which needs its variables replaced.
Returns:
String The new url with the variables replaced.
Throws:
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
Replace variables in a URL. The variables to replace and their values are defined in an xml file. This version also replaces 2 additional variables $storeId$ and $locale$ with the store id and the locale (eg: en_US) respectively.
Parameters:
url - java.lang.String The url which needs its variables replaced.
Returns:
String The new url with the variables replaced
Throws:
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 an 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 to a string acceptable by javascript. This involves escaping any special characters.
Parameters:
result - The object to be converted into JavaScript.
Returns:
The new string in as a JavaScript object.

toJavaScript

public static java.lang.String toJavaScript(java.lang.String result)
Converts target to a string acceptable by javascript. This involves escaping any special characters.
Parameters:
result - The object to be converted into JavaScript.
Returns:
The new string in as a JavaScript object.

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 your JavaScript object.
target - The object to be converted to JavaScript

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 when we should stop getting the objects parents class.
Throws:
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 you wish to have prepended to the creation of your JavaScript object.
target - The object to be converted to JavaScript
Throws:
If - an error occurs, throw an exception.