Universal dialog JavaScript functions
These functions are used to validate user input. They are implemented by WebSphere Commerce by default. Custom validators can be defined within included JS or JSP segment files, with the same usage
Function Name | Description |
---|---|
wc_validateDate(yearStr,monthStr,dayStr) | Validates a date element, which has three input text fields of <elementName>_year, <elementName>_month, and <elementName>_day |
wc_validateInt(intStr) | Validates whether the input string is a valid integer value. The valid integer range is [-2147483648, 2147483647]. |
wc_validateIntRange(intStr, min, max) | Validates whether the input string is a valid integer within the given range. It requires two parameters: a min and max value. |
wc_validateUTF8length(inputStr, maxlength) | Validates whether the input string is within the max UTF8 length. It requires one parameter as the max length. |
wc_validateName(inputStr) | Validates whether the input string is a valid name. Special characters are not valid, with the exception of "-", "_", and ".". This string cannot start with a leading number nor be empty. |
wc_validateTime(timeStr) | Validates whether the input string is in the valid time format: HH:MM |
wc_validateNonEmpty(inputStr) | Validates whether the input string is not empty, for example for a required field. This function does not work for check box or selection types, including radio and option selection. |
You can use the following JavaScript functions in your
universal dialog JSP page, they are implemented by WebSphere Commerce
by default. The following functions are defined in the parent frame,
and are called using parent.functionName()
:
Function Name | Description |
---|---|
finish() | Default finish implementation function, to save, validate and submit the data to server. |
cancelForm() | Default cancel implementation function, to discard all changes and go back to previous item in the bread crumb trail |
validationError(String name, String code, String msg) | An object with three properties: source element name, error code and error message. |
validateForm() | Default form data validation implementation function, to validate data and display all error messages in a popup dialog. |
getValidationErrors() | Returns an array of the validationError objects. |
getData(key, defaultValue) | A convenient function to get a previously saved JavaScript object. Internally, it calls parent.get() in panel mode and top.getData() in stand-alone mode. It is highly recommended to use this function instead of calling either parent.get() or top.getData() directly. |
saveData(key, value) | A convenient function to save a JavaScript object for later retrieval. Internally, it calls parent.put() in panel mode and top.saveData() in stand-alone mode. It is highly recommended to use this function instead of calling either parent.put() or top.saveData() directly. |
_alert(msg) | A convenient function to display a message in a popup alert dialog. Internally, it uses alertDialog() and if not found, the standard alert(). |
You can write code to implement the following JavaScript functions in your universal dialog JSP page.
Function Name | Description |
---|---|
saveFormData() | Called from _saveFormData(), this function can be implemented to put any additional data that is not currently in the form into the request parameters. |
loadFormData() | Called from _loadFormData() during page initialization, this function can be implemented to load any data to the HTML form that is not handled by Universal Dialog JSP. |
finishHandler(msg) | Called from _init() when the controller command returns a successful message. If not defined, the default implementation is to display the message and go back to the previous item in the bread crumb trail. |
errorHandler(msg, errorCode) | Called from _init() when the controller command returns an error. If not defined, the default implementation is to display the message and stay on the current page. |
init() | Called from _init() after page is loaded, this function can be implemented to process any custom logic. |