Develop > Business logic layer > Name-value pair command framework


Command types

WebSphere Commerce commands are Java beans that contain the programming logic associated with handling a particular request. Commands perform a specific business process, such as adding a product to the shopping cart, processing an order, updating a customer's address book, or displaying a specific product page.

Depending on its nature, a command can:

The WebSphere Commerce programming model defines the following command types:

Controller commands

Encapsulate the logic related to a particular business process. Examples of controller commands include the OrderProcessCmd command for order processing and the LogonCmd that allows users to log on. In general, a controller command contains the control statements (for example, if, then, else) and invokes task commands to perform individual tasks in the business process. Upon completion, a controller command returns a view name. Based upon the view name, the store identifier, and the device type, the solution controller determines the appropriate implementation class for the view and then invokes it.

Task commands

Implement a specific unit of application logic. In general, a controller command and a set of task commands together implement the application logic for a URL request. Task commands are executed in the same container as the controller command.

Data bean commands

Are invoked by the data bean manager when a JSP page needs to instantiate a data bean. The primary function of a data bean command is to populate the fields of a data bean with data from a persistent object.

View commands

View commands, used to compose a view as a response to a client request, are deprecated in this release of WebSphere Commerce. Since WebSphere Commerce is a Struts application the view command has been replaced by global forwards. For compatibility with previous releases, view command of previous releases will continue to work.

When creating new business logic for the e-commerce application, it is expected that you might need to create new controller and task commands.

New commands must implement their corresponding interface (which, in turn, should extend an existing interface).

To simplify command writing, WebSphere Commerce includes an abstract implementation class for each type of command. New commands should extend these classes.

The following table shows which implementation class a new command should extend and which interface it should implement:

Command type Example command name Extends Implements example interface
Controller command MyControllerCmdImpl com.ibm.commerce.command.ControllerCommandImpl MyControllerCmd
Task command MyTaskCmdImpl com.ibm.commerce.command.TaskCommandImpl MyTaskCmd
Data bean command MyDataBeanCmdImpl com.ibm.commerce.command.DataBeanCommandImpl MyDataBean


Default commands and views

WebSphere Commerce provides default commands and views which you can use in the store. These default commands and views are listed in the Struts configuration file for the Web application.

Additionally, many of the views used in starter store were created specifically for the store. These views are listed in the struts-config-update.tpl.xml file packaged as part of the store archives. If a required command or view is not provided, you can add the own to the store archive's Struts configuration file.


Related concepts

Command context

Long-running controller commands

Data bean commands

Temporary changes to contextual information for URLs


Related tasks

Enable WebSphere Commerce components


+

Search Tips   |   Advanced Search