BEA Logo BEA WLCS Release 3.5

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

 

   WLCS Documentation   |   Developing Campaign Infrastructure   |   Previous Topic   |   Next Topic   |   Contents   |   Index

Setting Up JSP Tags and Scriptlets for Campaigns

 

Campaigns require a minimal set of JSP tags and scriptlets to support their services. In some cases, you might have already added the required JSP tags to implement other Campaign Manager for WebLogic services.

This topic includes the following sections:

For information about the JSP tags that support the e-mail service, refer to Setting Up and Sending E-mail for Campaigns.

 


Creating User Profile Tags to Support Events

To provide information about the customer who interacts with the site, the Event Service must use the <um:getProfile> JSP tag. This tag retrieves information from the customer profile, making it available to the JSP on which the tag resides.

To Create a Get Profile Tag

  1. In a text editor, open a JSP.

  2. Import the tag library by adding the following tag near the top of the JSP:

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

  3. Locate the get profile tag somewhere below the statement to import the um.tld tag library. If any other JSP tag requires the information in the customer profile, locate the get profile tag before the other JSP tag.

  4. Use the following syntax to create the get profile tag:

    <um:getProfile profileKey="name"/>

    where name provides a unique identifier that the Event Service can use to retrieve the profile. If other tags on the JSP require information in the customer profile, you must use additional attributes in the tag. For more information, refer to <um:getProfile> under "JSP Tag Library Reference" in the Guide to Building Personalized Applications.

 


Using Ad Placeholder Tags to Display Ads

After a BA uses the E-Business Control Center to create ad placeholders, a CBE creates ad placeholder tags in the Web site's JSPs. The placeholder definition determines the behavior of the placeholder tag.

You can create placeholders in JSPs that directly display content to a customer (for example, index.jsp) or in JSPs that are included in other JSPs (for example, heading.jsp).

For more information about ad placeholders, refer to "Working with Ad Placeholders" in the Guide to Building Personalized Applications.

To Create an Ad Placeholder Tag

  1. In a text editor, open a JSP.

  2. Import the tag library by adding the following tag near the top of the JSP:

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

  3. Find the location in which the Business Analyst wants to display the ad.

  4. Use the following syntax to use the placeholder tag:

    <ph: placeholder= "{ placeholder-name | scriptlet }" >

    where placeholder-name refers to the name of an existing placeholder definition (see Figure 3-1) or where scriptlet returns the name of an existing placeholder.

    Figure 3-1 Placeholder Names Must Match


     

Listing 3-1 shows an example from the heading include file of the e-commerce sample JSP templates
(WL_COMMERCE_HOME\config\wlcsDomain\applications\wlcsApp\wlcs\commerce\includes\heading.inc).

All JSP files in the e-commerce sample web application include heading.inc to create consistency in the top banner. Instead of requiring the banner on each page to use the same placeholder, the placeholder in heading.inc uses a scriptlet to determine the value of the name attribute. A JSP can use the default value for the name attribute (which is cs_top_generic), or it can specify define a variable named banner and specify a placeholder name as the value for the variable.

Listing 3-1 Using a Scriptlet for the Placeholder Name

<% 
   String banner = (String)pageContext.getAttribute("bannerPh");
banner = (banner == null) ? "cs_top_generic" : banner;
%>
<!-- ------------------------------------------------------------- -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="108">
  <tr><td rowspan="2" width="147" height="108">
<img src="<%=WebflowJSPHelper.createGIFURL(request, response,
"/commerce/images/header_logo.gif")%>" width="147" height="108"></td>
  <td colspan="7" height="75" align="center" valign="middle">
<ph:placeholder name="<%= banner %>" />
</td>

Figure 3-2 illustrates how Campaign Manager for WebLogic renders the placeholder in the main.jsp file, which is the home page for the e-commerce JSP templates.

Figure 3-2 Placeholder in the E-Commerce JSP Templates


 

For more information about the <ph:placeholder> tag, refer to "JSP Tag Library Reference" in the Guide to Building Personalized Applications.

 


Using the <ad:adTarget> JSP Tag to Display Ads

The <ad:adTarget> JSP tag is an additional mechanism for selecting and displaying ads. Use <ad:adTarget> if it is essential that a specific query run in a specific location.

Like an ad placeholder, <ad:adTarget> can do the following:

However, the <ad:adTarget> is unlike ad placeholders in the following ways:

For a more information about <ad:adTarget>, refer to "JSP Tag Library Reference" in the Guide to Building Personalized Applications.

 


Creating Scriptlets to Display Discounts

The Pricing Service calculates the effect of discounts on a customer's order. To display the discount information that the Pricing Service calculates, you can use the following objects and their methods:

This section provides the following subsections:

The Sequence of Applying Discounts in the Shopping Cart

The Pricing Service follows this sequence for applying discounts (see Figure 3-3):

  1. It applies item discounts to each line in the shopping cart.

  2. It calculates a subtotal by adding the price of all lines in the cart.

  3. It calculates an adjusted base price by applying any order discounts to the subtotal (if any order discounts apply).

  4. It calculates a total by applying the shipping cost (including any shipping discounts) to the adjusted base price.

    The following formula summarizes the discount-application process:

    (Sum of line items) + order discounts (if any) + shipping (including any shipping discounts) = total

    Figure 3-3 Discount Sequence


     

The DiscountPresentation Object

The shopping cart uses a line to represent the quantity of a single catalog item that a customer places in the cart. For example, if a customer orders 1 item, the shopping cart contains 1 line. If the customer changes the quantity of the item to 2, the shopping cart still contains 1 line.

For each shopping cart line that receives a discount, the Pricing Service instantiates a DiscountPresentation object to describe the discount. If multiple discounts apply to the line, then the Pricing Service instantiates multiple DiscountPresentation objects. (A line may receive 1 or more discounts, up to the quantity of the line.)

This section includes the following subsections:

Statement to Import the Java Class

To display the information in the DiscountPresentation object on a given JSP, you import the class by including the following statement:

<%@ page import="com.bea.commerce.ebusiness.price.service.DiscountPresentation" %>

shoppingCartLine Method for Retrieving the Object

From any JSP on which you want to display information about discounts for a shopping cart line, you use the following shoppingCartLine method:

The DiscountPresentation Methods

After you use getDiscountPresentations()to retrieve a list of DiscountPresentation objects, you can call DiscountPresentation methods to retrieve discount information. Table 3-1describes the methods.

Table 3-1 DiscountPresentation Methods

Method

Returns Data of Type

Description

getQuantity()

Double

The number of items in the line that are discounted.

getUnitPrice()

Money

The discounted price of a single item.

The com.beasys.axiom.units.Money class defines the Money data type.

getDiscount()

Money

The total price reduction from this discount:

(Number of discounted items) X (The discounted unit price.)

getComputation()

String

The method of computation for the discount. For example, 50% off.

getReason()

String

The reason for the discount as described in the E-Business Control Center. For example, Spring Sale.

getShortText()

String

A concatenation of getComputation() and getReason(). For example, the method can return Discount: 50% off - Spring Sale.


 

For more information on com.bea.commerce.ebusiness.price.service.DiscountPresentation, refer to the Campaign Manager for WebLogic Javadoc.

Example of Discount for Items in the ShoppingCartLine

For purposes of this example, assume that a customer's shopping cart contains only one line with the following information:

quantity 5 hammer-71-UF30588 MSRP: $18.00, "Our Price": $10.00 

The Pricing Service determines that the line is eligible for one discount that offers 50% off the price of up to two hammers. It applies the discount and creates a DiscountPresentation object that contains the following information:

The shopping-cart subtotal is: $40.00 (3 x $10.00 + 2 x $5.00)

Figure 3-4 illustrates a shopping cart that displays the line discount.

Figure 3-4 Discount on Shopping Cart Line


 

The OrderAdjustment and AdjustmentDetail Objects

The Pricing Service always instantiates at least one OrderAdjustment object to describe the shipping cost that is associated with an order. It also instantiates at least one AdjustmentDetail object to provide additional information about the base shipping cost. If an order includes a discount on shipping cost, the Pricing Service creates a second AdjustmentDetail object to describe the shipping discount.

If an order includes a discount that applies to the entire order (for example, 10% off the order subtotal), then the Pricing Service instantiates an OrderAdjustment object to describe the order discount. It also instantiates a single AdjustmentDetail object to provide additional information about the discount. (See Figure 3-5.)

Note that a shopping cart may have an order discount or a shipping discount, but not both. For any given shopping cart with order or shipping discounts, the Price Service creates one of the following:

This section contains the following subsections:

Statements to Import the Java Classes

To display the information in the OrderAdjustment and AdjustmentDetail objects on a given JSP, you import the classes by including the following statements:

<%@ page import="com.bea.commerce.ebusiness.price.quote.OrderAdjustment" %>
<%@ page import="
com.bea.commerce.ebusiness.price.quote.AdjustmentDetail" %>

ShoppingCart Methods for Retrieving the Objects

From any JSP on which you want to display information about discounts on shipping cost and discounts on the overall order, you use the following ShoppingCart methods to retrieve the OrderAdjustment and AdjustmentDetails objects:

Note: Before you can call these methods, you must first use the PriceOrderPC Pipeline component to set them.

Note that attached to each OrderAdjustment object is at least one AdjustmentDetails object, as described in The OrderAdjustment and AdjustmentDetail Objects.

The OrderAdjustment Methods

After you use the ShoppingCart methods to retrieve an OrderAdjustment object, you can use OrderAdjustment methods to retrieve discount or shipping information for the current JSP. Table 3-2 describes the methods that are of general interest to CBEs.

Table 3-2 OrderAdjustment Methods

Method

Returns

Description

getType()

AdjustmentType object

One of the following types of adjustments:

For an example of using getType() to determine the type of order adjustment, refer to Listing 3-2.

getBasePrice()

Money

The initial order price prior to applying the adjustment.

The com.beasys.axiom.units.Money class defines the Money data type.

getActualPrice()

Money

The shipping price or order subtotal after applying discounts.

getAdjustmentAmount()

Money

The order price after applying the adjustment.

getDetails()

List

The list of AdjustmentDetail objects that are associated with the current OrderAdjustment object.

The AdjustmentDetail supplements the information in the OrderAdjustment object.

getCurrency()

String

The currency for all Money objects in this adjustment.


 

For more information on com.bea.commerce.ebusiness.price.quote.OrderAdjustment, refer to the Campaign Manager for WebLogic Javadoc.

Listing 3-2 provides an example of using getType() to determine if the OrderAdjusment object is an ORDER_DISCOUNT type.

Listing 3-2 Using getType()

<%@ page import="com.bea.commerce.ebusiness.price.quote.OrderAdjustment" %>
<%@ page import="
com.bea.commerce.ebusiness.price.quote.AdjustmentDetail" %>
...
OrderAdjustment OrderAdjustment
AdjustmentType type = OrderAdjustment.getType()
if (type.equals(AdjustmentType.ORDER_DISCOUNT))
...

The AdjustmentDetail Methods

After you use the ShoppingCart methods to retrieve an AdjustmentDetail object, you can use AdjustmentDetail methods to retrieve additional information about discount or shipping information for the current JSP. Table 3-3 describes the methods that are of general interest to CBEs.

Table 3-3 AdjustmentDetail Methods

Method

Returns Data of Type

Description

getType()

AdjustmentType object

One of the following types of adjustment details:

getInitialPrice()

Money

The order price before applying the adjustment.

The com.beasys.axiom.units.Money class defines the Money data type.

getEndPrice()

Money

The order price after applying the adjustment.

getComputation()

String

The method of computation for the discount. For example, 50% off.

getReason()

String

The reason for the discount as described in the E-Business Control Center. For example, Spring Sale.

getCurrency()

String

The currency for all Money objects in this adjustment detail.


 

For more information on com.bea.commerce.ebusiness.price.quote.AdjustmentDetail, refer to the Campaign Manager for WebLogic Javadoc.

Example of a Discount for the Order

The Pricing Service determines that the entire order is eligible for a 10% discount. It applies the discount and creates an OrderAdjustment object that contains the following information:

The Pricing Service also creates an AdjustmentDetail object to supplement the information in the OrderAdjustment object. The AdjustmentDetail object contains the following information:

You can use the getOrderDiscountPresentations() method to retrieve the data in the OrderAdjustment and AdjustmentDetails objects. Because a shopping cart can discount either the entire order price or the shipping charges (but not both), you can use a single scriptlet to display either type of discount.

Figure 3-6 shows an example of a JSP that displays an order discount.

Figure 3-6 Order Discount Example


 

Example of a Discount for the Shipping Charges

The Pricing Service always creates an OrderAdjustment object and an AdjustmentDetails object to describe standard shipping charges. You can use the getShippingDiscountPresentations() method to retrieve these objects.

Shipping Cost Without a Shipping Discount

If the shopping cart receives an order discount (and no discount for shipping charges), the shipping OrderAdjustment object would contain the following info:

If the shopping cart receives an order discount (and no discount for shipping charges), the AdjustmentDetail object contains the following:

Shipping Discount Applied to the Shipping Cost

If the shopping cart receives a shipping discount (instead of an order discount), the shopping cart method getOrderDiscountPresentations() would return a null value.

The getShippingDiscountPresentations() would return a single OrderAdjustment object and two AdjustmentDetail objects: one that describes the standard shipping charges and another that describes the shipping discount.

The OrderAdjustment object would contain the following information:

The first AdjustmentDetail object contains the following:

The second AdjustmentDetail object contains the following:

Figure 3-7 shows a JSP that displays a shipping discount.

Figure 3-7 Shipping Discount Example


 
 

 

back to top previous page next page