Skip Headers
Oracle® Fusion Middleware Interaction Management Guide for Oracle WebLogic Portal
10g Release 3 (10.3.4)

Part Number E14238-03
Go to Documentation Home
Home
Go to Table of Contents
Contents
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

6 Creating a Content Selector

Content Selectors use rules to target specific groups of people with content items from the WLP 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 Oracle Enterprise Pack for Eclipse 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. You can retrieve both published and versioned content in a content selector. For more information about publishing content, see Adding Content to a WLP Repository in the Oracle Fusion Middleware Content Management Guide for Oracle WebLogic 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:

6.1 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 Section 7.2.1, "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 Section 7.1.1, "Displaying Additional MIME Types in a Placeholder" for more information on other types.

6.2 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 Oracle Enterprise Pack for Eclipse 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 Oracle Enterprise Pack for Eclipse. 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:

6.2.1 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 Oracle Enterprise Pack for Eclipse. For instructions on configuring the WebLogic Server, see the Oracle Fusion Middleware Portal Development Guide for Oracle WebLogic Portal.

  2. In the Portal Perspective, right-click the <data>\src\contentselectors\GlobalContentSelectors folder in the Package Explorer View and choose New > Content Selector.

  3. Enter a name for the Content Selector in the File name field, using the .sel file extension, as shown in Figure 6-1.

Figure 6-1 Create a New Content Selector

Description of Figure 6-1 follows
Description of "Figure 6-1 Create a New Content Selector"

  1. Click Finish. The Content Selector Editor appears.

  2. Select the Properties tab to change the description for the Content Selector.

  3. Select the Design 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.

  4. In the Content Selector Editor window, click the corresponding links to create the conditions you selected, and enter the appropriate information.

  5. In the Content Selector Editor window, click the query's empty content search link to define the query. This requires a connection to WLP's Virtual Content Repository, which is set up in the WebLogic Portal Administration Console.

  6. 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 Section 6.2.1.1, "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. One of the default property sets is Standard Versioned, which retrieves versioned content. Use the Standard Versioned properties to narrow your content search. For example, you can retrieve only the latest version of a graphic by selecting the cm_latestVersion property.

      Note:

      The properties you select are system content properties, rather than property set properties like user profile or session properties.
    3. In the Content Search Values dialog 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-6 for more details.

      Figure 6-2 A Content Query that Retrieves a Binary File Called IRACampaign

      Description of Figure 6-2 follows
      Description of "Figure 6-2 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.

  1. Click Add. The query descriptor is added in the Content Search window.

  2. 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.

  3. Click OK in the Content Search window to add the query to the search.

  4. 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 user name of an existing user in the Preview User field to see which content will be retrieved for that user. By default, you preview published content. If you want to preview versioned content, click Controls whether this will preview versioned or published content, as shown below. (Click the Menu icon next to this icon to toggle between versioned content and published content.)

    Description of contentpreview.gif follows
    Description of the illustration contentpreview.gif

    For more information about publishing content, see Adding Content to a WLP Repository in the Oracle Fusion Middleware Content Management Guide for Oracle WebLogic Portal.

  1. Save the Content Selector file by choosing File > Save.

  2. To use the Content Selector, add the <pz:contentSelector> tag to the relevant JSPs. See Section 6.2.2, "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).

    Tip:

    Content Selectors can display binary content, such as images. See the Oracle Fusion Middleware Content Management Guide for Oracle WebLogic Portal 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 Oracle Enterprise Pack for Eclipse

Description of Figure 6-3 follows
Description of "Figure 6-3 Content Selector File in Oracle Enterprise Pack for Eclipse"

Tip:

When library services (for example, versioning and workflow status) are enabled for a WLP Repository, system properties are always available to queries unless the content item has a retired status. You can search for both published and versioned content. 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.

6.2.1.1 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 WLP 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:

Query Description
(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:

6.2.1.1.1 Using Rules to Build a Query

Use the following rules when you build a query:

  • Queries are case sensitive.

  • Queries can be simple, one-clause queries, or they can be more complex, multi-clause queries. In complex queries, parentheses control the order of evaluation for multiple query clauses, and clauses are evaluated using and (&&) and or (||) logic.

  • In a Placeholder, only one content item can be displayed at a time. If you are using a Placeholder to run queries from a Campaign (as well as its own default queries), you can run several queries, but only one query at a time. The query is determined by the Placeholder's weighting system. After the query runs, the query can return multiple content items, but the Placeholder displays only one of the retrieved content items.

    Tip:

    With your development server running, create a test Placeholder or Content Selector in Oracle Enterprise Pack for Eclipse 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.
6.2.1.1.2 Selecting Properties

The following two types of properties exist for content:

  • User-defined content properties.

  • System content properties. See Table 6-6 for a list of system content properties.

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.

System 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. System properties can be used to retrieve published content or versioned content. 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 System Content Properties

Property API Type of Content Description

cm_uid

Node.id.uid

Published and

Versioned

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

Published

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

Published

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

Published and

Versioned

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_modifiedBy

Node.modifiedBy

Published and

Versioned

The user who last edited the content.

cm_nodeName

Node.name

Published and

Versioned

The name of the content item, as shown in the Administration Console.

cm_path

Node.path

Published

The Virtual Content Repository path to the content item. For example,

/WLPRepository/ juvenilebooks/ TheCrazyAdventure.

cm_isHierarchy

Node.type == Node.HIERARCHY

Published

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

Published

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

Published

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

Published

Finds all instances of a given object class and all of its children.

cm_value

The value

Published and

Versioned

A metadata search for any property with a given value. This property is similar to a wildcard search.

cm_contentType

BinaryValue. contentType

Published and

Versioned

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)

Published and

Versioned

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)

Published and

Versioned

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.

cm_assignedToUser

VirtualNode

Versioned

The user to which the node is assigned. For example, cm_assignedToUser = 'joe'.

cm_checkedOut

VirtualNode

Versioned

If the node is checked out. For example, cm_checkedOut = false.

cm_latestVersion

N/A

Versioned

The latest version of the content. For example, cm_latestVersion = true.

cm_role

VirtualNode

Versioned

The role to which the node is assigned. For example, cm_role = 'Admin'.

cm_version

Version

Versioned

The version number of the content. This value is a string. For example, cm_version = '5'.

cm_versionComment

Version

Versioned

Text describing the changes to the version. For example, cm_versionComment = Includes updates from Marketing.


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'

6.2.1.1.3 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.


6.2.1.1.4 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.

    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').

6.2.1.1.5 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 Oracle Fusion Middleware Content Management Guide for Oracle WebLogic Portal for more information about queries.

6.2.1.1.6 Using Sample Queries

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

Figure 6-4 Properties on a Book

Description of Figure 6-4 follows
Description of "Figure 6-4 Properties on a Book"

The example queries in Table 6-3, Table 6-4, and Table 6-5 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

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.


Table 6-4 Complex Queries

Query Will Retrieve Sample? Description

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 Oracle Enterprise Pack for Eclipse), you can still use userProperty() in your queries.


Table 6-5 Other Useful Queries (Not Related to the Sample Content)

Query Description

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.


6.2.2 Using a JSP Tag to Display a Content Selector File

After you have created a Content Selector file (see Section 6.2.1, "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:

  • The rule attribute – Contains the name of the Content Selector file (without the file extension). This attribute tells the JSP tag which personalization rules and query to use.

  • The id attribute – When a Content Selector runs its query, the content is retrieved from the virtual content repository as an array of content properties. The id attribute, which is a String you enter when you set up the JSP tag, serves as a container that holds the array. At this point, you must use other JSP tags to handle the array and display the content. For details on what you can do with the array of properties to display the content, see Section 7.1.1, "Displaying Additional MIME Types in a Placeholder."

There are other attributes you can set on the <pz:contentSelector> tag. See the Oracle Fusion Middleware JSP Tag Java API Reference for Oracle WebLogic Portal for more information on the class.

6.2.2.1 Adding a Content Selector to a JSP

After you create a Content Selector file in Oracle Enterprise Pack for Eclipse, you can use any of the following three methods to add the Content Selector to a JSP in Oracle Enterprise Pack for Eclipse:

  • Drag a Content Selector from the Design Palette onto a page of an open portal file. See the instructions in Section 6.2.2.1.1, "Dragging a Content Selector to a Portal File."

  • Open the JSP to which you want to add the Content Selector, and drag the Content Selector file from the Design Palette into the JSP. The JSP tag is added automatically, the rule attribute is automatically populated with the name of the Content Selector, and the id attribute is included (without a value). The include statement for the tag library is automatically added. See Figure 6-5.

Figure 6-5 Adding a Content Selector to a JSP in Oracle Enterprise Pack for Eclipse

Description of Figure 6-5 follows
Description of "Figure 6-5 Adding a Content Selector to a JSP in Oracle Enterprise Pack for Eclipse"

  • Drag the <pz:contentSelector> JSP tag from the JSP Design Palette window (in the Portal Personalization category) into an open JSP and populate the tag's attributes manually. Get to the JSP Design Palette by choosing Window > Show View > Design Palette. The include statement for the tag library is automatically added.

6.2.2.1.1 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 Design Palette 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.

    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 Example 6-1.

Example 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-6 describes the JSP tags you can use with a Content Selector.

Table 6-6 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.


6.2.2.1.2 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. Example 6-2 demonstrates how to use multiple Content Selectors for personalized content.

Example 6-2 Using the <pz:contentSelector> JSP Tag for Multiple Content Selectors

<%@ taglib uri="http://www.bea.com/servers/portal/tags/content" 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>

6.3 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 Oracle Enterprise Pack for Eclipse 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 Oracle Fusion Middleware Content Management Guide for Oracle WebLogic Portal for instructions.

6.4 Deleting a Content Selector Query

Deleting a Content Selector query removes the query from the Content Selector in Oracle Enterprise Pack for Eclipse 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.

6.5 Deleting a Content Selector

Removing a Content Selector removes it from Oracle Enterprise Pack for Eclipse 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.

6.6 Modifying a Content Selector

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