Feature Pack 6 or later

Creating a serialization JSP file to transform URL information for in-context preview

Create a serialization JSP file to retrieve authoring elements from database tables for your new object and display these elements in Store preview. The serialization JSP file formats nouns that are received from a controller JSP file into the XML format that is required by the Management Center framework to populate the Store preview address.

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

A controller JSP sends the nouns from BOD responses to a serialization JSP file for XML formatting. The serialization JSP file is used to receive object properties from nouns, and transform this URL information to an expected format for use in the Management Center Store preview. The expected format is in the form:
<objects>
	<object>
		<alias>aliasName</alias>
		<url>objectURL</url>
	</object>
</objects>
aliasName
An alias of the page.
objectURL
The full URL of the page.

Procedure

  1. In the Enterprise Explorer view, expand LOBTools > WebContent > jsp > your_company_name > component_name.
  2. Right-click the component_name folder and select New > File.
  3. In the File name field, enter a name for the new JSP file, including the .jspf extension, and click Finish. To ensure consistency and to make customization simpler, consider following the naming convention as such: SerializeObjectNamePageSeoUrl.jspf.
    For example, for a recipe collection object, name the JSP file SerializeRecipeCollectionPageSeoUrl.jspf.
  4. Add the definitions for your object to the serialization JSP file.
    The following code is a sample serialization JSP file that transforms the catalog entry object URL information into XML:
    <jsp:useBean id="seoUrlKeywordList" class="java.util.HashMap" type="java.util.Map"/>
    <jsp:useBean id="seoPrefixUrlList" class="java.util.HashMap" type="java.util.Map"/>
    <jsp:useBean id="inheritedSeoUrlKeywordList" class="java.util.HashMap" type="java.util.Map"/>
    
    1
    <c:forEach var="seoURL" items="${catentry.SEOURL}">
    	<c:set var="inherited" value=""/>
    		
    	<c:if test="${seoURL.parentStoreIdentifier.uniqueID != currentStoreId}">
    		<c:set var="inherited" value="Inherited"/>
    	</c:if>
    	
    	<c:forEach var="seoURLKeyword" items="${seoURL.URLKeyword}">
    		<c:if test="${seoURLKeyword.language != null}">
    			<c:choose>
    				<c:when test="${inherited != '' }">
    					<c:if test="${seoURLKeyword.keyword != null && seoURLKeyword.keyword != ''}">
    						<c:set target="${inheritedSeoUrlKeywordList}" property="${seoURLKeyword.language}" 
    							value="${seoURLKeyword.keyword}"/>
    					</c:if>
    				</c:when>
    				<c:otherwise>
    					<c:if test="${seoURLKeyword.keyword != null && seoURLKeyword.keyword != ''}">
    						<c:set target="${seoUrlKeywordList}" property="${seoURLKeyword.language}" 
    							value="${seoURLKeyword.keyword}"/>
    					</c:if>
    					<c:if test="${seoURLKeyword.URLPrefix != null && seoURLKeyword.URLPrefix != ''}">
    						<c:set target="${seoPrefixUrlList}" property="${seoURLKeyword.language}" 
    						value="${seoURLKeyword.URLPrefix}"/>
    					</c:if>
    				</c:otherwise>
    			</c:choose>		
    		</c:if>
    	</c:forEach>
    </c:forEach>
    
    <c:set var="fullUrl" value=""/>
    <c:set var="urlKeyword" value=""/>
    
    2
    <c:forEach var="language" items="${supportedDataLangIds}">
    	<c:choose>
    		<c:when test="${(seoUrlKeywordList[language] != '' && seoUrlKeywordList[language] != null) 
    			&& seoPrefixUrlList[language] != ''}">
    			<c:set var="fullUrl" value="${fn:replace(seoPrefixUrlList[language],'$SEO:PRIMARYTOKEN$'
    				,seoUrlKeywordList[language])}"/>
    			<c:set var="urlKeyword" value="${seoUrlKeywordList[language]}"/>
    		</c:when>
    		<c:when test="${(seoUrlKeywordList[language] == '' || seoUrlKeywordList[language] == null) 
    			&& seoPrefixUrlList[language] != '' && !empty (inheritedSeoUrlKeywordList[language])}">
    			<c:choose>
    				<c:when test="${fn:contains(seoPrefixUrlList[language],'$SEO:STORETOKEN$')}">
    					<c:set var="isAssetStore" value="true"/>
    				</c:when>
    				<c:otherwise>
    					<c:set var="fullUrl" value="${fn:replace(seoPrefixUrlList[language],
    						'$SEO:PRIMARYTOKEN$',inheritedSeoUrlKeywordList[language])}"/>
    					<c:set var="urlKeyword" value="${inheritedSeoUrlKeywordList[language]}"/>
    				</c:otherwise>
    				</c:choose>
    		</c:when>
    		<c:otherwise>
    			<c:set var="fullUrl" value=""/>
    		</c:otherwise>
    	</c:choose>
    	<c:if test="${urlKeyword != '' && fullUrl != ''}">
    		<object>
    			<alias><wcf:cdata data="${storeName} - ${urlKeyword}"/></alias>  (xml tags useddby the getpreviewurlservice.
    			<url><wcf:cdata data="${fullUrl}"/></url>
    		</object>
    	</c:if>
    </c:forEach>
    • 1 The following code between the <c:for> tags processes the returned noun's SEO URL information to store the catalog entry object's URL prefix and keywords per language.
    • 2 The following code between the <c:for> tags processes each supported language of the store and constructs the fully qualified URL and alias of the catalog entry object into the store address representation for display in the Management Center Store Preview Options dialog.