Defining WebSphere Commerce error message resources: message-resources

Retrieving error messages, accomplished in earlier versions of WebSphere Commerce using the StoreErrorDataBean, can also be accomplished in the WebSphere Commerce Struts-based Web application with the Struts declarative exception handling framework. This framework relies on property message resources (resource bundles) defined in properties files and configured in the Struts configuration files using message-resources elements.

Procedure

Select an appropriate method:
  • If your site has only one store or all your stores share the same error messages, configure your message resources as follows:
    
    <message-resources factory="com.ibm.commerce.struts.messages.WCPropertyMessageResourcesFactory"
     key="org.apache.struts.action.MESSAGE" null="false" parameter="com.mycompany.properties.MySite"
     className="com.ibm.commerce.struts.messages.WCMessageResourcesConfig">
     <set-property property="additionalProperties" value="WebSphere Commerce properties files" />
    </message-resources>
    

    Where:

    com.mycompany.properties.MySite.properties
    The site-wide properties file, which will be searched first. It should be placed into the WEB-INF/classes subdirectory of your Stores Web module.
    WebSphere Commerce properties files
    A comma-separated list of the names of component properties files, without the .properties extension, such as com.ibm.commerce.ras.properties.ecServerMessages, com.ibm.commerce.catalog.ras.properties.WcCatalogUserMessages, com.ibm.commerce.pa.ras.properties.WcPAUserMessages. Copy this list in its entirety from your Web module's struts-config.xml file.

    Note also the WebSphere Commerce-specific values of the factory and className attributes.

  • If your site has multiple stores that do not share the same error messages but want to use messages supplied by WebSphere Commerce by default (that is, if they decide not to override a particular message), configure your message resources as follows:
    
    <message-resources factory="com.ibm.commerce.struts.messages.WCPropertyMessageResourcesFactory"
     key="org.apache.struts.action.MESSAGE" null="false"  parameter="" 
     className="com.ibm.commerce.struts.messages.WCMessageResourcesConfig">
      <set-property property="additionalProperties" value="WebSphere Commerce properties files" />
    </message-resources>
    
    
    <message-resources factory="com.ibm.commerce.struts.messages.WCPropertyMessageResourcesFactory" 
     key="myStore" null="false" parameter="com.mycompany.properties.MyStore"
     className="com.ibm.commerce.struts.messages.WCMessageResourcesConfig">
      <set-property property="additionalProperties" value="WebSphere Commerce properties files" />
    </message-resources>
    
    Where:
    • com.mycompany.properties.MyStore .properties is the store-specific properties file, which will be searched first.
    • The first message-resources element defines the site-wide resources that will be used if no key value is provided on the JSP page.