JSP programming best practice: Use the StoreErrorDataBean data bean for error handling
To display store-specific error messages in JSP pages, use the StoreErrorDataBean data bean.This data bean provides getter methods to:
- Retrieve the store error key, <ECMessageKey>.<Error Code>
- Retrieve the error message parameters, that is, the substitution parameters used in the error messages
In mapping error codes to error messages, the StoreErrorDataBean data bean relies on the existence of the store error message properties file, storeErrorMessages_ locale.properties, in the following directory:
- WC_eardir/Stores.war/WEB-INF/classes/ storedir
- workspace_dir\Stores\Web Content\WEB-INF\classes\ storedir
The store error message properties file should contain error message definitions, such as the following:
# UserRegistrationAddForm.jsp _ERR_CMD_INVALID_PARAM.2020 = Type an e-mail address in the E-mail address field. _ERR_CMD_INVALID_PARAM.2050 = Type your password in the Password field. # UserRegistrationUpdateForm.jsp _ERR_AUTHENTICATION_MINIMUMLENGTH_PASSWORD.2200 = The password you have entered contains fewer than {0} characters. Ensure that your password is at least {0} characters in length, including {1} digit(s) and {2} letter(s), and try again.The following is an example of the StoreErrorDataBean use:
<wcbase:useBean id="storeError" classname="com.ibm.commerce.common.beans.StoreErrorDataBean" scope="page"> <c:set target="${storeError}" property="resourceBundleName" value="${sdb.jspStoreDir}/storeErrorMessages" /> </wcbase:useBean> <c:if test="${!empty storeError.key}"> <c:set var="errorMessage" value="${storeError.message}" /> </c:if>Related concepts
Command error handling
WebSphere Commerce data beans
WebSphere Commerce framework overviewRelated tasks
Change store pagesRelated reference
JSP programming best practice: Use the Commerce-specific tag for bean activation
WebSphere Commerce JSP programming best practices