For in-context preview to function properly for your business object, ensure
that the URL information is returned as part of the object. One way to retrieve URL information is
to create a custom controller JSP file to work with a serialization JSP file to transform HCL Commerce services nouns into XML for display in the Management Center. The controller JSP
sends the nouns from BOD responses to a serialization JSP file for XML formatting.
Note: Creating a serialization
JSP file is only one of many ways to transform URL information into
XML. You might have custom services or methods to transform URL information.
For example, if you have a custom wcf url tag that can return URL
information in the expected format, a serialization JSP file is not
required. You can implement the url
tag in the controller JSP file.
About this task
When a business user is working on an object and launches store preview, a call is made
to retrieve the URL information of the object. To retrieve the in-context preview URL information,
the URL information must be in the XML format that is required by Management Center. To
transform this URL information to the XML format, a controller JSP and serialization JSP file are
required. The controller JSP determines how to handle the transformation request and sends the
content to the correct serialization JSP file. The serialization JSP file is used to receive object
properties from Nouns, and transform this URL information for use in the Management Center
store preview.
When the call to retrieve URL information occurs, the controller JSP invokes
the wcf:getData
tag library to retrieve the noun that is used for the Management Center object. In the wcf:getData
tag, the
expressionBuilder parameter defines the query template to run. The query
template is mapped to the SQL statement that retrieves the data. For more information, see Management Center Web application.
Procedure
-
Create a controller JSP file.
-
In the Enterprise explorer view, expand . Create the directory structure if it does not exist.
-
Right-click the component_name directory; then select .
-
In the File name field, enter a name for the new controller JSP file
that follows this format: GetObjectNamePageSeoUrl.jsp.
For example, for a recipe collection object, name the JSP file
GetRecipeCollectionPageSeoUrl.jsp.
-
Click Finish.
-
Develop the code for your controller JSP file.
Ensure that in the controller JSP file, you define the
wcf:getData
tag to
retrieve the noun for the new
Management Center object from the
HCL Commerce
services. Within the
wcf:getData
tag, define the correct type of data that is to be
retrieved, and the correct expression builder. The expression builder is defined in the
get-data-config.xml file for the component and defines the query template to
run to retrieve URL information. The following code snippets are examples of expression builders
that are predefined for existing business objects that in-context preview supports.
- For catalog page-related
objects:
<wcf:getData type="com.ibm.commerce.catalog.facade.datatypes.CatalogGroupType[]"
var="category" expressionBuilder="getCatalogGroupSEOByID">
- For catalog entry page-related
objects:
<wcf:getData type="com.ibm.commerce.catalog.facade.datatypes.CatalogEntryType[]"
var="catalogEntry" expressionBuilder="getCatalogEntrySEOByID">
- For static page-related
objects:
<wcf:getData type="com.ibm.commerce.infrastructure.facade.datatypes.OnlineStoreType[]"
var="staticPagesSEO" expressionBuilder="findAllSEOStaticPageURLKeywordSummaryByStoreID">
-
Save and close the file.
-
Register the controller JSP file in the struts-extension.xml configuration
file.
-
In the Enterprise Explorer view, expand .
-
Perform one of the two following sets of steps depending on whether your HCL Commerce
version is 9.0.0.x or 9.0.1.x.
If you are using
HCL Commerce Version 9.0.0.x:
- Open the struts-extension.xml file in a text editor.
- In the
<action-mappings>
section, add an action mapping to register the
controller JSP file.<action path="pathName" forward="pathToJSP" />
- pathName
- A name that is used to map to the JSP file.
- pathToJSP
- The path to the JSP file, starting from .
- Save and close the struts-extension.xml file.
For example, to create a mapping to a JSP file that retrieves the URL for a recipe collection
page, add the following code to the
file:
<action path="/GetRecipeCollectionPageSeoUrl" forward="/jsp/your_company_name/component_name/GetRecipeCollectionPageSeoUrl.jsp" />
If you are using
HCL Commerce Version 9.0.1.x:
- Open the spring-extension.xml file in a text editor.
- In the
<beans>
section, add a bean mapping to register the controller JSP file.<bean id="beanName" class="org.springframework.web.servlet.mvc.ParameterizableViewController">
<property name="viewName" value="pathToJSP"/>
</bean>
- beanName
- A name that is used to map to the JSP file.
- pathToJSP
- The path to the JSP file, starting from .
For example, to create a mapping to a JSP file that retrieves the URL for a recipe
collection page, add the following code to the
file:<bean id="/GetRecipeCollectionPageSeoUrl" class="org.springframework.web.servlet.mvc.ParameterizableViewController">
<property name="viewName" value="/jsp/your_company_name/component_name/GetRecipeCollectionPageSeoUrl.jsp"/>
</bean>
- Save and close the spring-extension.xml file.
For example, to create a mapping to a JSP file that retrieves the URL for a recipe collection
page, add the following code to the file:
<bean id="/GetRecipeCollectionPageSeoUrl" class="org.springframework.web.servlet.mvc.ParameterizableViewController">
<property name="viewName" value="/jsp/your_company_name/component_name/GetRecipeCollectionPageSeoUrl.jsp"/>
</bean>