Tutorials > Management Center > Add a validation rule in the Marketing tool

< Previous | Next >


Display the server side error message

In this step, we will map the server side error message to the client side property to display the error message.

In the previous step, you implemented the validate method of the new mediator and defined an error message in the server side. When server validate fails, the error message will be returned to the OpenLaszlo side.

To display the server side error message, you must change the validationError mapping and Struts configuration files.


Procedure

  1. Change the validation error mapping.

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

    2. Right-click config; then click New > Folder. In the Name field, type com.ibm.commerce.marketing-ext and click Finish.

    3. Right-click com.ibm.commerce.marketing-ext and select New > File. In the Name field, type wc-marketing-clientobjects-ext.xmland click Finish.

    4. Add the following XML content into the wc-marketing-clientobjects-ext.xml file.

      Notes:

      1. The other parts are copied from com.ibm.commerce.marketing\wc-marketing-clientobjects.xml and you only need to add <_config:ReasonCodeParameterAssociation reasonCode="_APP_Marketingext_END_DATE_AFTER_START_DATE_Over10Days" parameterName ="enddate"/> for the customization validation error. The reasonCode must be same as the key in the properties file which was created in step 2. 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 tutorial, the _APP_Marketingext_END_DATE_AFTER_START_DATE_Over10Days error is displayed in the enddate property that is mentioned in the instruction 4 of Creating a properties file of the previous step of this tutorial. The other content is 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="Campaign">                
                  <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_CAMPAIGN_CAMPAIGN_NAME_ALREADY_EXISTS" 
                      parameterName="name"/>
                  <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_CAMPAIGN_CAMPAIGN_NAME_EMPTY"
                      parameterName="name"/>
              </_config:ErrorGroup>    
              <_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:ErrorGroup name="EmailTemplate">                
                  <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_EMAILTEMPLATE_EMAILTEMPLATE_ALREADY_EXISTS" 
                      parameterName="name"/>
                  <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_EMAILTEMPLATE_EMAILTEMPLATE_NAME_EMPTY" 
                      parameterName="name"/>
                  <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_EMAILTEMPLATE_EMAILTEMPLATE_SUBJECT_EMPTY" 
                      parameterName="subject"/>
                  <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_EMAILTEMPLATE_EMAILTEMPLATE_CONTENT_EMPTY" 
                      parameterName="body"/>                                
                  <_config:ReasonCodeParameterAssociation 
                      reasonCode="_APP_EMAILTEMPLATE_EMAILTEMPLATE_ASSOCIATED_WITH_ACTIVITY"/>
              </_config:ErrorGroup>    
          </_config:ErrorDefinitions>
      </_config:URLtoOAGIS>     
      

    5. Click Save to save the changes.

  2. Change the Struts configuration.

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

    To use the wc-marketing-clientobjects-ext.xml file, add the file path into the plug-in section of structs-config 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 expansion point for Struts.

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

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

    4. Navigate to LOBTools. Right-click LOBTools; then click Properties. In the Properties window, select OpenLaszlo Settings. In the Compiler Settings page, clear Enable the debug console. Click OK.

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

< Previous | Next >


+

Search Tips   |   Advanced Search