Displaying the server side error message
In this step, you will map the server side error
message to the client side property to display the error message.
About this task
Procedure
- Change the validation error mapping.
- In the Enterprise Explorer view, expand LOBTools > WebContent > WEB-INF > config.
- Right-click config; then click New > Folder. In the Name field, type com.ibm.commerce.marketing-ext and click Finish.
- Right-click com.ibm.commerce.marketing-ext and select New > File. In the Name field, type wc-marketing-clientobjects-ext.xmland click Finish.
- Add the following XML content into the wc-marketing-clientobjects-ext.xml file.
Notes:
- 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 . - 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>
- The other parts are copied from com.ibm.commerce.marketing\wc-marketing-clientobjects.xml
and you only need to add
- Click Save to save the changes.
- 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, you need to add the file path into the plug-in section of structs-config
file.
- Navigate toLOBTools > WebContent > WEB-INF.
- 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>
Note: 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. - Select File > Save all to save the changes.
- 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.
- Select Project > Build all to build all projects.