Adding the Madisons store error message properties files as a Struts

In this lesson, you learn to add the error message properties files as a Strut.

About this task

For the Validator framework to be able to retrieve error messages from the Madisons store error message properties files, you must configure the latter as a Struts message resource:

Procedure

  1. Open the struts-config-ext.xml file for editing if it is not already opened.
  2. Switch to the Message Resources page of the editor.
  3. In the Message Resources section, click Add. Type Madisons/storeErrorMessages.
  4. In the Message Resource attributes section, add the following information:
    1. In the Factory field, type com.ibm.commerce.struts.messages.WCPropertyMessageResourcesFactory.
    2. In the Key field, type Madisons_errors.
    3. Select the Null check box.
  5. In the Message Resource Mapping Extensions section:
    1. Click Add.
    2. In the Property field, type additionalProperties.
    3. In the Value field, paste the value of the additionalProperties property from the Store module struts-config.xml file as follows:
      1. Navigate to Stores > WebContent > WEB-INF.
      2. Right-click the struts-config.xml file and select Open With > Struts Configuration File Editor.
      3. Click the Message Resources tab.
      4. In the Message Resources section, select com.ibm.strutsstore.resources.ApplicationResources.
      5. In the Message Resource Mapping Extensions section, select the entry for the additionalProperties property.
      6. Click the corresponding entry in the Value column, right-click it, and select Copy.
      7. Switch back to the editor of the struts-config-ext.xml file.
      8. Click the highlighted entry in the Value column, right-click it, and select Paste.
    4. In the Class Name field, type com.ibm.commerce.struts.messages.WCMessageResourcesConfig as the class.
  6. Switch to the Source view and verify that you see the following element near the bottom of the view:
    
    <message-resources parameter="Madisons/storeErrorMessages">
           
    className="com.ibm.commerce.struts.messages.WCMessageResourcesConfig">
           
    factory="com.ibm.commerce.struts.messages.WCPropertyMessageResourcesFactory">
            key="Madisons_errors" null="true">
      <set-property property="additionalProperties" 
                   
    value="com.ibm.commerce.ras.properties.ecServerMessages, ... "/>
    </message-resources>
    
  7. Ensure that the MyContactUsDisplay.jsp calls the correct key element that you created in step 4b.
    1. Navigate to Stores > WebContent > Madisons > StoreInfoArea and open MyContactUsDisplay.jsp.
    2. Search for the code:
      <html:errors bundle="
      Ensure that the bundle variable is set to Madisons_errors like the following code:
      <html:errors bundle="Madisons_errors"/>
  8. Save your changes.