BEA Logo BEA WebLogic Portal Release 4.0

  BEA Home  |  Events  |  Solutions  |  Partners  |  Products  |  Services  |  Download  |  Developer Center  |  WebSUPPORT

 

   WebLogic Portal Documentation   |   Building Personalized Applications   |   Previous Topic   |   Next Topic   |   Contents   |   Index

Working with Content Selectors

 

A content selector is one of several mechanisms that WebLogic Portal provides for retrieving documents from a content management system. A document is a graphic, a segment of HTML or plain text, or a file that must be viewed with a plug-in. (We recommend that you store most of your Web site's dynamic documents in a content management system because it offers an effective way to store and manage information.)

Using content selectors, a Business Analyst (BA) can specify conditions under which WebLogic Portal retrieves one or more documents. For example, a BA can use a content selector to encapsulate the following conditions: between May 1 and May 10, if a Gold Customer views this page, find and retrieve any documents that describe sailing along the Maine coast.

A Business Analyst uses the BEA E-Business Control Center to define the conditions that activate a content selector and to define the query the content selector uses to find and retrieve documents. Then, a Business Engineer (BE) uses content selector JSP tags and a set of other JSP tags to retrieve and display the content targeted by the content selector.

This topic includes the following sections:

For a comparison of content retrieval methods available with WebLogic Personalization Server, see Methods for Retrieving and Displaying Documents.

For a technical discussion of content management in the WebLogic Personalization Server, see the topic Creating and Managing Content in this guide.

 


What Are Content Selectors?

Content selectors consist of the following elements:

To display the documents that are in the array (or the cache), a BE must use the <es:forEachInArray> tag. Depending on the scope of the cache, a <es:forEachInArray> can access a content-selector cache that WebLogic Portal created for another page and/or for another user.

 


Using Content-Selector Tags and Associated JSP Tags

To use the content selector features on a given JSP, a BE must add calls to the content selector JSP tag and a set of associated tags.

This section contains the following subsections:

For more information about the tags discussed here, see the topic Personalization Server JSP Tag Library Reference in this guide.

Attributes of the <pz:contentSelector> Tag

While BAs use the E-Business Control Center to configure the dynamic properties of a content selector, a BE uses attributes of the content selector tag to do the following:

For a complete list and description of all content-selector attributes, see <pz:contentSelector> in the topic Personalization Server JSP Tag Library Reference in this guide.

Identify the Content Selector Definition

The content selector definition that a BA creates in the E-Business Control Center determines the conditions that activate a content selector and the query that the active content selector runs.

To refer to this definition, you use the rule attribute:

<pz:contentSelector rule= { definition-name | scriptlet } >

You can use a scriptlet to determine the value of the rule attribute based on additional criteria. For example, you use a content selector in a heading JSP (heading.inc), which is included in other JSPs. A BA creates different content selectors for each page that includes heading.inc.

The BE uses a scriptlet in heading.inc to provide a value based on the page that currently displays the included JSP file. For example,

<% 
   String banner = (String)pageContext.getAttribute("bannerPh");
banner = (banner == null) ? "cs_top_generic" : banner;
%>
<!-- ------------------------------------------------------------- -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="108">
  <tr><td rowspan="2" width="147" height="108">
<pz:contentSelector rule="<%= banner %>" ... />
</td>

Identify the JNDI Home for the Content Management System

The content selector tag must use the contentHome attribute to specify the JNDI home of the content management system. If you use the reference content management system or a third-party integration, you can use a scriptlet to refer to the default content home. Because the scriptlet uses the ContentHelper class, you must first use the following tag to import the class into the JSP:

<%@ page import="com.bea.p13n.content.ContentHelper"%>

Then, when you use the content selector tag, specify the contentHome as follows:

<pz:contentSelector
contentHome="<%=ContentHelper.DEF_DOCUMENT_MANAGER_HOME %>"
... />

If you create your own content management system, you must specify the JNDI home for your system instead of using the ContentHelper scriptlet. In addition, if your content management system provides a JNDI home, you can specify that one instead of using the ContentHelper scriptlet.

Define the Array That Contains Query Results

You can use the following attributes to configure the array that contains the results of the content-selector query:

Create and Configure the Cache to Improve Performance

To extend accessibility of retrieved content, and to improve performance, you can optionally use content-selector attributes to create and configure a cache that contains the array contents. Without the cache, you can access the content-selector array only from the current JSP page, and only for the customer request that created it. In addition, each time a customer requests a JSP that contains the content selector tag, the content selector must run the query, potentially slowing the overall performance of WebLogic Personalization Server. To cache the contents of the array, use the following attributes:

Associated Tags That Support Content Selectors

The following JSP tags support content-selector functions:

Common Uses of Content-Selector Tags and Associated Tags

The combination of content selector definitions, tag attributes, and associated JSP tags creates a powerful set of tools for matching documents to customers in specific contexts. The following tasks are the most common uses of content selectors and associated tags:

To Retrieve and Display Text-Type Documents

Note: This section assumes that the content selector query that the BA created in E-Business Control Center includes a filter to retrieve only text documents.

  1. Open a JSP in a text editor.

  2. Near the beginning of the JSP, add the following lines to import classes and tag libraries if they are not already in the JSP:

    <%@ page import="com.bea.p13n.content.ContentHelper"%>
    <%@ taglib uri="es.tld" prefix="es" %>
    <%@ taglib uri="pz.tld" prefix="pz" %>
    <%@ taglib uri="um.tld" prefix="um" %>

  3. Add the following tag to get the customer profile, if the tag is not already in the JSP:

    <um:getProfile>

    If the JSP already uses this tag for some other purpose, it probably includes other attributes. Make sure that the tag is closer to the beginning of the JSP than the <pz:contentSelector> tag, which you use in the next step.

  4. Add the following tags, where SpringSailing is the name of the content selector that a BA created in the E-Business Control Center:

    <pz:contentSelector rule="SpringSailing"
    contentHome="<%=ContentHelper.DEF_DOCUMENT_MANAGER_HOME %>"
    id="textDocs"/>
    <es:forEachInArray array="<%=textDocs%>" id="aTextDoc" type="com.bea.p13n.content.Content">

    <p><cm:printDoc id="aTextDoc"/></p>

    </es:forEachInArray>

    Note: The above tags assume that the content selector query that the BA created in the E-Business Control Center includes a filter to retrieve only text documents. To verify the content type before you display it, you can surround the <% "<P>" + aTextDoc + "</P>" %> scriptlet with another scriptlet. For example:

    <% if (aTextDoc.getMimeType().contains("text") != -1)
    {
    %>
    <p><cm:printDoc id="aTextDoc"/></p>
    <%
    }
    %>

  5. Save the JSP. If you deploy the Web application as a WAR file, re-jar the Web application and deploy it.

    WebLogic Portal deploys the modifications. If you specified a page-check rate for your Web application, WebLogic Portal waits for the page-check interval to expire before deploying any changes. For more information about setting the page-check interval, see the Performance Tuning Guide.

To Retrieve and Display Image-Type Documents

  1. Open a JSP in a text editor.

  2. Near the beginning of the JSP, add the following lines to import classes and tag libraries if they are not already in the JSP:

    <%@ page import="com.bea.p13n.content.ContentHelper"%>
    <%@ taglib uri="pz.tld" prefix="pz" %>
    <%@ taglib uri="um.tld" prefix="um" %>
    <%@ taglib uri="cm.tld" prefix="cm" %>

  3. Add the following tag to get the customer profile, if the tag is not already in the JSP:

    <um:getProfile>

    If the JSP already uses this tag for some other purpose, it probably includes other attributes. Make sure that the tag is closer to the beginning of the JSP than the <pz:contentSelector> tag, which you create in the next step.

  4. Add the following tags, where SpringSailing is the name of the content selector that a BA created in the E-Business Control Center:

    <pz:contentSelector rule="SpringSailing"
    contentHome="<%=ContentHelper.DEF_DOCUMENT_MANAGER_HOME %>"
    id="ImageDocs"/>

    <es:forEachInArray array="<%=ImageDocs%>" id="anImageDoc" type="com.bea.p13n.content.Content">

    <img src="ShowDoc/<cm:printProperty

    id="anImageDoc" name="identifier" encode="url"/>"

    </es:forEachInArray>

    Note: The above tags assume that the content selector query that the BA created in E-Business Control Center includes a filter to retrieve only image documents. To verify the content type before you display it, you can surround the <img> tag with a scriptlet. For example:

    <% if (anImageDoc .getMimeType().contains("image"))
    {
    %>
    <img src="ShowDoc/<cm:printProperty
    id="anImageDoc" name="identifier" encode="url"/>">
    }
    %>

  5. Save the JSP. If you deploy the Web application as a WAR file, re-jar the Web application and deploy it.

    WebLogic Portal deploys the modifications. If you specified a page-check rate for your Web application, WebLogic Portal waits for the page-check interval to expire before deploying any changes. For more information about setting the page-check interval, see the Performance Tuning Guide.

To Retrieve and Display a List of Documents

  1. Open a JSP in a text editor.

  2. Near the beginning of the JSP, add the following lines to import classes and tag libraries if they are not already in the JSP:

    <%@ page import="com.bea.p13n.content.ContentHelper"%> <%@ taglib uri="es.tld" prefix="es" %>
    <%@ taglib uri="pz.tld" prefix="pz" %>
    <%@ taglib uri="um.tld" prefix="um" %>

  3. Add the following tag to get the customer profile, if the tag is not already in the JSP:

    <um:getProfile>

    If the JSP already uses this tag for some other purpose, it probably includes other attributes. Make sure that the tag is closer to the beginning of the JSP than the <pz:contentSelector> tag, which you create in the next step.

  4. Add the following tags, where SpringSailing is the name of the content selector that a BA created in the E-Business Control Center:

    <pz:contentSelector rule="SpringSailing"
    contentHome="<%=ContentHelper.DEF_DOCUMENT_MANAGER_HOME %>"
    id="docs"/>

    <ul>
    <es:forEachInArray array="<%=docs%>" id="aDoc"
    type="com.bea.p13n.content.Content">

    <li>The document title is: <cm:printProperty id="aDoc"
    name="Title" encode="html" />

    </es:forEachInArray>

    </ul>

  5. Save the JSP. If you deploy the Web application as a WAR file, re-jar the Web application and deploy it.

    WebLogic Portal deploys the modifications. If you specified a page-check rate for your Web application, WebLogic Portal waits for the page-check interval to expire before deploying any changes. For more information about setting the page-check interval, see the Performance Tuning Guide.

To Access a Content-Selector Cache on a Different JSP

  1. In a text editor, open the JSP page that contains the content selector tag. For example, you want to cache the results of the following tag:
    <pz:contentSelector rule="SpringSailing" id="docs".../>

  2. Add attributes to the content selector tag as follows:

    <pz:contentSelector rule="SpringSailing"
    contentHome="<%=ContentHelper.DEF_DOCUMENT_MANAGER_HOME %>"
    id="docs"

    useCache="true" cacheId="SpringSailingDocs" cacheTimeout="120000"
    cacheScope="application" />

    These attributes create a cache that WebLogic Portal maintains for 2 minutes (120000 milliseconds) and that can be accessed using the name SpringSailingDocs by any user from any page in the Web application. For more information about possible values for cacheScope, see Create and Configure the Cache to Improve Performance.

  3. Save and deploy the JSP.

  4. In a text editor, open the JSP from which you want to access the cache.

  5. Use a content-selector tag that is identical to the tag you created in step 2. For example, on the current JSP, add the following tag:
    <pz:contentSelector rule="SpringSailing"
    contentHome="<%=ContentHelper.DEF_DOCUMENT_MANAGER_HOME %>"
    id="docs"

    useCache="true" cacheId="SpringSailingDocs" cacheTimeout="120000"
    cacheScope="application" />

  6. Save and deploy the JSP.

 


How Content Selectors Select Documents

When a user requests a JSP that contains a content selector tag, the following process occurs:

  1. The content selector tag contacts the Advisor.

Note: For information about the Advisor, see Creating Personalized Applications with the Advisor.
For information about the Rules Engine, see Introducing the Rules Framework.

  1. The Advisor forwards the content-selector request to the Rules Manager via the Rules Advislet.

  2. The Rules Manager finds the corresponding content-selector definition and invokes the Rules Engine to evaluate the content selector's conditions.

  3. Depending on the conditions that are defined for the content selector, the Rules Engine refers to any of the following:

  4. If any of the conditions are met, the Rules Engine returns the content selector's query to the Advisor via the Rules Manager.

  5. The Advisor forwards the query to the content management system via the Content Query Advislet.

  6. The Advisor stores any query results in an array that only the current JSP can access. You can specify that the Advisor stores the results in a cache and that the cache is accessible beyond the current JSP invocation. For more information, see Create and Configure the Cache to Improve Performance.

Note that you must use other tags to display the documents that are in the array.

Figure 4-1 How Content Selectors Select Documents


 

 

back to top previous page next page