Siebel Interactive Selling Transact Server Interface Reference > The Shopping Cart >

Using the Shopping Cart Bean


The ShoppingCartBean class provides the API that is used to access all the information in the cart.

Directly following the "<%@ page" statement, there occurs the JSP statement:

<jsp:useBean id="bean" class="com.siebel.isscda.wl.transact.ShoppingCartBean">
<%
bean.setRequest(request);
bean.setSession(session);
bean.getQuote();
%>
</jsp:useBean>

The "jsp:useBean" tag just includes the ShoppingCartBean class, which implements the API that is used to access all the data which must be displayed in the shopping cart. The "id=bean" indicates that the ShoppingCartBean class will be referred to using the name "bean." If you change this to a different name, replace every instance of "bean" in the template with your new name. The class="com.siebel.isscda.wl.transact.ShoppingCartBean" part of the useBean tag gives the fully qualified name of the ShoppingCartBean class to the JSP compiler so that it is able to find it.

Before the useBean end tag "</jsp:useBean>," there is a code block bracketed by "<%" and "%>". Since "bean" is the name given in the useBean statement to refer to the ShoppingCartBean, bean is used to call into the ShoppingCartBean API. The specific statements in this block of code are initialization statements that must be executed before making any further ShoppingCartBean API calls. These statements are used inside the useBean tags to make sure that they are called directly after the bean is included in the page.

The first statement in the code block above is "bean.setSession(session);". This calls the ShoppingCartAPI function setSession and passes the variable session. The variable session is implicitly made available in all JSP pages (Common JSP behavior). The variable session refers to the HttpSession object defined by the Java class com.java.servlet.http.HttpSession (itself part of the Java servlet API). This session object is specific to the current user's session and can be used to store and retrieve the session state. Transact Server has put a session state into the session object, and so the session is passed into the setSession method of the ShoppingCartBean. This gives the ShoppingCartBean API access to this state information.

The format of the second statement,"bean.setRequest(request);", is similar to that of "bean.setSession(session);". Request is another variable which is implicitly made available to all JSP pages. This statement passes the request variable to the ShoppingCartBean, giving it access to the information contained therein. The request variable refers to the HttpRequest object generated for the HTTP request that brought the user to the ShoppingCart.jsp template. The request variable contains the usual information encapsulated by an HTTP request: any HTML form variables, URL parameters, and the URL itself being the most useful.

The final statement, "bean.getQuote();", gets the information about the current quote from the database. Once this statement is executed, you can start accessing information about the quote, as explained in the following section.


 Siebel Interactive Selling Transact Server Interface Reference 
 Published: 18 April 2003