BEA Logo BEA WebLogic Portal Release 4.0

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

 

   WebLogic Portal Documentation   |   Product Catalog Management   |   Previous Topic   |   Next Topic   |   Contents   |   Index

Product Catalog JSP Tag Library Reference

 

The Commerce services included in the WebLogic Portal product suite provide 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 PORTAL_HOME is used to represent the directory in which you installed the WebLogic Portal software.

 


Introduction

The JSP templates and JSP tags included in the Commerce services 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 Product Catalog also integrates with the Webflow mechanism, which automatically selects the appropriate JSP for displaying a particular category or product item. The Webflow is set by elements in a centralized Webflow configuration 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.

 


The Catalog JSP Tag Library: cat.tld

Table 6-1 summarizes the tags that comprise the 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" %>
.

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


 

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 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. However, 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 topic 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

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

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 values shown in Table 6-3.

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

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

iterator

Yes

ViewIterator

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

R

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

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

iterator

Yes

ViewIterator

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

R

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

Table 6-6 summarizes the tags that comprise the E-Business JSP Tag Library. To use the functionality provided by an e-business tag, you must import the eb.tld tag library into your JSP file, as follows:

<%@ taglib uri="eb.tld" prefix="eb" %>
.

Table 6-6 E-Business JSP Tag Library

Tag

Description

<eb:smnav>

Controls the presentation of elements in the list of value objects that are being viewed, and provides links to the previous and next pages.


 

<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-7) allows you to control the presentation of elements in the list of value objects that are being viewed, and provides links to the previous and next pages.

The <eb: preface stands for e-business. 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-7 <eb:smnav>

Tag Attribute

Required

Type

Description

R/C

event

No

String

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

C

nextstring

No

String

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

C

origin

No

String

The current JSP page.

C

pageindex

No

String

The index of the page to display.

R

prevstring

No

String

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

C


 

Example

The orderhistory.jsp that is part of the Commerce services JSP templates allows a visitor to browse 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 visitor clicks on the "Next" or "Previous" hyperlinks shown by the tag. In this example, if the visitor 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