bea.com | products | dev2dev | support | askBEA |
![]() |
![]() |
|
![]() |
e-docs > WebLogic Platform > WebLogic Portal > JavaServer Page Guide > Personalization JSP Tags |
JavaServer Page Guide
|
Personalization JSP Tags
The JSP tags included with WebLogic Portal allow developers to create personalized applications without having to program using Java.
This section includes information on the following JSP tags:
Ads
The Ad tag queries the content management system and displays ads.
In the following tables, the Required column specifies if the attribute is required (yes) or optional (no). In the R/C column, C means that the attribute is a Compile time expression, and R means that the attribute can be either a Request time expression or a Compile time expression.
<ad:adTarget>
The <ad:adTarget> (Table 3-1) uses the Ad Service to send an ad query to the content management system. Unlike the <ph:placeholder> tag, the query in the <ad:adTarget> tag does not compete with other queries in an ad placeholder. Use this tag if you need to make sure that a given ad displays to customers in a specific location. Depending on how narrowly you construct the query, you might have to remove or modify this tag when you want to display a different ad. If the ad query returns more than one ad, the Ad Service uses the adWeight attribute of each ad to determine which ad to display.
How the Tag Maps to the Content Management Service Provider Interface The following table shows how the tag accesses methods in the content management service provider interface (SPI). The table also shows the sequence of calls.
Tag Attributes
Table 3-1 describes the <ad:adTarget> tag attributes.
Example Listing 3-1 picks one of the ads in the ad group "Car" and renders it in a space measuring 200 x 400 pixels. Listing 3-1 Using <ad:adTarget>
<%@ taglib uri="ad.tld" prefix="ad" %>
.
.
.
<ad:adTarget query="group == 'ads'" />
Content Management
The Content Management component includes four JSP tags. These tags allow a JSP developer to include non-personalized content in a HTML-based page. The cm:select and cm:selectbyid tags support content caching for content searches. Note that none of the tags support or use a body.
In the following tables, the Required column specifies if the attribute is required (yes) or optional (no). In the R/C column, C means that the attribute is a Compile time expression, and R means that the attribute can be either a Request time expression or a Compile time expression.
<cm:getProperty>
The <cm:getProperty> tag retrieves the value of the specified content metadata property into a variable specified by resultId. It does not have a body. If resultId is not specified, the value will be inlined into the page, similar to the <cm:printProperty> tag. This tag operates on any ConfigurableEntity, not just the Content object. However, it does not support ConfigurableEntity successors. How the Tag Maps to the Content Management Service Provider Interface Because this tag receives data that has already been retrieved from the content management system, it makes no calls to the content management service provider interface (SPI). Tag Attributes Table 3-2 describes the <cm:getProperty> tag attributes.
Example Listing 3-2 shows how to use <cm:getProperty> to get the String value of the name property from the Content object stored at doc and place it in the contentName variable. Listing 3-2 Using <cm:getProperty> <%@ taglib uri="cm.tld" prefix="cm" %> <cm:printDoc>
.
.
.
<cm:getProperty resultId="contentName" resultType="String"
id="content" name="name" />
<es:notNull item="<%=contentName%>">
The name is not null.
</es:notNull>
The <cm:printDoc> tag inlines the raw bytes of a Document object into the JSP output stream. This tag does not support a body and only supports Document objects. It does not differentiate between text and binary data.
How the Tag Maps to the Content Management Service Provider Interface The following table shows how the tag accesses methods in the content management service provider interface (SPI). The table also shows the sequence of calls.
Tag Attributes
Table 3-3 describes the <cm:printDoc> tag attributes.
Note: If baseHref is provided, then the <cm:printDoc> tag will output a starting <BASE HREF> using the value of the baseHref parameter. If baseHref is not a fully complete URL, the missing parts will be filled in based upon the URL of the outermost page.
Additionally, if baseHref is provided, then, after printing the document, the <cm:printDoc> tag will output a <BASE HREF> based upon the URL of the outermost page.
Example
Listing 3-3 shows how to use <cm:printDoc> to get a Document object from an id in the request attributes and inline the Document's text (which might contain relative links).
Listing 3-3 Using <cm:printDoc>
<%@ taglib uri="cm.tld" prefix="cm" %>
.
.
.
.<% String contentId = request.getParameter("contentId"); %>
<cm:selectById contentId="<%=contentId%>" id="doc" />
<cm:printDoc id="doc" blockSize="1000" baseHref="/ShowDocServlet" />
<cm:printProperty>
The <cm:printProperty> tag inlines the value of the specified content metadata property as a string. It does not have a body. This tag operates on any ConfigurableEntity, not just the Content object. However, it does not support ConfigurableEntity successors.
How the Tag Maps to the Content Management Service Provider Interface Because this tag receives data that has already been retrieved from the content management system, it makes no calls to the content management service provider interface (SPI). Tag Attributes Table 3-4 describes the <cm:printProperty> tag attributes.
Example Listing 3-4 shows how to use <cm:printProperty> to have a text input field's default value be the first 75 characters of the subject of a Content object stored at doc: Listing 3-4 Using <cm:printProperty> <cm:select>
<%@ taglib uri="cm.tld" prefix="cm" %>
.
.
.
<form action="javascript:void(0)">
Subject: <input type="text" size="75" name="subject"
value="<cm:printProperty id="doc" name="Subject" maxLength="75"
encode="html"/>" >
</form>
This tag uses only the search expression query syntax to select content. It does not support or use a body. After this tag has returned the <es:forEachInArray> tag (see <es:forEachInArray>,) zero can be used to iterate over the array of Content objects. This tag supports generic Content via a ContentManager interface.
How the Tag Maps to the Content Management Service Provider Interface The following table shows how the tag accesses methods in the content management service provider interface (SPI). The table also shows the sequence of calls.
Tag Attributes
Table 3-5 describes the <cm:select> tag attributes.
Example Listing 3-5 shows how to use <cm:select> to find the first five text Content objects that are marked as news items for the evening using the ContentCache, and print out the titles in a list: Listing 3-5 Using <cm:select> <cm:selectById>
<%@ taglib uri="cm.tld" prefix="cm" %>
.
.
.
<cm:select contentHome="<%=ContentHelper.DEF_CONTENT_MANAGER_HOME%>" max="5" useCache="true" cacheTimeout="300000" cacheId="Evening News" sortBy="creationDate ASC, title ASC" query="
type = `News' && timeOfDay = `Evening' && mimetype like
`text/*' " id="newsList"/><ul>
<es:forEachInArray array="<%=newsList%>" id="newsItem"
type="com.bea.p13n.content.Content">
<li><cm:printProperty id="newsItem" name="Title"
encode="html" />
</es:forEachInArray>
</ul>
The <cm:selectById> tag (Table 3-6) retrieves content using the Content's unique identifier. This tag does not have a body. This tag is basically a wrapper around the select tag. It works against any Content object which has a string-capable primary key.
How the Tag Maps to the Content Management Service Provider Interface The following table shows how the tag accesses methods in the content management service provider interface (SPI). The table also shows the sequence of calls.
Tag Attributes
Table 3-6 describes the <cm:selectById> tag attributes.
Example Listing 3-6 shows how to use <cm:selectById > to fetch the Document (using ContentCaching) with an identifier of 1234 and inline its content. Listing 3-6 Using <cm:selectById >
<%@ taglib uri="cm.tld" prefix="cm" %>
.
.
.
<cm:selectById contentHome="<%=ContentHelper.DEF_CONTENT_MANAGER_HOME%>"
contentId="contentportlet/sports1.htm"
id="doc" useCache="true" cacheTimeout="300000" cacheId="1234" />
<cm:printDoc id="doc" />
Internationalization
These tags are used in the localization of JSP pages that have an internationalization requirement.
In the following tables, the Required column specifies if the attribute is required (yes) or optional (no). In the R/C column, C means that the attribute is a Compile time expression, and R means that the attribute can be either a Request time expression or a Compile time expression.
Note: With the <i18n> tags, you can point to resource bundle files that contain localized content for display in your JSPs. For information on setting the interval at which WebLogic Portal checks for updated resource bundle content, see "Internationalization Performance Tuning" in the Administration Guide at http://download.oracle.com/docs/cd/E13218_01/wlp/docs70/admin/sysadmin.htm.
<i18n:localize>
This tag allows you to define the language, country, variant, and base bundle name to be used throughout a page when accessing resource bundles via the <i18n:getmessage> tag. This tag also specifies a character encoding and content type to be specified for a JSP page. Because of this, the tag should be used as early in the page as possible—before anything is written to the output stream—so that the bytes are properly encoded.
When an HTML page is included in a larger page, only the larger page can use the <i18n:localize> tag. This is because the <i18n:localize> tag sets the encoding for the page, and the encoding must be set in the parent (including) page before any bytes are written to the response's output stream. The parent page must set an encoding that is sufficient for all the content on that page as well as any included pages. The preferred approach is to retrieve all strings dynamically from the <i18n:getMessage> tag, and avoid embedding strings statically (that is, avoid hard-coding them) in your JSP page. If your page contains only dynamic strings (strings retrieved using the <i18n:getMessage tag>), then do not use the <i18n:localize> tag in conjunction with the <%@ page contentType="<something>" > page directive defined in the JSP specification. The directive is unnecessary if you are using the <i18n:localize> tag, and can result in inconsistent or wrong contentType declarations. If you must mix static strings and dynamic strings on the same page, then you will need to use the page directive. Ensure that the character set specified by the <i18n:localize> tag is compatible with the character set specified in the page directive. Tag Attributes Table 3-7 describes the <i18n:localize> tag attributes.
Example 1 Listing 3-7 shows how to use <i18n:localize> to define a single language preference. Listing 3-7 Using <i18n:localize>; Example 1 <%@ taglib uri="i18n.tld" prefix="i18n" %> Example 2 Listing 3-8 shows how to use <i18n:localize> to define two language preferences, English and Spanish. Listing 3-8 Using <i18n:localize>; Example 2 <%@ taglib uri="i18n.tld" prefix="i18n" %> <i18n:getMessage>
.
.
.
<%
// Definition of a single language preference
String language = "en";
%> <i18n:localize language="<%=language%>" bundleName="i18nExampleResourceBundle"/>
<html>
<body>
<i18n:getMessage messageName="greeting"/>
</body>
</html>
.
.
.
<%
// Array that defines two languages preferences - English and
// Spanish in that order of preference.
String[] languages = new String[] { "en", "es" }; %>
<i18n:localize language="<%=languages%>" bundleName="i18nExampleResourceBundle"/>
<html>
<body>
<i18n:getMessage messageName="greeting"/>
</body>
</html>
This tag is used in conjunction with the <i18n:localize> tag to retrieve localized static text or messages from a JspMessageBundle.
Tag Attributes Table 3-8 describes the <i18n:getMessage> tag attributes.
Example 1 Listing 3-9 produces this output: when included in a JSP. Listing 3-9 The following code shows the entries in the property file named i18nExampleResourceBundle. properties: greeting=Welcome To This Page!
Welcome To This Page! 14 out of 100 files have been saved
<%@ taglib uri="i18n.tld" prefix="i18n" %>
.
.
.
<%
// Definition of a single language preference
String language = "en"; // Creation of message arguments
Object[] args = new Object[]
{
new Integer(14),
new Integer(100)
};
%> <i18n:localize language="<%=language%>" bundleName="i18nExampleResourceBundle"/>
<html>
<body>
<i18n:getMessage messageName="greeting"/>
<i18n:getMessage messageName="message" messageArgs="<%=args%>"/>
</body>
</html>
message={0} out of {1} files have been saved.
Personalization Tags
The <pz:div> tag, <pz:contentSelector> tag, and <pz:contentQuery> tag use the Advisor to classify the user, select content, and retrieve content, respectively.
In the following tables, the Required column specifies if the attribute is required (yes) or optional (no). In the R/C column, C means that the attribute is a Compile time expression, and R means that the attribute can be either a Request time expression or a Compile time expression.
This section contains information on the following subjects:
pz Tags and the Internal Cache
Content search contextParams support per-search configuration attributes and can be used to determine whether to use the internal cache. The <cm:select> and <cm:selectById> tags support setting the contextParams, but the pz tags do not. In order to control whether a <pz:contentSelector> uses the internal cache, use the following approach.
Add the following to a <pz:content*> tag:
contextParams="someName=someValue"
A runtime expression like the following should be used:
contextParams='<%="aName=aValue bName=bValue cName=cValue"%>'
<pz:contentQuery>
The <pz:contentQuery> tag performs a content attribute search for content in a content manager. If the useCache attribute is set to true, the results of a content management query will be cached. The tag only has a begin tag and does not have a body or end tag. It returns an array of Content objects returned from the content manager as the result of executing the content query. Personalization content tags required for JSP developers to access the Content object returned might include: An object array iterator tag. This tag provides a way to iterate over the Content objects in the array. Use the <es:forEachInArray> tag to iterate over an array of Objects. (See <es:forEachInArray> for more information.)
How the Tag Maps to the Content Management Service Provider Interface
The following table shows how the tag accesses methods in the content management service provider interface (SPI). The table also shows the sequence of calls.
Tag Attributes
Table 3-9 describes the <pz:contentQuery> tag attributes.
Example Listing 3-10 shows how to use <pz:contentQuery>. Listing 3-10 Using <pz:contentQuery> <pz:contentSelector>
<%@ page import="bea.p13n.content.ContentHelper" %>
<%@ taglib uri="es.tld" prefix="es" %>
<%@ taglib uri="cm.tld" prefix="cm" %>
<%@ taglib uri="pz.tld" prefix="pz" %>
.
.
.
<pz:contentQuery id="docs" contentHome="<%=ContentHelper.DEF_DOCUMENT_MANAGER_HOME%>"
query="author = 'Hemingway'" /><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>
The <pz:contentSelector> tag allows arbitrary personalized content to be recommended based on a content selector rule. A content selector rule first evaluates a set of conditions that you define in the E-Business Control Center (for example, whether or not a user fits a specified classification). If the conditions evaluate to true, content is retrieved from the Content Manager based on a content query defined in the E-Business Control Center. Note: Rules are created in the E-Business Control Center. This GUI tool is designed to allow Business Analysts to develop their own customer segments. Because the Business Analysts are not exposed to the concept of rules, you will see content selector rules called simply "content selectors" and classifier rules referred to as "customer segmentation." To cache the results of the content selector rule, set the useCache attribute to true. If the cache has not timed out, subsequent calls to the <pz:contentSelector> tag will return the cached results without re-evaluating the content query. The <pz:contentSelector> tag only has a begin tag and does not have a body or end tag. It returns an array of Content objects returned from the Content Manager as a result of executing the content query. Tags possibly required for JSP developers to access the Content objects returned might include:
How the Tag Maps to the Content Management Service Provider Interface
The following table shows how the tag accesses methods in the content management service provider interface (SPI). The table also shows the sequence of calls.
Tag Attributes
Table 3-10 describes the <pz:contentSelector> tag attributes.
Specify a Value for contentHome 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 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. Example Listing 3-10 shows how to use <pz:contentSelector>. Listing 3-11 Using <pz:contentSelector> Note: The sortBy attribute, when used in conjunction with the max attribute, works differently for explicit (system-defined) and implicit (user-defined) attributes. If you sort on explicit attributes (identifier, mimeType, size, version, author, creationDate, modifiedBy, modifiedDate, lockedBy, description, or comments) the sort is done on the database; therefore if you combine max="10" and sortBy, the system will perform the sort and then get the first 10 items. If you sort on implicit attributes, the sort is done after the max have been selected. <pz:div>
contentHome="<%=ContentHelper.DEF_DOCUMENT_MANAGER_HOME %>"
... /> <%@ page import="com.bea.p13n.content.ContentHelper" %>
<%@ taglib uri="es.tld" prefix="es" %>
<%@ taglib uri="cm.tld" prefix="cm" %>
<%@ taglib uri="pz.tld" prefix="pz" %>
<%@ taglib uri="um.tld" prefix="um" %>
.
.
.
<um:getProfile profileKey="bob"
profileId="myProfile" scope="session"/>
<pz:contentSelector rule="PremierCustomerSpotlight"
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>
The <pz:div> tag allows a piece of content to be conditionally included as a result of a classifier rule being executed by the rules engine. If the user's profile matches the classification specified in the E-Business Control Center, then the conditional content is included. This tag has a begin tag, a body, and an end tag. The tag returns a list of Classification objects that the user belongs to. Tag Attributes Table 3-11 describes the <pz:div> tag attributes.
Example
<%@ taglib uri="pz.tld" prefix="pz" %>
<%@ taglib uri="um.tld" prefix="um" %>
<um:getProfile profileKey="bob"
profileId="myProfile" scope="session"/>
<pz:div id="classifications" rule="PremierCustomer">
<%
//if the user is classified as a Premier Customer, a list with one entry should be returned//
java.util.Iterator iterator=classifications.iterator();
while (iterator.hasNext())
{
com.bea.p13n.user. Classification classification=(Classification) iterator.next();
out.println (classification.getName());
}
%> <p>Please check out our new Premier Customer bonus program.<p>
</pz:div>
Placeholders
The placeholder tag is a named location on a JSP. You use the E-Business Control Center to define the behavior of a placeholder.
In the following tables, the Required column specifies if the attribute is required (yes) or optional (no). In the R/C column, C means that the attribute is a Compile time expression, and R means that the attribute can be either a Request time expression or a Compile time expression.
<ph:placeholder>
The <ph:placeholder> tag implements a placeholder, which describes the behavior for a location on a JSP page. You use the E-Business Control Center to define a placeholder. Multiple placeholder tags can refer to the same placeholder. Each instance of a placeholder tag invokes its placeholder definition separately. If the placeholder definition specifies multiple queries, each placeholder tag instance can display different ads, even though each instance shares the same definition. When WebLogic Portal receives a request for a JSP that contains an ad placeholder, the placeholder tag contacts the Ad Service, a session EJB that invokes business logic to determine which ad to display. For information on a related tag, see <ad:adTarget>. How the Tag Maps to the Content Management Service Provider Interface The following table shows how the tag accesses methods in the content management service provider interface (SPI). The table also shows the sequence of calls.
Tag Attributes
Table 3-12 describes the <ph:placeholder> tag attributes.
Example Listing 3-12 displays the ad specified in the MainPageBanner placeholder. Listing 3-12 Using <ph:placeholder>
<%@ taglib uri="ph.tld" prefix="ph" %>
.
.
.
<ph:placeholder name="/placeholders/MainPageBanner.pla"/>
Property Sets
The Property Set tags allow access to the list of available properties and property sets. Property sets are manipulated through the E-Business Control Center.
All Property Sets tags send results to the same file. If you are checking for results, include this import directive at the top of the page:
<%@ page import="com.bea.p13n.property.servlets.jsp.taglib.PropertySetTag-
Constants" %>
In the following tables, the Required column specifies if the attribute is required (yes) or optional (no). In the R/C column, C means that the attribute is a Compile time expression, and R means that the attribute can be either a Request time expression or a Compile time expression.
<ps:getPropertyNames>
The <ps:getPropertyNames> tag is used to get a list of property names given a property set.
Tag Attributes Table 3-13 describes the <ps:getPropertyNames> tag attributes.
Example Listing 3-13 shows how to use <ps:getPropertyNames>. Listing 3-13 Using <ps:getPropertyNames> <ps:getPropertySetNames>
<%@ taglib uri="ps.tld" prefix="ps" %>
<%@ page import=
"com.bea.p13n.property.servlets.jsp.taglib.PropertySetTagConstants"
%> <% String myPropertySet="Demographics"; %>
<p> ------- <b>ps:getPropertyNames</b> -------------
<br>
<ps:getPropertyNames propertySetName="<%= myPropertySet %>"
propertySetType="USER" id="propertyNames" result="myResult"/>
<% for (int i=0; i<propertyNames.length; i++)
out.println(propertyNames[i] + "<br>");
%>
The <ps:getPropertySetNames> tag (Table 3-14) is used to get a list of property sets given a property set type. Tag Attributes Table 3-14 describes the <ps:getPropertySetNames> tag attributes.
Example Listing 3-14 shows how to use <ps:getPropertySetNames>. Listing 3-14 Using <ps:getPropertySetNames> <%@ taglib uri="ps.tld" prefix="ps" %> <ps:getRestrictedPropertyValues>
.
.
.
<ps:getPropertySetNames propertySetType="USER"
id="userPropertySets" result="myResult" />
The <ps:getRestrictedPropertyValues> tag returns a list of restricted values for a specific property definition, converted into Strings. These values will be returned as an array of Strings. Tag Attributes Table 3-15 describes the <ps:getRestrictedPropertyValues> tag attributes.
Example Listing 3-15 shows how to use <ps:getRestrictedPropertyValues>. Listing 3-15 Using <ps:getRestrictedPropertyValues>
<%@ taglib uri="ps.tld" prefix="ps" %>
<%@ page import=
"com.bea.p13n.property.servlets.jsp.taglib.PropertySetTagConstants"
%><p> ---- <b>ps:getRestrictedPropertyValues</b> -----
<br>Possible values for PreferredLanguage:<ps:getRestrictedPropertyValues propertySetName="Demographics"
propertySetType="USER" propertyName="PreferredLanguage"
id="values" result="myResult"/><ul>
<% if (myResult.intValue() == PropertySetTagConstants.PROPERTY_SEARCH_OK)
{
for ( int i=0; i<values.length; i++ ) {
%><li><%=values[i]%>
<% }
}
%>
</ul>
User Management:
Profile Management Tags
User Management tags allow access to user and group profile information, as well as operations such as creating and deleting users and groups, and managing user-group relationships.
In the following tables, the Required column specifies if the attribute is required (yes) or optional (no). In the R/C column, C means that the attribute is a Compile time expression, and R means that the attribute can be either a Request time expression or a Compile time expression.
<um:getProfile>
The <um:getProfile> tag (Table 3-16) retrieves the profile corresponding to the provided profile key and profile type. The tag has no enclosed body. The retrieved profile can be treated as a com.bea.p13n.usermgmt.profile.ProfileWrapper. Along with the profile key and profile, an explicit successor key and successor type can be specified, as specified by the profileType attribute. This successor will then be used, along with the retrieved profile, in subsequent invocations of the <um:getProperty> tag to ensure property inheritance from the successor. If no successor is retrieved, standard ConfigurableEntity successor search patterns will apply to retrieved properties. Tag Attributes Table 3-16 describes the <um:getProfile> tag attributes.
Example 1 Listing 3-16 shows a profile being retrieved with no successor specified and an explicitly-supplied session scope. Listing 3-16 Using <um:getProfile>; Example 1 Example 2 Listing 3-17 shows a default user profile type being retrieved with a default successor type and an explicitly-supplied request scope. Listing 3-17 Using <um:getProfile>; Example 2 <um:getProperty>
<%@ taglib uri="um.tld" prefix="um" %>
.
.
.
<um:getProfile profileKey="bob" profileType="AcmeUser"
profileId="myProfile" scope="session"/><%@ taglib uri="um.tld" prefix="um" %>
.
.
.
<um:getProfile profileKey="bob" successorKey="engineering" scope="request"/>
The <um:getProperty> tag retrieves the property value for a specified property set-property name pair. The tag has no enclosed body. The value returned is an Object. In typical cases, this tag is used after the <um:getProfile> tag is invoked to retrieve a profile for session use. The property to be retrieved is retrieved from the session profile. If the <um:getProfile> tag has not been used upon invoking the <um:getProperty> tag, the specified property value is retrieved from the Anonymous User Profile. Tag Attributes Table 3-17 describes the <um:getProperty> tag attributes.
Example 1 Listing 3-18 shows how to use <um:getProperty>. Listing 3-18 Using <um:getProperty> <um:getPropertyAsString>
<%@ taglib uri="um.tld" prefix="um" %>
.
.
.
<um:getProperty id="myBirthDate" propertySet="Demographics" propertyName="Date_of_Birth"/>
My birthday is <%=myBirthDate%>.
The <um:getPropertyAsString> tag works exactly like the <um:getProperty> tag above, but ensures that the retrieved property value is a String. The following example shows a multi-valued property which returns a Collection, but presents a list of favorite colors. Tag Attributes Table 3-18 describes the <um:getPropertyAsString> tag attributes.
Example Listing 3-19 shows how to use <um:getPropertyAsString>. Listing 3-19 Using <um:getPropertyAsString> <um:removeProperty>
<%@ taglib uri="um.tld" prefix="um" %>
.
.
.
<um:getPropertyAsString id="myBirthDate" propertySet="Demographics" propertyName="Date_of_Birth"/>
My birthday is <%=myBirthDate%>.
The <um:removeProperty> tag (Table 3-19) removes the specified property from the current session's profile or from the Anonymous User Profile. The tag has no enclosed body. Subsequent calls to <um:getProperty> for a removed property would result in the default value for the property as prescribed by the property set, or from the Profile's successor. Tag Attributes Table 3-19 describes the <um:removeProperty> tag attributes.
Example Listing 3-20 shows how to use <um:removeProperty> to remove a property. Listing 3-20 Using <um:removeProperty> <um:setProperty>
<%@ taglib uri="um.tld" prefix="um" %>
.
.
.
<um:removeProperty propertySet="<%=thePropertySet%>" propertyName="<%=thePropertyName%>"/>
The <um:setProperty> tag updates a property value for either the session's current profile, or for the Anonymous User Profile. This tag has no enclosed body. Tag Attributes Table 3-20 describes the <um:setProperty> tag attributes.
Example Listing 3-21 shows how to use <um:setProperty>. Listing 3-21 Using <um:setProperty>
<%@ taglib uri="um.tld" prefix="um" %>
.
.
.
<% String myGender = request.getParameter("gender"); %>
<um:setProperty propertySet="Demographics" propertyName="Gender" value="<%=myGender%>"/>
User Management:
Group-User Management Tags
User Management tags allow access to user and group profile information, as well as operations such as creating and deleting users and groups, and managing user-group relationships.
In the following tables, the Required column specifies if the attribute is required (yes) or optional (no). In the R/C column, C means that the attribute is a Compile time expression, and R means that the attribute can be either a Request time expression or a Compile time expression.
The <um:addGroupToGroup> tag (Table 3-21) adds the group corresponding to the provided childGroupName to the group corresponding to the provided groupName. Since a group can only have one parent, any previous database records which reflect the group belonging to another parent will be destroyed. Both the parent group and the child group must previously exist for proper tag behavior. The tag has no enclosed body. Note: This tag should only be invoked when the current realm is an implementation of weblogic.security.acl.ManageableRealm. This interface is implemented by the default WebLogic Portal realm (com.bea.p13n.security.realm.RDBMSRealm). Tag Attributes Table 3-21 describes the <um:addGroupToGroup> tag attributes.
Example Listing 3-22 shows how to use <um:addGroupToGroup> to add a new group of users to an existing group of users. Listing 3-22 Using <um:addGroupToGroup> <um:addUserToGroup>
<%@ taglib uri="um.tld" prefix="um" %>
.
.
.
<um:addGroupToGroup childGroupName="<%=childGroupName%>" parentGroupName="<%=parentGroupName%>" result="result"/>
The <um:addUserToGroup> tag adds the user corresponding to the provided username to the group corresponding to the provided groupName. Both the specified user and the specified group must previously exist for proper tag behavior. The tag has no enclosed body. Note: This tag should only be invoked when the current realm is an implementation of weblogic.security.acl.ManageableRealm. This interface is implemented by the default WebLogic Portal realm (com.bea.p13n.security.realm.RDBMSRealm). Tag Attributes Table 3-22 describes the <um:addUserToGroup> tag attributes.
Example Listing 3-23 shows how to use <um:addUserToGroup> to add a new user to an existing group. Listing 3-23 Using <um:addUserToGroup> <um:createGroup>
<%@ taglib uri="um.tld" prefix="um" %>
.
.
.
<um:addUserToGroup username="<%=username%>" groupName="<%=groupName%>" result="result"/>
The <um:createGroup> tag (Table 3-23) creates a new group in the realm, and a corresponding group profile in the personalization database. This tag has no enclosed body. Note: This tag should only be invoked when the current realm is an implementation of weblogic.security.acl.ManageableRealm. This interface is implemented by the default WebLogic Portal realm (com.bea.p13n.security.realm.RDBMSRealm). Tag Attributes Table 3-23 describes the <um:createGroup> tag attributes.
Example Listing 3-24 shows how to use <um:creategroup> to create a new group. Listing 3-24 Using <um:creategroup> <um:createUser>
<%@ taglib uri="um.tld" prefix="um" %>
.
.
.
<um:creategroup groupName="<%=groupName%>" result="result"/>
The <um:createUser> tag creates a new user profile. This tag has no enclosed body. Although classified as a Group-User management tag, this tag can be used in conjunction with run-time activities, in that it will persist any properties associated with a current Anonymous User Profile if specified. Note: This tag should only be invoked when the current realm is an implementation of weblogic.security.acl.ManageableRealm. This interface is implemented by the default WebLogic Portal realm (com.bea.p13n.security.realm.RDBMSRealm). Tag Attributes Table 3-24 describes the <um:createUser> tag attributes.
Example Listing 3-25 shows how to use <um:createUser> to create a new user. Listing 3-25 Using <um:createUser> <um:getChildGroupNames>
<%@ taglib uri="um.tld" prefix="um" %>
.
<um:createUser username="<%=username%>" password="<%=password"%> result="result"/>
The <um:getChildGroupNames> tag returns the names of any groups that are children of the given group. Tag Attributes Table 3-25 describes the <um:getChildGroupNames> tag attributes.
Example Listing 3-26 shows how to use <um:getChildGroupNames> to retrieve the names of a child group for the group SomeGroup. Listing 3-26 Using <um:getChildGroupNames> <%@ taglib uri="um.tld" prefix="um" %> <um:getGroupNamesForUser>
.
.
.
<um:getChildGroupNames groupName="SomeGroup"
id="childrenOfSomeGroup" />
The <um:getGroupNamesForUser> tag retrieves a String array that contains the group names corresponding to groups to which the provided user immediately belongs. This tag has no enclosed body. Tag Attributes Table 3-26 describes the <um:getGroupNamesForUser> tag attributes.
Example Listing 3-27 shows how to use <um:getGroupNamesForUser> to retrieve a group name to apply to a user. Listing 3-27 Using <um:getGroupNamesForUser> <um:getParentGroupName>
<%@ taglib uri="um.tld" prefix="um" %>
.
.
.
<um:getGroupNamesForUser username="<%=username%>" id="myGroups"/>
The <um:getParentGroupName> tag retrieves the name of the parent of the group associated with the provided groupName. The information is taken from the realm. This tag has no enclosed body. Tag Attributes Table 3-27 describes the <um:getParentGroupName> tag attributes.
Example Listing 3-28 shows how to use <um:getParentGroupName> to retrieve a parent group name. Listing 3-28 Using <um:getParentGroupName> <um:getTopLevelGroups>
<%@ taglib uri="um.tld" prefix="um" %>
.
.
.
<um:getParentGroupName groupName="<%=groupName%>" id="parentGroupName"/>
The <um:getTopLevelGroups> tag retrieves an array of group names, each of which has no parent group. The information is taken from the realm. This tag has no enclosed body. Tag Attributes Table 3-28 describes the <um:getTopLevelGroups> tag attributes.
Example Listing 3-29 shows how to use <um:getTopLevelGroups>. Listing 3-29 Using <um:getTopLevelGroups> <um:getUsernames>
<%@ taglib uri="um.tld" prefix="um" %>
.
.
.
<um:getTopLevelGroups id="topLevelGroups"/>
The <um:getUsernames> tag retrieves a String array that contains the usernames matching the provided search expression. The search expression supports only the asterisk (*) wildcard character, and is case insensitive. As many asterisks as desired may be used in the search expression. This tag has no enclosed body. Tag Attributes Table 3-29 describes the <um:getUsernames> tag attributes.
Note: The USER_SEARCH_FAILED value is returned only when a general error occurs while searching for the user, such as a database connection failure. If no user matches the search criteria, the result will not be equal to UserManagementTagConstants.USER_SEARCH_FAILED, but the length returned by the array in id will be zero. Example Listing 3-30 shows how to use <um:getUsernames> to retrieve a username. Listing 3-30 Using <um:getUsernames> <um:getUsernamesForGroup>
<%@ taglib uri="um.tld" prefix="um" %>
.
.
.
<um:getUsernames userLimit="500" searchExp="t*" id="myUsers"/>
<%System.out.println("I found " + myUsers.length + " users.");%>
The <um:getUsernamesForGroup> tag retrieves a String array that contains the usernames matching the provided search expression and correspond to members of the provided group. The search expression supports only the asterisk (*) wildcard character, and is case insensitive. As many asterisks as desired may be used in the search expression. This tag has no enclosed body. Tag Attributes Table 3-30 describes the <um:getUsernamesForGroup> tag attributes.
Note: The USER_SEARCH_FAILED value is returned only when a general error occurs while searching for the user, such as a database connection failure. If no user matches the search criteria, the result will not be equal to UserManagementTagConstants.USER_SEARCH_FAILED, but the length returned by the array in id will be zero. Example Listing 3-31 shows how to use <um:getUsernamesForGroup> to retrieve usernames that match the provided search expression and correspond to members of the provided group. Listing 3-31 Using <um:getUsernamesForGroup> <um:removeGroup>
<%@ taglib uri="um.tld" prefix="um" %>
.
.
.
<um:getUsernamesForGroup groupName="engineering" userLimit="500" searchExp="t*" id="myUsers"/>
<%System.out.println("I found " + myUsers.length + " users in my group.");%>
The <um:removeGroup> tag removes the group corresponding to the provided groupName. This tag has no enclosed body. Note: This tag should only be invoked when the current realm is an implementation of weblogic.security.acl.ManageableRealm. This interface is implemented by the default WebLogic Portal realm (com.bea.p13n.security.realm.RDBMSRealm). Tag Attributes Table 3-31 describes the <um:removeGroup> tag attributes.
Example Listing 3-32 shows how to use <um:removeGroup> to remove a group that corresponds to the provided groupName. Listing 3-32 Using <um:removeGroup> <um:removeGroupFromGroup>
<%@ taglib uri="um.tld" prefix="um" %>
.
.
.
<um:removeGroup groupName="<%=groupName%>" result="result"/>
The <um:removeGroupFromGroup> tag removes a child group from a parent group. Tag Attributes Table 3-32 describes the <um:removeGroupFromGroup> tag attributes.
Example Listing 3-33 shows how to use <um:removeGroupFromGroup> to remove a child group from a parent group. Listing 3-33 Using <um:removeGroupFromGroup> <um:removeUser>
The <um:removeUser> tag removes the user corresponding to the provided username. It can remove any type of extended user that has its profileType set in the database. This tag has no enclosed body. Note: This tag should only be invoked when the current realm is an implementation of weblogic.security.acl.ManageableRealm. This interface is implemented by the default WebLogic Portal realm (com.bea.p13n.security.realm.RDBMSRealm). Tag Attributes Table 3-33 describes the <um:removeUser> tag attributes.
Example Listing 3-34 shows how to use <um:removeUser> to remove a user. Listing 3-34 Using <um:removeUser> <um:removeUserFromGroup>
<%@ taglib uri="um.tld" prefix="um" %>
.
.
.
<um:removeUser username="<%=username%>" result="result"/>
The <um:removeUserFromGroup> tag removes a user from a group. Note: This tag should only be invoked when the current realm is an implementation of weblogic.security.acl.ManageableRealm. This interface is implemented by the default WebLogic Portal realm (com.bea.p13n.security.realm.RDBMSRealm). Tag Attributes Table 3-34 describes the <um:removeUserFromGroup> tag attributes.
Example Listing 3-35 shows how to use <um:removeUserFromGroup> to remove a specified user from a specified group. Listing 3-35 Using <um:removeUserFromGroup> <%@ taglib uri="um.tld" prefix="um" %>
.
.
.
<um:removeUserFromGroup username="UserToRemove"
groupName="SomeGroup" result="myResult" />
User Management: Security Tags
User Management tags allow access to user and group profile information, as well as operations such as creating and deleting users and groups, and managing user-group relationships.
In the following tables, the Required column specifies if the attribute is required (yes) or optional (no). In the R/C column, C means that the attribute is a Compile time expression, and R means that the attribute can be either a Request time expression or a Compile time expression.
<um:login>
The <um:login> tag provides weak authentication (username, password) against the current security realm, and sets the authenticated user as the current WebLogic user. This tag has no enclosed body. Note: The login tag requires a username parameter and a password parameter to be present in the HTTP request. Tag Attributes Table 3-35 describes the <um:login> tag attributes.
<um:logout>
The <um:logout> tag ends the current user's WebLogic Server session. This tag should be used in combination with the <um:login> tag. Tag Attributes Table 3-36 describes the <um:logout> tag attributes.
The <um:setPassword> tag updates the password for the user corresponding to the provided username. Note: This tag should only be invoked when the current realm is an implementation of weblogic.security.acl.ManageableRealm. This interface is implemented by the default WebLogic Portal realm (com.bea.p13n.security.realm.RDBMSRealm). In addition, the user object used by the current realm must implement weblogic.security.acl.CredentialChanger. Tag Attributes Table 3-37 describes the <um:setPassword> tag attributes.
Personalization Utilities
The <es:jsptaglib> tag contains generic tags you can use to create JSP pages.
In the following tables, the Required column specifies if the attribute is required (yes) or optional (no). In the R/C column, C means that the attribute is a Compile time expression, and R means that the attribute can be either a Request time expression or a Compile time expression.
<es:convertSpecialChars>
The <es:convertSpecialChars> tag converts characters which would normally signify special meaning to an HTML browser into characters which can be displayed as intended. For example, the following sentence must be converted because it uses the "<" and ">"characters, which signify tag opening and closing to the browser: Enter <filename> here: Tag Attributes Table 3-38 describes the <es:convertSpecialChars> tag attributes.
Example Listing 3-36 allows a string containing a less-than sign to be rendered in HTML. Listing 3-36 Using <es:convertSpecialChars> <es:counter>
<%@ taglib uri="es.tld" prefix="es" %>
.
.
.
<es:convertSpecialChars string="<thisString>"/>
The <es:counter> tag is used to create a for loop. Tag Attributes Table 3-39 describes the <es:counter> tag attributes.
Example Listing 3-37 shows how to use <es:counter>. Listing 3-37 Using <es:counter> <es:date>
<%@ taglib uri="es.tld" prefix="es" %>
.
.
.
<es:counter id="iterator" minCount="0" maxCount="10">
<% System.out.println(iterator);%>
</es:counter>
The <es:date> tag is used to get a date- and time-formatted String based on the user's time zone preference. Tag Attributes Table 3-40 describes the <es:date> tag attributes.
Example Listing 3-38 shows how <es:date> is used to retrieve a time and date. Listing 3-38 Using <es:date> <es:forEachInArray>
<%@ taglib uri="es.tld" prefix="es" %>
.
.
.
<es:date formatStr="MMMM dd yyyy" timeZoneId="MST" />
The <es:forEachInArray> tag is used to iterate over an array. Tag Attributes Table 3-41 describes the <es:forEachInArray> tag attributes.
Example Listing 3-39 shows how to use <es:forEachInArray> to iterate over an array. Listing 3-39 Using <es:forEachInArray> <es:isNull>
<es:forEachInArray id="item" array="<%=items%>" type="String" counterId="i">
<% System.out.println("items[" + i + "]: " + item);%>
</es:forEachInArray>
The <es:isNull> tag is used to check if a value is null. In the case of a String, the <es:isNull> tag is used to check if the String is null or has a value. An empty string will cause isNull to be false. (An empty string is not null.) Tag Attributes Table 3-42 describes the <es:isNull> tag attributes.
Example Listing 3-40 shows how to use <es:isNull> to check if a value is null. Listing 3-40 Using <es:isNull> <es:notNull>
<%@ taglib uri="es.tld" prefix="es" %>
.
.
.
<es:isNull item="<%=value%>">
Error: the value is null.
</es:isNull>
The <es:notNull> tag is used to check if a value is not null. In the case of a String, the <es:notNull> tag is used to check if the String is not null or has a value. An empty string will cause notNull to be true. (An empty string is treated as a value.) Tag Attributes Table 3-43 describes the <es:notNull> tag attributes.
Example Listing 3-41 shows how to use <es:notNull> to check if a value is not null. Listing 3-41 Using <es:notNull> <es:transposeArray>
<%@ taglib uri="es.tld" prefix="es" %>
.
.
.
<es:notNull item="<%=value%>">
The value is not null.
</es:notNull>
The <es:transposeArray> tag is used to transpose a standard [row][column] array to a [column][row] array. Tag Attributes Table 3-44 describes the <es:transposeArray> tag attributes.
Example Listing 3-42 shows how to use <es:transposeArray>. Listing 3-42 Using <es:transposeArray> <es:uriContent>
<%@ taglib uri="es.tld" prefix="es" %>
.
.
.
<es:transposeArray id="byColumnRow" array="<%=byRowColumn%>" type="String">
...
</es:transposeArray>
The <es:uriContent> tag is used to pull content from a URL. It is best used for grabbing text-heavy pages. Tag Attributes Table 3-45 describes the <es:uriContent> tag attributes.
Example Listing 3-43 shows how to use <es:uriContent> to pull content from a URL. Listing 3-43 Using <es:uriContent> Note: If you combine HTML pages with relative URL's, you must fully qualify them to the correct host in each URL, or else images (on other resources) may not be retrieved properly by the browser.
<%@ taglib uri="es.tld" prefix="es" %>
.
.
.
<es:uriContent id="uriContent" uri="http://www.beasys.com/index.html">
<%
out.print(uriContent);
%>
</es:uriContent>
WebLogic Utilities
The <wl:jsptaglib> tag library contains custom JSP extension tags which are supplied as a part of the WebLogic Server platform.
In the following tables, the Required column specifies if the attribute is required (yes) or optional (no). In the R/C column, C means that the attribute is a Compile time expression, and R means that the attribute can be either a Request time expression or a Compile time expression.
<wl:cache>
The <wl:cache> tag specifies that its contents do not necessarily need to be updated every time it is displayed. Tag Attributes Table 3-46 describes the <wl:cache> tag attributes.
<wl:process>
The <wl:process> tag is used for query attribute-based flow control. By using a combination of the four attributes, you can selectively execute the statements between the <wl:process> and </wl:process> tags, as shown in Listing 3-44. Tag Attributes Table 3-47 describes the <wl:process> tag attributes.
Statements between the <wl:process> tags will be executed according to the matrix below:
Example Listing 3-44 shows how to use <wl:process>. It will execute if lastBookRead exists and the value of lastBookRead is A Man in Full. Listing 3-44 Using <wl:process> <wl:repeat>
<%@ taglib uri="weblogic.tld" prefix="wl" %>
.
.
.
<wl:process name="lastBookRead" value="A Man in Full">
<!-- This section of code will be executed
if lastBookRead exists and the value of lastBookRead is
"A Man in Full" -->
</wl:process>
The <wl:repeat> tag is used to iterate over a variety of Java objects, as specified in the set attribute. Tag Attributes Table 3-48 describes the <wl:repeat> tag attributes.
![]() |
![]() |
![]() |
![]() |
||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |