You must create and register a serialization
JSP file to transform server versioned objects into XML that Management
Center understands. When you extend content versioning in a business
object, you want to display the versions in the Management Center
user interface.
When you view the versions in the Version
tab, the GetContentVersion service is called, and this service calls
the serialization JSP to retrieve and display the versioned business
objects.
When you extend content versioning for additional business
objects, you must create a new serialization JSP file and register
this serialization JSP file in the Struts configuration for customization,
struts-extension.xml
.
This file is initially empty and takes precedence over all Struts
configuration file.
Procedure
-
Open
WebSphere Commerce Developer and switch to the Enterprise Explorer
view.
-
Create a serialization JSP file.
-
Create a JSP file with this syntax:
GetVersioned
objectType_value
.jsp
;
where
objectType_value
is the object type of the
versioned object.
For example,
GetVersionedCatalogGroup.jsp
defines
the JSP fragment for CatalogGroup object type.
Ensure that you store
this JSP file in the same location as the other JSP files.
-
Define the new serialization JSP file. The following
code is a sample serialization JSP file for a CatalogGroup object
type.
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://commerce.ibm.com/foundation" prefix="wcf"%>
<wcf:getData type="com.ibm.commerce.catalog.facade.datatypes.CatalogGroupType[]"
var="category" expressionBuilder="getCatalogGroupDetailsByIDs" varShowVerb="showVerb">
<wcf:contextData name="storeId" data="${param.storeId}"/>
<wcf:contextData name="catalogId" data="${param.catalogId}"/>
<wcf:contextData name="versionId" data="${param.objectVersionId}"/>
<wcf:param name="UniqueID" value="${param.UniqueID}"/>
</wcf:getData>
<c:if test="${!(empty category)}">
1a
<c:set var="objectVersionId" value="${param.objectVersionId}" scope="request" />
1b
<c:set var="objectVersionNumber" value="${param.objectVersionNumber}" scope="request" />
<c:forEach var="catalogGroup" items="${category}">
<c:set var="childType" value="ChildCatalogGroup" />
<c:set var="objectType" value="CatalogGroup" />
<c:set var="owningStoreId" value="${catalogGroup.catalogGroupIdentifier.externalIdentifier.storeIdentifier.uniqueID}" />
<c:if test="${(param.storeId) != owningStoreId}">
<c:set var="childType" value="ChildInheritedCatalogGroup" />
<c:set var="objectType" value="InheritedCatalogGroup" />
</c:if>
<jsp:directive.include file="serialize/SerializeCatalogGroup.jspf"/>
</c:forEach>
</c:if>
The following describes the lines with numbered callouts:
-
1a-b
The
objectVersionId
and
objectVersionNumber
properties
must be included in your JSP file so that the framework knows if the
returned object is a version object or not.
- Optional:
If your serialization JSP already
includes
SerializeChangeControlMetaData.jsp
,
then set a variable in the
SerializeCatalogGroup.jspf
file.
Otherwise, complete the next step instead.
<object objectType="${objectType}">
<jsp:include page="/cmc/SerializeChangeControlMetaData" />
<catgroupId>
${catalogGroup.catalogGroupIdentifier.uniqueID}</catgroupId>
<qualifiedCatgroupId>
${owningCatalog}_${catalogGroup.catalogGroupIdentifier.uniqueID}</qualifiedCatgroupId>
<identifier>
<wcf:cdata data="${catalogGroup.catalogGroupIdentifier.externalIdentifier.groupIdentifier}"/>
</identifier>
<objectStoreId>
${catalogGroup.catalogGroupIdentifier.externalIdentifier.storeIdentifier.uniqueID}</objectStoreId>
<ownerId>
${catalogGroup.catalogGroupIdentifier.externalIdentifier.ownerID}</ownerId>
<owningCatalog>
${owningCatalog}</owningCatalog>
</object>
- Optional:
In the
Serialize
objectType_value
.jspf
file,
add the lines to retrieve the
objectVersionId
and
objectVersionNumber
if
they exist.
<object objectType="${objectType}">
<c:if test="${!empty objectVersionId}">
<objectVersionId>
${objectVersionId}</objectVersionId>
</c:if>
<c:if test="${!empty objectVersionNumber}">
<objectVersionNumber>
${objectVersionNumber}</objectVersionNumber>
</c:if>
<jsp:include page="/cmc/SerializeChangeControlMetaData" />
<catgroupId>
${catalogGroup.catalogGroupIdentifier.uniqueID}</catgroupId>
<qualifiedCatgroupId>
${owningCatalog}_${catalogGroup.catalogGroupIdentifier.uniqueID}</qualifiedCatgroupId>
<identifier>
<wcf:cdata data="${catalogGroup.catalogGroupIdentifier.externalIdentifier.groupIdentifier}"/>
</identifier>
<objectStoreId>
${catalogGroup.catalogGroupIdentifier.externalIdentifier.storeIdentifier.uniqueID}</objectStoreId>
<ownerId>
${catalogGroup.catalogGroupIdentifier.externalIdentifier.ownerID}</ownerId>
<owningCatalog>
${owningCatalog}</owningCatalog>
</object>
Both
<c:if>
elements must
be added to retrieve the
objectVersionId
and
objectVersionNumber
if
they exist
-
Save and close the new serialization JSP file
-
Register the serialization JSP in the struts action configuration
file.
-
Navigate to
.
-
Open the
struts-extension.xml
file
with a Struts configuration file editor.
-
Add a new action mapping:
-
Click the
ActionMappings
tab.
-
In the
Action Mappings
section, click
Add
.
-
Under
The following Action Mappings are defined for
this config file
, you see
/action1
, type
your new GetVersioned
objectType_value
, for example,
the one for CatalogGroup is GetVersionedCatalogGroup
-
In the
Action Mapping attributes
section,
select
Include
, and then type the new
GetVersioned
objectType_value
.jsp
.
For example, the one for CatalogGroup looks like
/jsp/commerce/catalog/restricted/GetVersionedCatalogGroup.jsp
-
Save the
struts-extension.xml
configuration
file.
-
To verify your updates, view the source of the
struts-extension.xml
configuration
file and ensure that you see the code you added. For example, here
is the one for CatalogGroup object.
<action path="/GetVersionedCatalogGroup" include= "/jsp/commerce/catalog/restricted/GetVersionedCatalogGroup.jsp"/>
-
Restart the WebSphere Commerce test server to make the
new configuration available.