Develop > Controller layer > Management Center Web application > Customize the Management Center Web application


Display a server side error message in the Management Center

When server validation fails, an error message will be returned to the OpenLaszlo side.

To display the server side error message, assign or change the validationError mapping, and then register the mapping in the Struts configuration file.


Before you begin


Procedure

  1. Create an extension object definition file for the service module name (for example, marketing or catalog) you are working with, if it has not already been created:

    1. In the Enterprise Explorer view, expand LOBTools > WebContent > WEB-INF > config.

    2. Right-click the config folder and select New > Folder. In the Name field, type com.ibm.commerce.servicemodulename-ext and click Finish.

    3. Right-click com.ibm.commerce.servicemodulename-ext and select New > Other > Simple > File. In the Name field, type wc-servicemodulename-clientobjects-ext.xml and click Finish.

  2. Add or change the validation error mapping in the extension object definitions file:

    1. If the file is a new (empty) file, use the content from the base file as a template. The mapping must be contained in a <_config:ErrorGroup>, which is contained in a <_config:ErrorDefinitions> and so if you wish to use an existing error group, copy those elements to the new file as well. For example, the following sample XML shows an extension object definition file for the marketing component. The content was added from com.ibm.commerce.marketing/wc-marketing-clientobjects.xml.

      <_config:URLtoOAGIS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config ../xsd/url-to-oagis.xsd " 
      xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config">     
      <_config:ErrorDefinitions 
              primaryResourceBundle="com.ibm.commerce.marketing.client.lobtools.properties.MarketingLOBErrorMessages"
              alternateResourceBundle="extensions.com.ibm.commerce.marketing.client.lobtools.properties.MarketingLOBErrorMessages">        
              <_config:ErrorGroup name="Activity">                
                  <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_ACTIVITY_ACTIVITY_NAME_ALREADY_EXISTS" 
                      parameterName="name"/>             <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_ACTIVITY_ACTIVITY_NAME_EMPTY" 
                      parameterName="name"/>             <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_CAMPAIGN_INVALID_START_DATE" 
                      parameterName="startdate"/>             <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_CAMPAIGN_INVALID_END_DATE" 
                      parameterName="enddate"/>             <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_CAMPAIGN_END_DATE_AFTER_START_DATE" 
                      parameterName="enddate"/>             <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_ACTIVITY_ACTIVITY_MUST_BE_INACTIVE_TO_CHANGE"/>             <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_ACTIVITY_EMAIL_ACTIVITY_ALREADY_SENT"/>             <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_ACTIVITY_ACTIVITY_NOT_ACTIVATED"/>             <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_ELEMENT_EMARKETINGSPOT_NOT_FOUND"/>             <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_ELEMENT_PRODUCT_NOT_FOUND"/>             <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_ELEMENT_CATEGORY_NOT_FOUND"/>             <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_ELEMENT_CONTENT_NOT_FOUND"/>             <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_ELEMENT_SEGMENT_NOT_FOUND"/>             <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_ELEMENT_EMAIL_NOT_FOUND"/>             <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_ELEMENT_REFERRAL_NOT_FOUND"/>             <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_ELEMENT_STARTDATE_NOT_FOUND"/>             <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_ELEMENT_MERCHASSOC_NOT_FOUND"/>             <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_ELEMENT_ASSOC_ELEMENT_NOT_FOUND"/>             <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_ELEMENT_REPLYTO_NOT_FOUND"/>             <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_ELEMENT_DATA_NOT_FOUND"/>             <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_ELEMENT_NVP_NOT_FOUND"/>    
                  <_config:ReasonCodeParameterAssociation
                       reasonCode="_APP_Marketingext_END_DATE_AFTER_START_DATE_Over10Days" 
                       parameterName ="enddate"/>                
              </_config:ErrorGroup>    
          </_config:ErrorDefinitions>
      </_config:URLtoOAGIS>     
      

    2. Add the <_config:ReasonCodeParameterAssociation> element to the applicable <_config:ErrorGroup> element. For example, here is the element you would add for a marketing service module message:

      <_config:ReasonCodeParameterAssociation reasonCode="_APP_Marketingext_END_DATE_AFTER_START_DATE_Over10Days" parameterName ="enddate"/> 
      

      Notes:

      1. The reasonCode must be same as the key for the message you added to the properties file. The parameterName is the propertyName in propertiesView definition. For example, you can find the propertyName enddate in the definition of the class mktGeneralWebActivityProperties in WebActivityBuilder.lzx file .

      2. In this example, the _APP_Marketingext_END_DATE_AFTER_START_DATE_Over10Days error is displayed with the enddate parameter.

      3. When the object definition files are read by WebSphere Commerce, it is a merge operation, with the content in the extension files overriding default WebSphere Commerce files.

    3. Click Save to save the changes.

  3. Change the Struts configuration to register the object definition file:

    WebSphere Commerce provides an interface to extend the struts configuration. Extensions are added to the struts-extension.xml file.

    To use the our sample wc-marketing-clientobjects-ext.xml file, add the file path into the plug-in section of the struts-extension.xml file.

    1. Navigate toLOBTools > WebContent > WEB-INF.

    2. Open the struts-extension.xml file and add the following information before the tag </struts-config>.

      <plug-in className="com.ibm.commerce.foundation.client.facade.bod.servlet.struts.BusinessObjectDocumentPlugInImpl">         <set-property property="config"
                                     value="/WEB-INF/config/com.ibm.commerce.marketing/wc-marketing-clientobjects.xml,/WEB-INF/config/com.ibm.commerce.catalog/wc-catalog-clientobjects.xml,/WEB-INF/config/com.ibm.commerce.price/wc-price-clientobjects.xml,/WEB-INF/config/com.ibm.commerce.promotion/wc-promotion-clientobjects.xml,/WEB-INF/config/com.ibm.commerce.marketing-ext/wc-marketing-clientobjects-ext.xml" />     </plug-in>
      

      The struts-extension.xml is the extension point for Struts.

      To use the new validation error mapping, add the mapping file into the struts-extension.xml. Only the file WEB-INF/config/com.ibm.commerce.marketing-ext/wc-marketing-clientobjects-ext.xml is added, and the rest of the code comes from the plugin section of the struts-ibm-tools.xml file.

    3. Select File > Save all to save the changes.

    4. Navigate to LOBTools. Right-click LOBTools and select Properties. In the Properties window, select OpenLaszlo Settings. In the Compiler Settings panel, uncheck Enable the debug console.

    5. Click OK.

    6. Select Project > Build all to build all projects.


+

Search Tips   |   Advanced Search