bea.com | products | dev2dev | support | askBEA
 Download Docs   Site Map   Glossary 
Search

JavaServer Page Guide

 Previous Next Contents View as PDF  

Catalog Development JSP Tags

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:

 


Catalog JSP Tags

This section summarizes the tags that comprise the Product Catalog JSP tag library. 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.

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>

Tag Library

cat.tld

Import Statement

<%@ taglib uri="cat.tld" prefix="catalog" %>

Class Implemented

GetPropertyTag

GetPropertyTagExtraInfo


 

Use the <catalog:getProperty> tag (Table  5-1) 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  5-1 describes the <catalog:getProperty> tag attributes.

Table 5-1 <catalog:getProperty> Tag Attributes

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

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

Listing  5-1 retrieves the detail JSP information from an existing ProductItem:

Listing 5-1 Using <catalog:getProperty>; Example 1

<%@ 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.

Listing 5-2 Using <catalog:getProperty>; Example 2

<%@ 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>

Tag Library

cat.tld

Import Statement

<%@ taglib uri="cat.tld" prefix="catalog" %>

Class Implemented

IterateViewIteratorTag

IterateViewIteratorTagExtraInfo


 

Use the <catalog:iterateViewIterator> tag 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  5-3 describes the <catalog:iterateViewIterator> tag attributes.

Table 5-3 <catalog:iterateViewIterator> Tag Attributes

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

Listing  5-3 displays the keys of all Categories in a ViewIterator:

Listing 5-3 Using <catalog:iterateViewIterator>; Example 1

<%@ 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:

Listing 5-4 Using <catalog:iterateViewIterator>; Example 2

<%@ 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>

Tag Library

cat.tld

Import Statement

<%@ taglib uri="cat.tld" prefix="catalog" %>

Class Implemented

IterateThroughViewTag

IterateThroughViewTagExtraInfo


 

The <catalog:iterateThroughView> tag (Table  5-4) 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  5-4 describes the <catalog:iterateThroughView> tag attributes.

Table 5-4 <catalog:iterateThroughView> Tag Attributes

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

Listing  5-5 displays the keys of all the ProductItems contained in the current View of a specified ViewIterator:

Listing 5-5 Using <catalog:iterateThroughView>; Example 1

<%@ 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:

Listing 5-6 Using <catalog:iterateThroughView>; Example 2

<%@ 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>

 


E-Business JSP Tags

This section summarizes the tags that comprise the E-Business JSP tag library.

.
 

<eb:smnav>

Tag Library

eb.tld

Import Statement

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

Class Implemented

ScrollableModelTag


 

A Scrollable Model is used to retrieve value objects so that only what is viewed is retrieved. The <eb:smnav> tag (Table  5-5) 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  5-5 describes the <eb:smnav> tag attributes.

Table 5-5 <eb:smnav> Tag Atttibutes

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 Listing  5-7, if the visitor has 40 orders and is viewing the second page, the tag will be displayed as "Previous | 20-29 | Next".

Listing 5-7 Using <eb:smnav>

<%@ 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 Next