Customizing controller configurations
Before you begin
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.
<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
- Open HCL Commerce Developer
- In the Enterprise Explorer view, expand
- Open the spring-extension.xml file for editing.
-
Complete one of the following procedures
Option Description To override an existing configuration - Open the spring-ibm-component.xml file that includes the configuration that you want to override.
- Locate and copy the controller configuration that you want to override for an object or view.
- 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 - Within the spring-extension.xml file, add a
<bean>
element definition as a direct child element of the top-level<beans>
element. - Include an
id
attribute for your new<bean>
and set the value to be the name for the URL service request.
-
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 HCL Commerce nouns. If you need to transfer objects, such within change or process BOD service requests, include this class in your configuration. -
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 different properties for
each expected view. For example, you can have a
successView
andfailureView
property with each property value identifying the appropriate JSP.
Each property must be defined within a separate
<property>
element. Each element must include thename
attribute to identify the name of the property. You can include avalue
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>
, wherename
is the name of the parameter andvalue
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"/> - Save and close the file.
Example
- 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>