Defining process services for a custom WebSphere Commerce object

When you are creating a custom object that can be managed in WebSphere Commerce, you need to defining the authoring services for the object, such as the services to create, save, update, and delete the object. To create these services, you need to define the URL parameter mapping to the noun in the BOD request. Then, you need to define the controller configuration in the Spring framework to indicate the verb and the processing information.

Procedure

  1. Open IBM WebSphere Commerce Developer.
  2. In the Enterprise Explorer view, expand LOBTools > WebContent > WEB-INF > config > com.mycompany.commerce.component-ext, where mycompany is the name of your company and component is the name of the component for the object that you want to map to an error code.
    If the com.mycompany.commerce.component-ext directory does not exist, you must create this directory.
  3. Open your custom wc-component-clientobjects-ext.xml configuration file, where component is the name of the object componet, such as wc-catalog-clientobjects-ext.xml. If the file does not exist, you must create the file. Use the file that is provided by WebSphere Commerce for the component as a model for creating your file.
  4. Within this file, you must define the mapping between the noun elements and the properties for the Management Center object that your service must process.
    • In the <_config:NounDefinitions> element, add the noun by including a <_config:Noun> element to the list of noun definitions. If this noun has any parts that can be modified, indicate those parts in <_config:NounElement> subelements and specify the part attribute as "true".
    • In the <_config:URLDefinitions> element, add the mapping of the object to the noun within a <_config:URLParameterGroup> element. For each property of the Management Center object, specify the XPath location of the noun that property represents. If the object has a UserData property that needs to be mapped, the value for the name must begin with the x prefix.
    • In the ValidationErrorMapping element, specify the resource bundle that is used to override the error messages returned by the server. A mapping of validation reason codes can be mapped to properties of the each Management Center object.
  5. Save and close the file.
  6. Expand LOBTools > WebContent > WEB-INF.
  7. Open the spring-extension.xml file for editing. Your configurations within this extension file override the configurations for the same services within the spring-ibm-component.xml files that are provided by WebSphere Commerce.
  8. Add your new XML file to the list of files that are specified in the config property of the BusinessObjectDocumentPlugin.
  9. Add controller configurations within <bean> elements for each authoring service that you want to support for the Management Center object. These configurations need to define the verb and the processing information that is required to invoke the business object document service.
    • If your object represents the noun, include the action codes "Create" and "Delete" for mapping the create and delete services to the process business object document request.
    • If your object represents a part of the noun, include the action codes "Add" and "Delete" for mapping the create and delete services to the change business object document request.
    • Include the action code "Change" for mapping all update services, which always map to the change business object document.
    The following sample code snippets show configurations for a change BOD service and a process BOD service.
    • Change BOD
      
      <bean id="/CreateCatalogEntryDescription" class="com.ibm.commerce.foundation.client.facade.bod.servlet.spring.BusinessObjectDocumentController">
        <property name="urlObject" value="CatalogEntryDescription"/>
        <property name="contextParameters">
          <props>
            <prop key="storeId">storeId</prop>
            <prop key="langId">langId</prop>
            <prop key="masterCatalogId">catalogId</prop>
          </props>
        </property>
        <property name="verb" value="Change"/>
        <property name="documentRootFactory" value="com.ibm.commerce.catalog.facade.datatypes.CatalogFactory"/>
        <property name="clientLibrary" value="com.ibm.commerce.catalog.facade.client.CatalogFacadeClient"/>
        <property name="clientLibraryMethod" value="changeCatalogEntry"/>
        <property name="actionCode" value="Change"/>
      </bean>
    • Process BOD
      	
      <bean id="/CreateCatalogEntry" class="com.ibm.commerce.foundation.client.facade.bod.servlet.spring.BusinessObjectDocumentController">
        <property name="urlObject" value="CatalogEntry"/>
        <property name="contextParameters">
          <props>
            <prop key="storeId">storeId</prop>
            <prop key="langId">langId</prop>
            <prop key="masterCatalogId">catalogId</prop>
          </props>
        </property>
        <property name="verb" value="Process"/>
        <property name="documentRootFactory" value="com.ibm.commerce.catalog.facade.datatypes.CatalogFactory"/>
        <property name="clientLibrary" value="com.ibm.commerce.catalog.facade.client.CatalogFacadeClient"/>
        <property name="clientLibraryMethod" value="processCatalogEntry"/>
        <property name="actionCode" value="Create"/>
        <property name="var" value="catalogEntries"/>
        <property name="successView" value="/jsp/commerce/catalog/restricted/RespondCreateCatalogEntry.jsp"/>
      </bean>
  10. Save and close the file.
  11. Restart your WebSphere Commerce Test Server and test your changes.