BEA Logo BEA WLCS Release 3.5

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

 

   WLCS Documentation   |   Product Catalog   |   Previous Topic   |   Next Topic   |   Contents   |   Index

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.

Table 6-1 JSP Tag Library

Tag

Description

<catalog:getProperty>

Retrieves a property for display from a specified ProductItem or Category. Either explicit or implicit properties may be retrieved.

<catalog:iterateViewIterator>

Iterates a specified ViewIterator. The ViewIterator may be iterated either by View (one View per iteration) or by contained Catalog item (one ProductItem or Category per iteration).

<catalog:iterateThroughView>

Iterates a specified ViewIterator through the ProductItems or Categories contained within a specified View.


 

 


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.

Table 6-2 <catalog:getProperty>

Tag Attribute

Required

Type

Description

R/C

object

yes

Catalog item

Denotes a reference to a ProductItem or Category object that must be presented in the form <%= objectReference %>.

R

propertyName

yes

String

propertyName="propertyName"

Name of the property to retrieve. If the property is explicit, it may be one of the following values shown in Table 6-3.

R

getterArgument

no

String

Denotes a reference to an object supplied as an argument to an explicit property getter method.

May also be used to obtain implicit or custom properties that are defined using the property set framework, in which case the getterArgument would be the scope name for the property set (see second example below).

The object must be presented in the form <%= getterArgumentReference %> and must be a run-time expression.

R

id

no

String

id="newInstance"

If the id attribute is supplied, the value of the retrieved property will be available in the variable name to which id is assigned. Otherwise, the value of the property is inlined.

C

returnType

no

String

returnType="returnType"

If the id attribute is supplied, declares the type of the variable specified by the id attribute.

C


 

Table 6-3 propertyName Values

Property Name

Catalog Item Type

"contributor | coverage | creationDate | creator | description | image | key | language | modifiedDate | name | publisher | relation | rights | source"

Catalog Item (common properties)

"jsp"

Category

"availability | currentPrice | format | jsp | msrp | shippingCode | taxCode | type | visible"

ProductItem


 

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.

Table 6-4 <catalog:iterateViewIterator>

Tag Attribute

Required

Type

Description

R/C

iterator

yes

ViewIterator

Denotes a reference to a ViewIterator object. Must be presented in the form <%= iteratorReference %>.

R

id

yes

String

id="newInstance"

The value of the current iterated object will be available in the variable name to which the id is assigned.

C

iterateByView

no

String

iterateByView="{true|false}"

Specifies whether to iterate the ViewIterator by View or by Catalog item. If not specified, the ViewIterator will be iterated by Catalog item.

C

returnType

no

String

returnType="returnType"

Declares the type of the variable specified by the id attribute. Defaults to java.lang.Object.

If iterateByView is true, the type is assumed to be com.beasys.commerce.ebusiness.catalog.View.

C


 

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.

Table 6-5 <catalog:iterateThroughView>

Tag Attribute

Required

Type

Description

R/C

iterator

yes

ViewIterator

Denotes a reference to a ViewIterator object that must be presented in the form <%= iteratorReference %>

R

id

yes

String

id="newInstance"

The value of the current iterated object will be available in the variable name to which the id is assigned.

C

returnType

no

String

returnType="returnType"

Declares the type of the variable specified by the id attribute. Defaults to java.lang.Object.

C

viewIndex

no

Integer

Specifies the index of the View (relative to the start of the ViewIterator) through which to iterate. The referenced object must be presented in the form <%= viewIndexIntegerReference %>.

R


 

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.

Table 6-6 <eb:smnav>

Tag Attribute

Required

Type

Description

R/C

Origin

yes

String

The current jsp page.

R

Event

yes

String

The name of the link configurable in the Webflow as the user clicks on Next or Previous .

R

Prevstring

yes

String

The localized name for Previous. Could be as simple as "<" .

R

Nextstring

yes

String

The localized name for Next. Could be as simple as ">".

R

PageIndex

no

String

The index of the page to display.

C


 

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%>" />

 

back to top previous page next page