Customizing controller configurations

If you are creating your own custom objects or tools in Management Center or customize existing objects and tools, you might need to define or extend Spring framework configurations. These configurations define how URL requests from Management Center map to controller classes and JSP files to handle the requests.

Before you begin

Determine the name of the URL request that you are mapping to a controller command. You need to specifiy this name as the value for the id attribute in your custom controller configuration. This name is defined in the object definition file where the object or view that is associated with the URL request is defined.
If you want to override the mapping for the search service that retrieves catalog entries for advanced search, the URL request name is defined within the FindAllCatalogEntriesSearchDefinition.xml search definition file.

<SearchService name="findAllCatalogEntries" url="/cmc/FindCatalogEntries-All">
  <ServiceParam name="storeId"/>
  <ServiceParam name="masterCatalogId"/> 
  <ServiceParam name="defaultLanguageId"/>
</SearchService>
The URL request name is in the value for the url attribute in the service definition. This value also includes the package name, /cmc. You need only the URL name portion of the url attribute value, which for this URL request is FindCatalogEntries-All. In the corresponding controller configuration for this URL request in the spring-ibm-catalog.xml configuration file, the value for the id attribute matches the value for the url attribute in the search service definition.

<bean id="/FindCatalogEntries-All" class="org.springframework.web.servlet.mvc.ParameterizableViewController">
  <property name="viewName" value="/jsp/commerce/catalog/restricted/FindAllCatalogEntries.jsp"/>
</bean>

Procedure

  1. Open IBM WebSphere Commerce Developer
  2. In the Enterprise Explorer view, expand LOBTools > WebContent > WEB-INF
  3. Open the spring-extension.xml file for editing.
  4. Complete one of the following procedures
    OptionDescription
    To override an existing configuration
    1. Open the spring-ibm-component.xml file that includes the configuration that you want to override.
    2. Locate and copy the controller configuration that you want to override for an object or view.
    3. Add your copied configuration into the spring-extension.xml file as a direct child element of the top-level <beans> element.
    To define a new configuration
    1. Within the spring-extension.xml file, add a <bean> element definition as a direct child element of the top-level <beans> element.
    2. Include an id attribute for your new <bean> and set the value to be the name for the URL service request.
  5. Set or change the value for the class attribute.
    This attribute identifies the controller class that is to be used to process the request.

    For example, the class com.ibm.commerce.foundation.client.facade.bod.servlet.spring.BusinessObjectDocumentController is used to transfer objects between Management Center and WebSphere Commerce nouns. If you need to transfer objects, such within change or process BOD service requests, include this class in your configuration.

  6. Set or change any properties for the configuration within <property> elements.
    These properties define the information that can be passed to the controller about the URL request.
    For example, you can include properties to configure the following types of information to pass to the controller:
    • Information that identifies the URL object and the configuration parameters to be used to process the request.
    • Actions that need to be performed on the URL object, such as to create, change, or delete the object.
    • Response JSP files that need to be used to generate the XML-formatted response to return to Management Center. If your URL request expects a different view based on the results of processing the action that is associated with the request, you can include differnet properties for each expected view. For example, you can have a successView and failureView property with each property value identifying the appropriate JSP.

    Each property must be defined within a separate <property> element. Each element must include the name attribute to identify the name of the property. You can include a value attribute to indicate the value for the property or include a <props> subelement to provide a list of parameters to pass to the controller for the property. You can include the parameters, such as the store ID, language ID, and catalog ID, as nested properties within the <props>element. Include each nested property as a separate <prop> subelement, with the format <prop key="name">value</prop>, where name is the name of the parameter and value is the value for the parameter.

    The following code snippet shows an example of a <property> element with a value and a <property> element with a list of <prop> subelements.

    
    <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"/>
  7. Save and close the file.

Example

The following sample code snippets show Spring controller configurations that includes properties for configuring a change BOD service and for configuring 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>