Tutorial: Modifying a controller command

This tutorial demonstrates how to modify an existing controller command. In this tutorial, you restrict the number of items in a customer's shopping cart to five or fewer unique items. To implement this solution, you override the OrderItemAddCmdImpl class with your own implementation. The implementation includes logic to check for the number of items in the shopping cart. If a customer attempts to add a sixth item to the shopping cart, an exception is thrown. This exception uses a new error message.

Learning objectives

After completed this tutorial, you should be familiar with the following concepts:
  • OrderItemAddCmdImpl class
  • Controller commands
After completing this tutorial, you should be familiar with the following tasks:
  • Creating implementation for a controller command
  • Updating the command registry so that the new implementation gets used in your application
  • Deploying a modified controller command to a WebSphere Commerce application

Time required

Expect this tutorial to take 30 minutes to complete. The tutorial takes longer if you explore concepts related to this tutorial.

You can load the completed tutorial code instead of performing each step. After loading the completed tutorial code into your workspace, you can run the code as if you performed each step in the tutorial. However, in order to fully attain the learning objectives, it is recommended that you perform the tutorial step by step.

Skill Level

This tutorial is intended for WebSphere Commerce Store developers who are responsible for modifying controller commands. To complete this tutorial you should be familiar with the following terms and concepts:
  1. Rational Application Developer.
  2. The Java programming language.
  3. The database type, Derby, DB2, For IBM i OS operating systemiSeries, or Oracle, used in your WebSphere Commerce development environment.

System requirements

Before beginning this tutorial, ensure that you have completed the following tasks:

  • Publish a sample starter store. In order to complete the deployment steps, the store must exist on the target WebSphere Commerce Server.
  • In the Enterprise Explorer view, ensure that the Toggle Project Grouping button is selected as shown in the following screen capture:
    A screen capture displaying the Toggle Project Grouping button.
    By selecting the Toggle Project Grouping button, you ensure that the view in WebSphere Commerce Developer matches the screen captures and instructions in this tutorial.