![]() |
![]() |
|
|
Product Catalog JSP Tag Library Reference
The BEA WebLogic Commerce Server provides JavaServer Page (JSP) templates and JSP tags that implement commonly used Web-based Product Catalog features. The Product Catalog JSP templates allow your customers to search for product items or browse through categories to locate items; the JSP tags are used to implement this functionality.
This topic includes the following sections:
Note: In this topic, the environment variable WL_COMMERCE_HOME is used to represent the directory in which you installed the WebLogic Commerce Server software.
Introduction
The JSP templates and JSP tags included in the BEA WebLogic Commerce Server allow you to easily customize the presentation of the Product Catalog. The names of the JSPs for categories and product items are stored in the database as attributes of the categories and items. (See The Product Catalog Database Schema, for information about the DISPLAY_JSP_URL column in the WLCS_CATEGORY database table, and the SUM_DISPLAY_JSP_URL column [a pointer to the item's summary page] and the DET_DISPLAY_JSP_URL column [a pointer to the item's detail page] in the WLCS_PROD_ITEM database table.)
The WebLogic Commerce Server Product Catalog integrates with the Webflow engine, which automatically selects the appropriate JSP for displaying a particular category or product item. The Webflow is set by entries in the webflow.properties file, as explained in the Guide to Managing Presentation and Business Logic: Using Webflow and Pipeline documentation.
JSP tag libraries allow you to easily retrieve the attributes of items and categories in the Product Catalog. You can then format these attributes using HTML tags. Any HTML editor can be used to create custom layouts. You can also include custom Java code within the JSPs to display categories and items. Table 6-1 describes the catalog tags in the JSP Tag Library.
The Catalog JSP Tag Library: cat.tld
Table 6-1 summarizes the tags that comprise the WebLogic Commerce Server Product Catalog JSP Tag Library. To use the functionality provided by a catalog tag, you must import the cat.tld tag library into your JSP file, as follows:
<%@ taglib uri="cat.tld" prefix="catalog" %>
These tags are used in the JSP templates that comprise the default Product Catalog. You can add or remove tags in your use of the JSP templates to match your specific formatting requirements.
The tag elements always start with <catalog: and are followed by the type of operation and one or more parameters. The operation, such as getProperty, always follows <catalog: without a space or breaking line. You do include a space between the tag element name and its parameters. Each parameter uses an equal sign and the parameter's value is enclosed in double quotes. End each tag with the forward slash, followed by the closing angle bracket: />.
Subsequent sections in this chapter describe the tags in more detail.
Note: 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.
<catalog:getProperty>
Use the <catalog:getProperty> tag (Table 6-2) to retrieve a property for display from either a ProductItem or Category. The property can either be an explicit property (a property that can be retrieved using a get method on the Catalog item) or an implicit property (a property available through the ConfigurableEntity getProperty methods on the Catalog item). The tag first checks to see if the specified property can be retrieved as an explicit property. If it cannot, the specified property is retrieved as an implicit property.
Example 1
This example retrieves the Detail JSP information from an existing ProductItem:
<%@ taglib uri="cat.tld" prefix="catalog" %>
.
.
.
<catalog:getProperty
object="<%= item %>"
propertyName="Jsp"
getterArgument=
"<%= new Integer(ProductItem.DETAILED_DISPLAY_JSP_INDEX) %>"
id="detailJspInfo"
returnType="com.beasys.commerce.ebusiness.catalog.JspInfo"
/>
Example 2
The following example shows how to use the getterArgument attribute to obtain an implicit or custom property for a property set/schema with the following characteristics:
Note: Because the getterArgument must be a run-time expression, we assign MyCatalog to a String variable and use the variable as the value to the getterArgument.
<%@ taglib uri="cat.tld" prefix="catalog" %>
.
.
.
<%
String myPropertySetName = "MyCatalog";
ProductItem myProductItem = .....; // reference to a ProductItem
%>
<catalog:getProperty
object="<%=myProductItem%>
propertyName="color"
getterArgument="<%=myPropertySetName%>"
/>
<catalog:iterateViewIterator>
Use the <catalog:iterateViewIterator> tag (Table 6-4) to iterate through a ViewIterator. A ViewIterator is an iterator over a potentially large collection of remote data that is broken up into a series of fixed sized Views. ViewIterators are returned from all Catalog service API methods that may potentially return a large set of ProductItems or Categories. This tag allows you to iterate the ViewIterator one item (ProductItem or Category) at a time (the default behavior) or by an entire View (fixed size set of ProductItems or Categories) at a time. It is important to note that this tag does not reset the state of the ViewIterator upon completion.
Example 1
The following example displays the keys of all Categories in a ViewIterator:
<%@ taglib uri="cat.tld" prefix="catalog" %>
.
.
.
<catalog:iterateViewIterator
iterator="<%= myIterator %>"
id="category"
returnType="com.beasys.commerce.ebusiness.catalog.Category">
<%= category.getKey().toString() %>
</catalog:iterateViewIterator>
Example 2
The following example displays all the Views contained within a ViewIterator:
<%@ taglib uri="cat.tld" prefix="catalog" %>
.
.
.
<catalog:iterateViewIterator
iterator="<%= myIterator %>"
id="view"
returnType="com.beasys.commerce.ebusiness.catalog.ViewIterator"
iterateByView="true">
<%= view.toString() %>
</catalog:iterateViewIterator>
<catalog:iterateThroughView>
The <catalog:iterateThroughView> tag (Table 6-5) iterates through a View of a specified ViewIterator. The tag will iterate the View one Catalog item at a time until the end of the View is reached. If you do not specify a specific View (by index) through which to iterate, the current View of the ViewIterator is used. It is important to note that this tag does not reset the state of the ViewIterator upon completion.
Example 1
The following example displays the keys of all the ProductItems contained in the current View of a specified ViewIterator:
<%@ taglib uri="cat.tld" prefix="catalog" %>
.
.
.
<catalog:iterateThroughView
iterator="<%= myIterator %>"
id="item"
returnType="com.beasys.commerce.ebusiness.catalog.ProductItem">
<%= item.getKey().toString() %>
</catalog:iterateThroughView>
Example 2
The following example displays the keys of all the ProductItems contained in the first View of a specified ViewIterator:
<%@ taglib uri="cat.tld" prefix="catalog" %>
.
.
.
<catalog:iterateThroughView
iterator="<%= myIterator %>"
id="item"
returnType="com.beasys.commerce.ebusiness.catalog.ProductItem"
viewIndex="new Integer(0)">
<%= item.getKey().toString() %>
</catalog:iterateThroughView>
The E-Business JSP Tag Library: eb.tld
The <eb:> preface stands for E-Business. The eb.tld tag library consists of just one tag, <eb:smnav>.
To import the E-Business JSP tag, use the following code:
<%@ taglib uri="eb.tld" prefix="eb" %>
Note: In the following table, 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.
<eb:smnav>
A Scrollable Model is used to retrieve value objects so that only what is viewed is retrieved. The <eb:smnav> tag (Table 6-6) provides a presentation of which elements in the list of value objects are being viewed, and potentially a link to the previous page and one to the next page.
The Scrollable Model can be use throughout the E-Business package to iterate through a list of objects. It can be used in conjunction with transaction, shopping cart, order history, or shipping services.
This tag relies on a pipeline session containing a ScrollableModel object on the PipelineSessionConstants.SCROLLABLE_MODEL key.
Example
The orderhistory.jsp page lets the user go page by page over the set of orders placed. Only 10 orders are displayed at a time. To go to the next or to the previous page, the user clicks on the "Next" or "Previous" hyperlinks shown by the tag. In this example, if the user has 40 orders and is viewing the second page, the tag will be displayed as "Previous | 20-29 | Next".
<%@ taglib uri="eb.tld" prefix="eb" %>
.
.
.
<!-- Show the Previous / 10-19 / Next navigation string -->
<eb:smnav origin="orderhistory.jsp" event="link(viewOrderHistory)"
prevstring="Previous" nextstring="Next"
pageindex="<%=pageIndexString%>" />
![]() |
![]() |
![]() |
|
Copyright © 2001 BEA Systems, Inc. All rights reserved.
|