Develop > Presentation layer > Work with JSP pages


WebSphere Commerce useBean tag

The useBean tag instantiates a WebSphere Commerce data bean and automatically populates it for you. A new programming direction has also been undertaken with our starter stores that now use the JavaServer Pages Standard Tag Library (JSTL) to perform view logic, instead of Java code. At the same time, business logic has been moving into data beans. The combination of these steps allows for less Java code in a JSP page.

The useBean tag takes the following attributes:

id

Required: The ID that the new bean will have. This ID must be a valid Java identifier and must be unique as it is also used to create a new scripting variable for the JSP page. The ID must also be unique to a page.

classname

Required: The class for the data bean that will be instantiated.

scope

The scope in which the bean should be stored such as page, request, session, and application. The default scope is page.

In order to be able to use the new useBean tag library, a JSP page must first be told how to locate the tag. In order to locate and use the new tag, the following line must be located at the top of the JSP file:

<%@ taglib uri="http://commerce.ibm.com/base" prefix="wcbase"
%>

This line will make the useBean tag available to the JSP page with the prefix of wcbase.

The following are examples of using the useBean tag:

   
<wcbase:useBean
id="orderBean"classname="com.ibm.commerce.order.beans.OrderDataBean"scope="page"/>


Related concepts

WebSphere Commerce JSP viewer


+

Search Tips   |   Advanced Search