Content Management Guide

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Delivering Content Within Your Portal

When developing your portal, you use JSP tags, the content API and personalization tools to search for and display content to your portal users.

Retrieving and displaying content is typically done within the context of a JSP page. Within a JSP page, you can use the API directly, a JSP tag, or use content selectors or placeholders to retrieve content based on queries or rules.

You can use content selectors and campaigns deliver personalized content to user based upon personalization rules or conditions. Within this context, you use JSP tags to retrieve the content you need.

For more information about delivering personalized content, see the WebLogic Portal Interaction Management Guide.

This chapter includes the following sections:

 


Working with JSP Tags

WebLogic Portal provides JSP tags that can be used to both retrieve and display content.

Retrieving content or searching for the content is typically done within the context of a JSP page. You can also retrieve content using the content API.

This section includes the following topics:

Retrieving Content with JSP Tags

There are four content-specific JSP tags that can be used to retrieve content. For more information about JSP tags, see the JSP Javadoc for Content Managment. Table 10-1 lists the content-related JSP tags.

Table 10-1 Content JSP Tags
JSP Tag
Usage
<cm:getNode>
Retrieves a content node and stores the node in a variable.
<cm:search>
Searches for and retrieves content nodes based on a supplied query and stores the results in a variable.
<cm:getProperty>
Retrieves a property value from a content node and stores it as a variable or prints it in the JSP.
<cm:getBinaryProperty>
Retrieves a binary property associated with a content node.

Regardless of which tag you decide to use, retrieving for content within a JSP tag is done using one of two methods:

Retrieving Content Using a Repository Path

All content is addressable by a unique path. This path is visible in the Portal Administration Console as you create folders and content. Within the <cm:getNode> JSP tag, you can specify the repository path to retrieve content. For example, if your content hierarchy appears in the Portal Administration Console as shown in Figure 10-1, you could use the code in Listing 10-1 to retrieve CarPic.

Figure 10-1 Content Hierarchy

Content Hierarchy

Listing 10-1 Sample Code for Retrieving CarPic
<%@ taglib uri="content.tld" prefix="cm"%>
<cm:getNode path="/BEA Repository/Dev2Dev/CarPic" id="carpic" />

Using Queries to Retrieve Content

You can also use queries to retrieve content. For more information about creating queries, see Building a Content Query with Expressions in the Interaction Management Guide.

 


Displaying Content with JSP Tags

After retrieving content, you need to decide how you will display it within the portal. Displaying content can be done using JSP tags and with personalization tools such as content selectors and placeholders. This section discusses JSP tags and provides some examples. For more information about personalizing content, see the Interaction Management Guide.

This section provides an overview of JSP tags you can use to display content.

Content Display JSP Tags

Content can be displayed in your portal using the tags listed in Table 10-2, JSP Tags Used to Display Content, on page 10-5. For a complete reference for the tags listed, see the JSP Javadoc for Content Management.

Table 10-2 JSP Tags Used to Display Content
JSP Tag
Description
<ad:adTarget>
Uses the Ad Service to send an ad query to the content management system.
<ad:render>
Renders a content node from the Virtual Content Repository in the current JSP.
<ph:placeholder>
Displays personalized web content in a JSP based on Placeholder and Campaign rules and queries that have been defined.
<pz:contentQuery>
Performs a content attribute search in a content management system and returns an array of content objects.
<pz:contentSelector>
Implements a Content Selector that has been defined using Workshop for WebLogic. Displays personalized Web content in a JSP based on Content Selector rules and queries defined.
<pz:div>
Allows a piece of in-line content to be shown if a user belongs to the specific User Segment defined with Workshop for WebLogic.
<dt:displaytemplate>
Requests the registered view for a resource, which in turn renders it in the JSP.
In order to use this tag, you must create display templates (views) and a mapping file (XML) to use templates with respective content types. For more information about setting up templates, see Displaying Content with Display Templates.
<dt: displaycmtemplate>
Requests the registered view for a content management resource, which in turn renders it in the JSP.
In order to use this tag, you must create display templates (views) and a mapping file (XML) to use templates with respective content types. For more information about setting up templates, see Displaying Content with Display Templates.

 


Displaying Content with Display Templates

Display templates allow you to create views for content according to content type. You can create a default view based on a content type or you can create multiple views for that content type. For example, you can create a “thumbnail” view for an image as well as a view that displays the full-size image and a list of properties such as the price (if it is merchandise) or an address (if the image is an employee directory). You can set up display templates for any content type within your repository.

Views are based on JSPs that you create. Views are then defined in a configuration file that you create. After creating views and mapping them to a configuration file (XML), you can refer to those views (display templates) with a display template tag.

WebLogic Portal provides two types of display template tags. The <dt:displaycmtemplate> is provided to use to display resources from your content management system. The <dt:displaytemplate> tag should be used to display any other portal resources.

These tags are part of the wlp-services-web-lib.war which can be found in the //WebLogic_Home/portal/lib/modules directory.

This section includes the following topics:

Creating Views to Use with your Display Template

Views or templates are simply JSP pages that can be used to display associated resources. These pages can incorporate any JSP functionality you require.

As a best practice, it can be helpful to store all display templates in the same directory within your web application.

Creating a wlp-template-config.xml File

Before you can use a display template, you must create a configuration file that associates the views (JSP pages) you have created with the respective resources. For example, if you have created a view to use with a content type, you must configure that relationship using a wlp-template-config.xml file.

Listing 10-2 provides an commented outline of the wlp-template-config.xml schema.

Listing 10-2 wlp-template-config.xml
<wlp-display-template> 
<!-- Describes the content repository’s types and templates --> 
<content-repository>
	<!-- Allows you to use a namespace to define multiple repositories if needed -->
	<content-name-space>
	<!-- Name of repository. (Required) --> 
	<name> </name> 
	<!-- Description for developer use, not shown to end user (Optional) --> 
	<description> </description> 
	<!-- If only the repository that matches this template is used to render content (Optional) --> 
	<default-template-uri> </default-template-uri> 
	<! -- Optionally, define a namespace to reference a content-resource --!>
	<namespace></namespace>
	<!-- Describes the content type (Optional) --> 
	<content-resource> 
	<!-- Description not shown to end user (Optional) --> 
	<description> </description> 
	<!-- Name of content type.(Required) --> 
	<name> </name> 
	<!-- If only the content type matches this template is used to render content (Optional) --> 
	<default-template-uri> </default-template-uri> 
		<!-- Describes the view (Optional) --> 
		<view> 
		<!-- Name of the view (Required) --> 
		<name> </name> 
		<!-- Description not shown to end user (Optional) --> 
		<description> </description> 
		<!-- If the view name matches this template is used to render content (Required) --> 
		<uri> </uri> 
		</view> 
	</content-resource> 
</content-name-space>
</content-repository> 
<!-- Describes templates that are not linked to a content repository in any way --> 
<template-group> 
<!-- Allows you to use namespaces if you want to define more than one template group --!>
<template-name-space>
<name> </name> 
<description> </description> 
<default-template-uri> </default-template-uri> 
<template> 
	<description> </description> 
<!-- Name of template. (Required) --> 
	<name> </name> 
	<default-template-uri> </default-template-uri> 
	<!-- Optionally, specific a preview icon for this template --!>>
	<default-template-preview-icon-uri> </default-template-preview-icon-uri>
		<view> 
		<name> </name> 
		<description> </description> 
		<uri> </uri> 
		<!--Optionally, specify a preview icon for this view --!>
		<preview-icon-url></preview-icon-url>
		</view> 
	</template> 
</template-name-space>
</template-group> 
</wlp-display-template> 

Table 10-3 provides an example of a valid wlp-template-config.xml file.

Listing 10-3 Sample wlp-template-config.xml Document
<wlp-display-template> 
<content-repository> 
<name>MyRepo</name> 
<default-template-uri>/MyDefault.jsp </default-template-uri> 
	<content-resource> 
		<name>thumbnail</name> 
		<view> 
			<name>small</name> 
			<uri>/smallview.jsp</uri> 
		</view> 
	</content-resource> 
	<content-resource> 
		<name>Product </name> 
		<default-template-uri>/MyProductDisplay.jsp</default-template-uri> 
	<view> 
		<name>small</name> 
		<uri>/product/smallview.jsp</uri> 
	</view> 
</content-resource> 
<content-resource> 
	<name>Camera </name> 	<default-template-uri>/MyCameraProductDisplay.jsp</default-template-uri> 
	<view> 
		<name>small</name> 
		<uri>/product/camera/smallview.jsp</uri> 
	</view> 
</content-resource> 
</content-repository> 
</wlp-display-template>

Using the <dt:displaycmtemplate> Within a JSP

The <dt:displaycmtemplate> is used to display resources from your content management system. See the Commerce and Interaction Management JSP Tag Javadoc for more information about this tag and its attributes.

<dt:displaycmtemplate> Example

This example displays a content type of DigitalCamera which extends Camera which extends Product. See <dt:displaycmtemplate> Example Using Type Inheritance for an example of how the tag takes advantage of type inheritance.

This example includes three parts. Listing 10-4 shows an example JSP usage that uses a defined view while Listing 10-5 shows an example usage that uses the default view. Listing 10-6 provides the corresponding configuration file.

Tip: You can define a default view within your configuration file that is used for all content resources that do not have otherwise defined display templates. You do this by defining a content resource with a * as a value. For example, <name>*<name>. See Listing 10-6 for an example. You can also use a * as <name> for the content-repository element.
Listing 10-4 <dt:displaycmtemplate> Tag Usage
<dt:displaycmtemplate repositoryName="MyRepo" resourceName="DigitalCamera" view="small"/> 
Listing 10-5 <dt:displaycmtemplate> Tag Usage
<dt:displaycmtemplate repositoryName="MyRepo" resourceName="Car" view="small"/>
Listing 10-6 Corresponding wlp-template-config.xml
<wlp-display-template> 
<content-repository> 
<name>MyRepo</name> 
<default-template-uri>/MyDefault.jsp </default-template-uri>
<content-resource> 
	<name>*</name>
<!-- Using an * in the name element defines a default view for content resources --!>
	<view>
		<name>small</name>
		<uri>/smallview.jsp</uri>
	</view>
</content-resource>
<content-resource> 
	<name>Product</name> 
	<default-template-uri>/MyProductDisplay.jsp</default-template-uri> 
	<view> 
		<name>small</name> 
		<uri>/product/smallview.jsp</uri> 
	</view> 
</content-resource> 
<content-resource> 
	<name>Camera </name> 
	<default-template-uri>/MyCameraProductDisplay.jsp</default-template-uri>
	<view> 
		<name>small</name> 
		<uri>/product/camera/smallview.jsp</uri> 
	</view> 
</content-resource> 
</content-repository> 
</wlp-display-template> 
<!-- With this configuration the uri of "product/camera/smallview.jsp" will be found. This is because a Digital Camera is a Camera and the camera resource has a small view. -->

<dt:displaycmtemplate> Example Using Type Inheritance

This example displays a content type of DigitalCamera which extends Camera which extends Product. Notice that the tag leverages type inheritance when searching for which view to use.

This example includes two parts. Listing 10-7 shows the syntax of the JSP tag and Listing 10-8 provides the corresponding configuration file.

Listing 10-7 <dt:displaycmtemplate> Tag Usage
<dt:displaycmtemplate repositoryName="MyRepo" resourceName="DigitalCamera" view="full"/> 
Listing 10-8 Corresponding wlp-template-config.xml
<wlp-display-template> 
<content-repository> 
<name>MyRepo</name> 
<default-template-uri>/MyDefault.jsp </default-template-uri> 
<content-resource> 
	<name>Product </name> 
	<default-template-uri>/MyProductDisplay.jsp</default-template-uri> 
	<view> 
		<name>small</name> 
		<uri>/product/smallview.jsp</uri> 
	</view> 
	<view> 
		<name>full</name> 
		<uri>/product/fullview.jsp</uri> 
	</view> 
</content-resource> 
<content-resource> 
	<name>Camera </name> 
	<default-template-uri>/MyCameraProductDisplay.jsp</default-template-uri>
	<view> 
		<name>small</name> 
		<uri>/product/camera/smallview.jsp</uri> 
	</view> 
</content-resource> 
</content-repository> 
</wlp-display-template> 
<!-- With this configuration the uri of "product/fullview.jsp" will be found. This is the JSP tag takes advantage of type inheritance and knows that camera inherits from product. -->

Using the <dt:displaytemplate> Tag Within a JSP

The <dt:displaytemplate> tag should be used to display any non-content management portal resources. See the Commerce and Interaction Management JSP Tag Javadoc for more information about this tag and its attributes.

 


Displaying Content with the Content Presenter Portlet

WebLogic Portal provides a content presenter portlet that can be used to preview content. For more information about the content presenter portlet, see “ Using the Content Presenter Portlet” in the Portlet Development Guide.


  Back to Top       Previous  Next