Interaction Management Guide

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

Creating a Content Selector

Content Selectors use rules to target specific groups of people with content items from BEA's Virtual Content Repository. Content Selectors return and display content. For example, if a user logs in and is identified in the User Profile as a book fan, a Content Selector can display a list of recommended books.

Developers can use Workshop for WebLogic to create and update Content Selectors and place them in a JSP. Portal administrators use the Administration Console to make changes to the Content Selectors that display content in your portal.

Users do not have to be authenticated (logged in) to be targeted by Content Selectors. For example, the presence of specific HTTP request or session properties, or specific date and time conditions can trigger content to be displayed. You can, for example, display targeted holiday content to users who visit your portal in the month of December and view your portal with a specific type of web browser.

However, authenticated users (as well as anonymous tracked users) have profile information associated with them that you can use to target them with personalized content. A book fan is an example of this type of User Profile data.

Note: The steps in this chapter refer to the data\src folder in the Package Explorer View. Your data and src directories might be named differently.

This chapter includes the following sections:

 


Setting Up Content to Display

Content Selectors retrieve content properties, which are usually text or numeric values. For example, you want your Content Selectors to retrieve information about books. Book content can be assigned many properties, such as title, author, publication date, ISBN, and a URL to the publisher's web site. You may want your Content Selector to display a bulleted list of titles and link each title to the publisher's web site. This list and link is accomplished through using just the text values of the content properties.

However, your book content could also have a binary property that stores an image of the book's cover. The Content Selector can also display that binary property—the actual image—using the ShowProperty servlet, as described in Creating a Placeholder File. The type of binary content that Content Selectors can display is dependent on the MIME types you have configured. By default, WebLogic Portal provides MIME support for displaying images and other types of files. See Displaying Additional MIME Types in a Placeholder for more information on other types.

This section includes the following topic:

Displaying Content for Other MIME Types

To display content for other MIME types, Content Selectors refer to a document's MIME type and then generate the HTML tags that a browser requires for the specific document type. For example, to display an image-type document, an ad Placeholder must generate the <img> tag that a browser requires for images. By default, ad Placeholders can generate the appropriate HTML only for the following MIME types:

WARNING: The <EMBED> tags do not always work correctly in all browsers. The behavior depends on the plug-ins you have configured.

If you are familiar with basic Java programming, you can write classes that enable Content Selectors to generate HTML for additional MIME types.

To support additional MIME types, you must complete the following tasks:

  1. Create and compile a Java class to generate HTML.
  2. Register the new class.

Creating and Compiling a Java Class to Generate HTML

To generate the HTML that the browser requires to display the MIME type, use Workshop for WebLogic to create a Java project in your application, and then create and compile a Java class in that Java project that implements the com.bea.p13n.ad.AdContentProvider interface. For information on this interface, see the Javadoc.

Registering the New Class

After you save the class in a directory that is in your CLASSPATH, you must notify WebLogic Portal Administration Console of its existence by performing the following steps:

  1. Stop the server.
  2. Create a backup copy of your application's META-INF\wps-config.xml file.
  3. Open the wps-config.xml file in a text editor and find the <AdService> element.
  4. Add the following code as a sub-element of the <AdService> element:
  5. <AdContentProvider
    Name="MIME-type"
    Provider="YourClass.class"
    Properties="optional-properties-for-your-class"
    >
    </AdContentProvider>

    Provide the following values for the attributes of the AdContentProvider element:

    • Name - The name of the MIME type that you want to support.
    • Provider - The name of the compiled Java file. If you saved the file below a directory that your CLASSPATH environment variable names, you must include the file's path name, starting one directory level below the CLASSPATH directory.
    • Properties - Any additional properties or parameters want to pass to your object. For example, if you added <PORTAL_APP>/classes to the system classpath, save your class to support AVI files as <PORTAL_APP>/classes/myclasses/MimeAvi.class.
    • The following code sample demonstrates AVI file support:

      <AdContentProvider 
      Name="video/x-msvideo"
      Provider="myclasses.MimeAvi"
      Properties=""
      >
      </AdContentProvider>
  6. Save your modifications to the wps-config.xml file.
  7. Restart the WebLogic Server.
  8. Activate the content provider in the Administration Console by performing the following steps:
    1. Start the WebLogic Portal Administration Console.
    2. In the WebLogic Portal Administration Console, choose Configuration Settings > Service Administration.
    3. In Resource Tree, select Add/remove configurable item.
    4. In the list of configurable items that appears, select the check box next to the content provider you added.
    5. Click Update.

 


Creating a Content Selector

Content Selectors are scoped to the enterprise application, so you can include a Content Selector in any JSP within the enterprise application.

A Content Selector consists of the following two parts:

  1. Content Selector file - The Content Selector file that you create in Workshop for WebLogic contains the following parts:
    1. Personalization rules - The conditions that define when the Content Selector runs its query and displays the content. The following conditions can be used to trigger a Content Selector:
      • The visitor is a member of a predefined User Segment
      • The visitor has specific characteristics (User Profile properties)
      • Specific HTTP session or request properties exist
      • Date and time conditions
    2. A content query that retrieves a specific set of content properties.
  2. The <pz:contentSelector> JSP tag - This companion tag performs the processing and is also created in Workshop for WebLogic. Content returned from Content Selectors is usually displayed in portlets. When a user views a portlet or a portal desktop that contains a Content Selector, the Content Selector's rules and logic look for a match of properties, such as User Profile information. If the properties match the Content Selector rules, the Content Selector runs a query and retrieves and displays all content matching the query.
Tip: During development, the rules files reload when they change (just like JSPs), so you can quickly develop with Content Selectors. However, when the server is in production mode, Content Selectors are loaded into the database (from the file-based definitions in the application) where they can be modified in the WebLogic Portal Administration Console without redeploying the application or restarting the server.

Use the following guidelines when you create Content Selectors.

The <img> HTML tag's source path is constructed to use the path to the content item in the Virtual Content Repository. The path includes the ShowProperty servlet to render the binary file. In the node.getPath() method, node is a specific content item stored by the <utility:forEachInArray> tag's id attribute. If the <utility:forEachInArray> id attribute value was foo, the method would look similar to the following: foo.getPath().

This section contains the following topics:

Creating the Content Selector File

Perform the following steps to create a Content Selector file:

  1. Start the WebLogic server by choosing Run As > Run on Server in Workshop for WebLogic. For instructions on configuring the WebLogic Server, see the Portal Development Guide.
  2. In the Portal Perspective, right-click the data\src\contentselectors\GlobalContentSelectors folder in the Package Explorer View and choose New > Other.
  3. Tip: You can customize the menu so that Content Selector appears as a choice on the New menu. See the Portal Development Guide for instructions.
  4. In the New Select a Wizard window, select Content Selector in the WebLogic Portal folder and click Next.
  5. In the New Content Selector File window, enter a name for the Content Selector in the File name field. Keep the .sel file extension, as shown in Figure 6-1.
  6. Figure 6-1 Create a New Content Selector


    Create a New Content Selector

  7. Click Finish. The Content Selector Editor appears.
  8. Select the Properties tab to change the display Name for the Content Selector.
  9. Select the Palette tab to see the Available Conditions under which the Content Selector will run. As you select conditions, corresponding links appear in the top of the Editor window.
  10. In the Content Selector Editor window, click the corresponding links to create the conditions you selected, and enter the appropriate information.
  11. In the Content Selector Editor window, click the query's empty content search link to define the query. This requires a connection to BEA's Virtual Content Repository, which is set up in the WebLogic Portal Administration Console.
  12. You can define the query in advanced mode using WebLogic Portal's expression syntax (on the Advanced tab) or in graphical mode (on the Query tab):
    • Advanced mode - In the Content Search window, select the Advanced tab and build a query using the instructions in Building a Content Query with Expressions. The Advanced tab provides code coloring to highlight context errors in your queries. You can reuse existing queries by pasting them into the Advanced tab.
    • Graphical mode - Use the following steps in the Query tab to build a content query by selecting content properties, comparators, and values to retrieve content items.
    1. In the Content Search window, select the Query tab.
    2. Select a property set and a property within the content type, and click Add.
    3. Note: The properties you select are content properties (types) rather than property set properties such as user profile or session properties.
    4. In the Content Search Values window that appears, use one of the following tabs:
      • Values tab - To define the query based on a comparison to a value you enter. For example, the query could be set to retrieve content with an investorRiskLevel property that is marked as high. You could also retrieve binary content with a name of IRACampaign. See Figure 6-2 for an example and Table 6-1 for more details.
      • Figure 6-2 A Content Query that Retrieves a Binary File Called IRACampaign


        A Content Query that Retrieves a Binary File Called IRACampaign

      • Properties tab - To define the content query based on the property value that is dynamically fed in from another type of property, such as a user profile property. For example, instead of creating a query based on static content properties, you can create a query that reads in the value of the current user's investorRiskLevel to populate the query. The query would be different for each user.
    5. Click Add. The query descriptor is added in the Content Search window.
    6. You can add more value phrases to the query, then set the appropriate option in the For multiple descriptors area at the bottom of the window.
  13. Click OK in the Content Search window to add the query to the search.
  14. You can preview the content that will be retrieved by the query by clicking the Content Preview tab. If you defined the query to use values from a User Profile property, the retrieved content will be different for each user, so you must enter the username of an existing user in the Preview User field to see which content will be retrieved for that user.
  15. Save the Content Selector file by choosing File > Save.
  16. To use the Content Selector, add the <pz:contentSelector> tag to the relevant JSPs. See Using a JSP Tag to Display a Content Selector File for more information on using the <pz:contentSelector> tag to display text content (including text binaries, such as HTML files) and non-text binaries (graphics). See the Content Management Guide to learn how to modify an existing Content Selector to display binary content.
Tip: Content Selectors can display binary content, such as images. See the Content Management Guide for instructions.

Figure 6-3 shows a Content Selector file called classic.sel. The condition that triggers the Content Selector is a user with a property set of SalesRegion with a value of Americas. The content that is retrieved is any content with a binary file name that contains IRACampaign.

Figure 6-3 Content Selector File in Workshop for WebLogic

Content Selector File in Workshop for WebLogic

Tip: When library services (for example, versioning and workflow status) are enabled for a BEA repository, system properties are always available (published) to queries unless the content item has a retired status. If you want to retrieve content based on its content type, you must use the cm_objectClass system property in your content query. If your queries use only system properties, the query retrieves all content items with matching system properties that are not retired.

Users do not have to be authenticated to be targeted by Content Selectors.

Building a Content Query with Expressions

You can use the WebLogic Portal Expression language in WebLogic Portal Administration Console to build content queries. You can build queries with the Advanced Query window from content-related JSP tags and when you are creating queries for Placeholders, Campaigns, and Content Selectors.

The query compares a content property to a value that you enter. A query contains the following three parts: <property><comparator><value>.

If the comparison is true, all matching content items are retrieved.

For example:

employee_type == 'manager'
This query retrieves any content item from the BEA Virtual Content Repository with a property called employee_type that contains the exact (==) String manager.

Queries are often made up of multiple clauses using and (&&) and or (||) logic. For example:

(genre == 'rock' || genre == 'alternative') &&
platinum_records > 2
This query retrieves any content item with a genre property that has an exact value of rock or (||) alternative and (&&) with a platinum_records property value greater than 2. The parentheses separates one section of the query from the next, controlling the order of evaluation.
(genre=='rock' || genre=='country') && artist=='dead'
This query retrieves any content item with a genre property that has an exact value of rock or country and an artist property value of dead.

This section contains the following topics:

Using Rules to Build a Query

Use the following rules when you build a query:

Tip: With your development server running, create a test Placeholder or Content Selector in Workshop for WebLogic and construct queries for it using the Advanced tab in the Content Search window. The retrieved content is displayed in the Content Preview tab. If you utilize the userProperty() format to retrieve values for your query, you must enter a user name in the Preview User field of the Content Preview tab to retrieve the values for that user and display the retrieved content items.
Selecting Properties

The following two types of properties exist for content:

You can use both properties in a query.

User-defined content properties are stored in sets called types, which are defined in the WebLogic Portal Administration Console. For example, you can create a type called Book and add properties, such as title, author, pub_date, and isbn.

Explicit content properties are automatically associated with all content items and are automatically assigned values for a content item when the content item is added to the content repository. These properties, which are also listed in the com.bea.content.expression.Search class, include the items listed in Table 6-1.

Table 6-1 Explicit Content Properties 
Property
API
Description
cm_uid
Node.id.uid
The unique ID for a content item. You can view a content item's unique ID by selecting the content item in the Administration Console and viewing its description.
cm_createdDate
Node.createDate
The date on which a content item was created. You can view Creation Date information for content items by selecting their content folder in the Administration Console and selecting the Summary tab.
cm_createdBy
Node.createdBy
The user who created the content item. You can view Created By information for content items by selecting the content folder in the Administration Console and selecting the Summary tab.
cm_modifiedDate
Node.modifiedDate
The date the content item was last modified. You can view Modified Date information for content items by selecting their content folder in the Administration Console and selecting the Summary tab.
cm_nodeName
Node.name
The name of the content item, as shown in the Administration Console.
cm_path
Node.path
The Virtual Content Repository path to the content item. For example,
/BEA Repository/juvenilebooks/ TheCrazyAdventure.
cm_isHierarchy
Node.type == Node.HIERARCHY
Identifies a content folder rather than a content item. Content folders can contain content items and child content folders. When using this property in queries, compare it using a Boolean value of true or false.
cm_isContent
Node.type == Node.CONTENT
Identifies a content item rather than a content folder. Content items contain properties from the type with which they are associated. When using this property in queries, compare it using a Boolean value of true or false.
cm_objectClass
Node.objectClass.name
The content type associated with a content item. You can view Type information for content items by selecting the Types tab in the Administration Console and selecting the Summary tab.
cm_objectClassInstance
The instance of an object class
Finds all instances of a given object class and all of its children.
cm_value
The value
A metadata search for any property with a given value. This property is similar to a wildcard search.
cm_contentType
BinaryValue.contentType
The MIME type for content item binary properties. For example, image/jpeg. You can view the MIME type of a content item by selecting it in the Administration Console and looking at the Primary Property Data Type field.
cm_binarySize
BinaryValue.size
(For Node Properties)
The size of the binary value of content items. You can view the size of a content item's binary value by selecting the content item in the Administration Console, selecting the Properties tab, and clicking Download File. Click Save and right-click the displayed binary file to view the file properties.
When you use this property in a query, specify binary size in bytes.
cm_binaryName
BinaryValue.name
(For Node Properties)
The file name of the binary value of a content item. You can view the name of a content item's binary value by selecting the content item in the Administration Console and viewing the Name value in the Summary tab.

When you construct a query, you can specify property names by themselves without quotes. For example: title <comparator> <value>. However, if a property name contains spaces, double quotes, or dashes, you must enclose the property name within a toProperty() format. For example: toProperty('Favorite Author') <comparator> <value>.

The query looks for the property name in all content types and returns any content item with that property value (if the content item meets the conditions of the query). However, you can also isolate a property within a specific type. For example, if you have a books type and an articles type that both contain a title property, you can retrieve content items with a specific title from within only the book type using the cm_objectClass property.

For example: title likeignorecase '*Adventure' && cm_objectClass = 'books'

Using Comparators

Comparators provide the logic that compares a query's property to the value you enter. If a content item meets the conditions of the query, the content item is returned. Table 6-2 contains a list of the comparators you can use in your queries.

Table 6-2 Available Comparators 
Comparator
Description (Property Formats on Which the Comparator Can Act)
= or ==
Checks to see if a single-value property (including a single value containing a list) is exactly equal to the case-sensitive value you enter (Boolean, date and time, numeric, and string values). For example, genre == 'fantasy' retrieves any content item that has case-sensitive fantasy as the value for the genre property.
!=
Checks to see if a single-value property (including a single value containing a list) is not equal to the case-sensitive value you enter (Boolean, date and time, numeric, and string values). For example, genre != 'mystery' retrieves any content item that does not have case-sensitive mystery as the value for the genre property.
>
Checks to see if a single-value property is greater than the value you specify (date or time and numeric values). For example, pub_date > toDate('MM-dd-yyyy', `01-01-2000') retrieves any content item with a pub_date property set to a value later than January 1, 2006.
<
Checks to see if a single-value property is less than the value you specify (date or time and numeric values). For example, books in series < 3. Because the property name contains spaces, you must use toProperty(), as shown in toProperty('books in series') < 3 to retrieve any content item with a value less than 3 for the books in series property.
>=
Checks to see if a single-value property is greater than or equal to the value you specify (date or time and numeric values). For example, toProperty('books in series') >= 3 retrieves any content item with a value greater than or equal to 3 for the books in series property. The property value of the sample content item is 1.
<=
Checks to see if a single-value property is less than or equal to the value you specify (date or time and numeric values). For example, toProperty('books in series') <= 3 retrieves any content item with a value less than or equal to 3 for the books in series property.
like
Checks to see if a single-value property is like the case-sensitive value you enter. You can use wildcard characters * (one or more characters) or ? (single character). For example, author like 'P?nm*' retrieves any content that contains case-sensitive Penman, Panmen, or any other variation with a different character between the P and the n and any characters after the m for the author property.

Note: If you do not put the asterisk (*) at the end, the content item is not retrieved, because more text follows the name Penman in the property value.

likeignorecase
Checks to see if a single-value property is like the value you enter. You can use the wildcard characters * and ?. Character case is ignored. For example, author likeignorecase 'pen*' retrieves any content with an author value that begins with pen in any case combination, such as penman, Penman, Penfield, and so on.
contains
Checks to see if a multi-value property contains exactly the single value you specify (date or time, numeric, and string values). In some implementations, this comparator may also work against single-value properties. For example, genre contains 'fantasy' retrieves any content containing an genre property value of exactly fantasy.
containsall
Checks to see if a multi-value property contains all of the exact values you specify (date or time, numeric, and string values). For example, genre containsall ('fantasy', 'children') retrieves any content that contains genre property values of fantasy and children. In some implementations, this comparator can also work against single-value properties.
containsany
Checks to see if a multi-value property contains any of the exact values you specify (date or time, numeric, and string values). For example, genre containsany ('fantasy', 'children', 'scifi') retrieves any content that contains genre property values of fantasy, children, or scifi. In some implementations, this comparator can also work against single-value properties.
in
Checks to see if a single-value property contains any of the values you enter. If the value you enter is not a list of possible values (is a single value), in is the same as = or == (date or time, numeric, and string values). For example, isbn in ('pending', 'not_available') retrieves any content that contains the isbn property value of pending or not_available.

Supplying Values

Values represent the content you want the query to return. By supplying values to a query, you are telling the query which content to retrieve or ignore based on the values stored on the content items.

For example, if you have a content type called book with a property called title, all content items you associate with the book type have a title field. Each title value is unique, so in a query, you can enter the unique value you want, resulting in the query retrieving a specific content item (or ignoring the content item, depending on the comparator you use).

You can enter values in two ways:

  1. Hard code values in the queries - Use hard-coded values so that you get predictability with your queries. Hard-coded values let you pinpoint the specific content you want to retrieve.
  2. Get values from User Profiles and other types of property sets (Session and Request) - When you populate values from User Profile, session, or request property sets, the value in each specified User Profile, session, or request property is inserted programmatically into the query, letting you create personalized queries based on the current user's preferences or the current session or request.
  3. For example, in a query where a content property is author, you can get the value of the user's FavoriteAuthor profile property to supply the value for the query, letting the query retrieve content associated with the user's favorite author.

    Use the following guidelines to build values in queries:

    • Enclose string literal values in single quotes. For example: 'pending'.
    • To supply a single or double quote, use a backslash for the quoting character (unicode characters are not supported). For example, if a book title is stored with double quotes, such as "The Crazy Adventure", enter the value like this: '\"The Crazy Adventure\"'. If the title is stored with single quotes, enter the value like this: title = '\'The Crazy Adventure\'' .
    • Unicode (such as "\u6565"), octal (such as "\7", "\65", "\377"), and standard Java escape sequences (such as "\n", "\r", "\b") are allowed in the string literals.
    • Boolean literals are either the true or false keyword (lowercase, without quotes).
    • Number literals are Java form (scientific notation is supported).
    • Date or time literals are presented in toDate('formatStr', 'dateStr') format, where formatStr is the date and time format you want to use (such as 'MM/dd/yyyy') and dateStr is the actual date and time you enter (such as '01/01/2006').

      The formatStr must be a valid java.text.SimpleDateFormat string. If you omit the formatStr, the toDate() expects the date and time you enter to be in the following format: 'MM/dd/yyyy HH:mm:ss z' (where z is the time zone, such as MDT). For example: toDate('12/01/2004 06:00:00 MDT').

      To specify date values only, enter the format you want for the formatStr. For example, for a date value only, specify toDate('MM/dd/yyyy', '12/01/2004'). You can also specify only the month and year, such as 'MM-yyyy'.

      Use the now keyword to specify the time at which the expression is being parsed at run time.

    • To supply query values from user, request, or session properties, use the following format: <type>Property(<propertyset>, <propertyname>), where the type is user, request, or session. For example: userProperty('userpreferences', 'FavoriteAuthor').
Creating Complex Queries

You can combine multiple independent query clauses, tying them together with and (&&) and or (||) logic and controlling the order of evaluation with parentheses the way you would with algebraic expressions. This lets you create more complex queries. You can also include not logic (!) in complex queries by using the exclamation point in front of a parenthetical grouping.

See the Content Management Guide for more information about queries.

Using Sample Queries

Figure 6-4 shows the properties set on a book stored in BEA's Virtual Content Repository.

Figure 6-4 Properties on a Book

Properties on a Book

The example queries in Table 6-3 use properties in the sample content item, and the description for each sample query tells you if the query will retrieve the content item.

Table 6-3 Example Queries (Continued)
Query
Will Retrieve Sample?
Description
genre == 'fantasy'
Yes
Retrieves any content item that has case-sensitive fantasy as the value for the genre property.
will_visit_schools == true
Yes
Retrieves any content item with the will_visit_schools property set to true. There are no single quotes around true, and true is lowercase.
genre != 'mystery'
Yes
Retrieves any content item that does not have case-sensitive mystery as the value for the genre property.
pub_date > toDate('MM-dd-yyyy', '01-01-2005')
Yes
Retrieves any content item with a pub_date property set to a value later than January 1, 2005.
books in series < 3
No
Because the property name contains spaces, you must use toProperty(), as shown in the next example.
toProperty('books in series') < 3
Yes
Retrieves any content item with a value less than 3 for the books in series property.
toProperty('books in series') >= 3
No
Retrieves any content item with value greater than or equal to 3 for the books in series property. The property value of the sample content item is 1.
toProperty('books in series') <= 3
Yes
Retrieves any content item with value less than or equal to 3 for the books in series property.
author like 'P?nm*'
Yes
Retrieves any content that contains case-sensitive Penman, Panmen, or any other variation with a different character between the P and the n and any characters after the m for the author property. Without an asterisk (*) at the end, the content item would not be retrieved, because more text follows the name Penman in the property value.
author likeignorecase 'pen*'
Yes
Retrieves any content with an author value that begins with pen in any case combination, such as penman, Penman, Penfield, and so on.
genre contains 'fantasy'
Yes
Retrieves any content containing an genre value of exactly fantasy.
genre contains 'child*'
No
The contains comparator does not allow wildcard characters.
genre containsall ('fantasy', 'children')
Yes
Retrieves any content that contains genre property values of fantasy and children.
genre containsall ('fantasy', 'children', 'scifi')
No
Retrieves any content that contains genre property values of fantasy, children, and scifi. The sample content item contains fantasy and children, but not scifi.
genre containsany ('fantasy', 'children', 'scifi')
Yes
Retrieves any content that contains genre property values of fantasy, children, or scifi.
isbn in ('pending', 'not_available')
Yes
Retrieves any content that contains the isbn property value of either pending or not_available.
Complex Queries
toProperty('books in series') >= 3 &&
pub_date > toDate('MM-yyyy','1-2005')
No
Retrieves books that are part of a trilogy that were published after January 2005.
(genre contains 'children' || keywords like '*children*') && will_visit_schools == true
Yes
Retrieves books with a genre value set to children or has *children* in the keyword value; and whose author is available to visit schools.
((genre contains 'children' || keywords like '*children*') && will_visit_schools == true) && isbn != 'pending'
No
Retrieves books with a genre value set to children or has *children* in the keyword value; and whose author is available to visit schools; and with an isbn value that does not equal pending (meaning the book is not yet published). The parenthetical nesting controls the order of evaluation.
(title likeignorecase '*adventure' || genre contains 'fantasy') && (pub_date >= toDate('MM-yyyy', '01-2005') || isbn == 'pending')
Yes
Retrieves books whose title contains *adventure or whose genre contains fantasy; and whose pub_date is after January 2005 or whose isbn is still pending (not yet published).
(genre containsany userProperty('userpreferences', 'BookGenre') && (keywords likeignorecase '*pixies')) ||
author likeignorecase userProperty('userpreferences', 'FavoriteAuthor')
Depends
Reads the User's Profile properties and uses specific property values to supply the values in the query. The query provides personalized content retrieval, because retrieved content is based on user preferences.
For example, if the current user has her BookGenre property set to mystery and her FavoriteAuthor set to Penman, Piper, this query will return the sample content. Even though the BookGenre value doesn't match in the first clause, the FavoriteAuthor in the or (||) second clause does match.
If you are using the Property control or the setProperty JSP tag to set user property sets and properties programmatically (rather than creating property sets in Workshop for WebLogic), you can still use userProperty() in your queries.
Other Useful Queries (Not Related to the Sample Content)
language == userProperty('userpreferences', 'userPreferredLang')
This approach lets you serve language-appropriate content to each user based on the user language preference (userPreferredLang) stored in a property set. You could also use sessionProperty() to get the language preference from the session; or you could use requestProperty('DefaultRequestPropertySet', 'Locale'), which returns the user's locale string, such as en-US.
((UserAge <= 35 && colors contains 'red' ||
UserAge > 35 && !(colors contains 'black')) &&
mimeType == 'text/html') &&
toProperty('Launch Date') < now && !(expireDate > toDate('MM-yyyy', '12-2004'))
This query uses not logic, as shown in the !(colors contains 'black') clause.

Using a JSP Tag to Display a Content Selector File

After you have created a Content Selector file (see Creating the Content Selector File), you must use the <pz:contentSelector> JSP tag to display the content. The following JSP tag uses the classic Content Selector shown in Figure 6-3:

<pz:contentSelector rule="classic" id="nodes"/>

The JSP tag has two required attributes:

There are other attributes you can set on the <pz:contentSelector> tag. See the Javadoc for more information on the class.

Adding a Content Selector to a JSP

After you create a Content Selector file in Workshop for WebLogic, you can use any of the following three methods to add the Content Selector to a JSP in Workshop for WebLogic:

Dragging a Content Selector to a Portal File

Perform the following steps to drag a Content Selector to an open portal file:

  1. In the Portal Perspective, locate a Content Selector file.
  2. Drag a Content Selector from the Workshop Perspective onto a page of an open portal file. When you do this, three things occur:
    1. The Portlet Wizard appears, letting you quickly create a portlet that will display the Placeholder.
    2. The resulting portlet is automatically added to the portal page.
    3. A JSP file is automatically created for the Content Selector.
    4. The JSP file contains the Content Selector JSP tag with the rule and id attributes automatically populated, and the include statement for the tag library is automatically added. Other JSP and HTML tags are also added automatically, as shown in Listing 6-1.

      Listing 6-1 JSP File with Other JSP and HTML Tags
      <pz:contentSelector rule="modern" id="nodes"/>
      <utility:notNull item="<%=nodes%>">
      <ul>
      <utility:forEachInArray array="<%=nodes%>" id="node"
      type="com.bea.content.Node">
      <li><cm:getProperty id="node" name="cm_nodeName"
      conversionType="html"/></li>
      </utility:forEachInArray>
      </ul>
      </utility:notNull>

      Table 6-4 describes the JSP tags you can use with a Content Selector.

      Table 6-4 JSP Tags for Content Selectors
      JSP Tag
      Description
      <utility:notNull>
      Checks to see if the array actually contains content.
      <ul>
      Provides a container for listing content items in a bulleted list.
      <utility:forEachInArray>
      Iterates through the array and isolates each content item until all items in the array have been processed. Each item is given its own <li> bullet.
      <cm:getProperty>
      Takes each content item from <utility:forEachInArray> and designates which content property is going to be displayed.

Using More than One Content Selector

You can use multiple Content Selectors with conditional logic to get hierarchical personalized content, where you try to match the most specific to the least specific, or for mutually exclusive Content Selectors. Listing 6-2 demonstrates how to use multiple Content Selectors for personalized content.

Listing 6-2 Using the <pz:contentSelector> JSP Tag for Multiple Content Selectors
<%@ taglib uri="content.tld" prefix="cm"%>
<%@ taglib uri="http://www.bea.com/servers/p13n/tags/utility" prefix="utility"%>
<%@ taglib uri="http://www.bea.com/servers/portal/tags/ad" prefix="ad"%>
<%@ taglib uri="http://www.bea.com/servers/portal/tags/personalization"
prefix="pz"%>
<pz:contentSelector rule="FemaleContent" id="nodes" sortBy="cm_nodeName desc"/>
<% if (nodes == null || nodes.length <= 0) { %>
<pz:contentSelector rule="MaleContent" id="nodes" sortBy="cm_nodeName desc"/>
<% }%>
<% if (nodes == null || nodes.length <= 0) { %>
Sorry, you don't get a free lunch today.
<% }%>
Found <%=nodes.length%> Node(s):
<dl>
<utility:forEachInArray array="<%=nodes%>" id="node"
type="com.bea.content.Node">
<dt><cm:getProperty id="node" name="title" conversionType="html"/></dt>
<dd><ad:render id="node" /></dd>
</utility:forEachInArray>
</dl>

 


Using the <pz:div> Tag Instead of a Content Selector

The <pz:div> JSP tag can provide in-line HTML Personalization. You can populate a JSP with sets of in-line content and wrap it with the tag. The tag uses a rule attribute that takes the name of an existing User Segment. Only members of that User Segment can see the in-line content. For example, you created a User Segment called bookfanUserSegment.seg in Workshop for WebLogic that makes anyone a member who has a bookfan User Profile property set value set of true. The following sample code illustrates this:

<pz:div rule="bookfanUserSegment">
<p>Only users who are book nerds will see this text!</p>
</pz:div>

User Segment rules (conditions) are the same as those available to Content Selectors, so the <pz:div> tag provides a similar level of Personalization. The difference is that Content Selectors retrieve their content from the virtual content repository, while the <pz:div> tag encloses its content in-line in the JSP.

Tip: Content Selectors can display binary content, such as images. See the Content Management Guide for instructions.

 


Deleting a Content Selector Query

Deleting a Content Selector query removes the query from the Content Selector in Workshop for WebLogic and the Administration Console.

Note: The steps in this chapter refer to the <data>\src folder in the Package Explorer View. Your data and src directories might be named differently.

Developers perform the following steps to remove a query in a Content Selector:

  1. In the Portal Perspective, open the Content Selector file in the \data\src\contentselectors\GlobalContentSelectors folder in the Package Explorer View.
  2. Click the query link in the Content Selector Editor.
  3. Select the query in the Content Search dialog.
  4. Click Remove.
  5. Click OK.

 


Deleting a Content Selector

Removing a Content Selector removes it from Workshop for WebLogic and from the Administration Console.

Perform the following steps to delete a Content Selector:

  1. In the Portal Perspective, open the Content Selector file in the \<data>\src\contentselectors\GlobalContentSelectors folder in the Package Explorer View.
  2. Right-click the Content Selector and choose Delete.
  3. Click Yes to confirm the deletion.
Tip: You should also delete any <pz:contentSelector> tags in your JSPs that reference the Content Selector you deleted.

 


Modifying a Content Selector

You can use the following methods to edit the content that a Content Selector displays:


  Back to Top       Previous  Next