Document Information


Part I Introduction

1.  Overview

2.  Using the Tutorial Examples

Part II The Web Tier

3.  Getting Started with Web Applications

4.  Java Servlet Technology

5.  JavaServer Pages Technology

6.  JavaServer Pages Documents

7.  JavaServer Pages Standard Tag Library

8.  Custom Tags in JSP Pages

9.  Scripting in JSP Pages

10.  JavaServer Faces Technology

11.  Using JavaServer Faces Technology in JSP Pages

12.  Developing with JavaServer Faces Technology

13.  Creating Custom UI Components

14.  Configuring JavaServer Faces Applications

15.  Internationalizing and Localizing Web Applications

Part III Web Services

16.  Building Web Services with JAX-WS

17.  Binding between XML Schema and Java Classes

18.  Streaming API for XML

19.  SOAP with Attachments API for Java

Part IV Enterprise Beans

20.  Enterprise Beans

21.  Getting Started with Enterprise Beans

22.  Session Bean Examples

23.  A Message-Driven Bean Example

Part V Persistence

24.  Introduction to the Java Persistence API

25.  Persistence in the Web Tier

26.  Persistence in the EJB Tier

27.  The Java Persistence Query Language

Part VI Services

28.  Introduction to Security in the Java EE Platform

29.  Securing Java EE Applications

30.  Securing Web Applications

31.  The Java Message Service API

32.  Java EE Examples Using the JMS API

33.  Transactions

34.  Resource Connections

35.  Connector Architecture

Part VII Case Studies

36.  The Coffee Break Application

37.  The Duke's Bank Application

Overview of the Duke's Bank Application

Enterprise Beans

Session Beans

The AccountControllerBean Session Bean

The CustomerControllerBean Session Bean

The TxControllerBean Session Bean

Java Persistence Entities

Helper Classes

Database Tables

Tables Representing Business Entities

Protecting the Enterprise Beans

Web Client

Design Strategies

Client Components

Request Processing

Protecting the Web Client Resources

Building, Packaging, Deploying, and Running the Duke's Bank Application

Setting Up the Servers

Starting the Application Server

Creating the Bank Database in NetBeans IDE

Creating the Bank Database Using Ant

Adding Users and Groups to the File Realm

Building, Packaging, and Deploying Duke's Bank Using NetBeans IDE

Building, Packaging, and Deploying Duke's Bank Using Ant

Running the Duke's Bank Application Client Using NetBeans IDE

Running the Duke's Bank Application Client Using Ant

Running the Duke's Bank Web Client

Part VIII Appendixes

A.  Java Encoding Schemes

B.  About the Authors



Application Client

Sometimes, enterprise applications use a stand-alone client application for handling tasks such as system or application administration. For example, the Duke’s Bank application uses an application client to administer customers and accounts. This capability is useful in the event that the site becomes inaccessible for any reason or if a customer prefers to communicate things such as changes to account information by phone.

The application client shown in Figure 37-3 handles basic customer and account administration for the banking application through a Swing user interface. The bank administrator can perform any of the following functions on the respective tabs.

Figure 37-3 Application Client

Screenshot of the Duke's Bank application client for the application admin.

Customer Info tab:

  • View customer information

  • Add a new customer to the database

  • Update customer information

  • Remove a customer

  • Find a customer’s ID

Account administration:

  • Create a new account

  • Add a new customer to an existing account

  • Remove a customer from an existing account

  • View account information

  • Remove an account from the database

Error and informational messages appear in the bottom under Messages.

The Classes and Their Relationships

The source code for the application client is in the following directory:


The application client is consists of a single class: BankAdmin.

BankAdmin Class

The BankAdmin class, which creates the user interface, is a Swing class that provides action methods that are called when certain events occur in the application, and methods that call the controller session beans. It was created using the NetBeans IDE Swing editor, Matisse.

Note - Although BankAdmin was written using NetBeans IDE, you do not need to have NetBeans installed in order to run the application. If you want to alter the user interface, however, you do need to use NetBeans IDE.

The BankAdmin Constructor

The BankAdmin constructor creates the initial user interface, which consists of a menu bar, two tabs, and a message pane, by calling the initComponents method. The menu bar contains the standard File and Edit menus, the left tab is for viewing and updating customer information, the right tab is for viewing and updating account information, and the message pane contains a message area.

The initComponents method is automatically generated by NetBeans IDE. It creates all the user interface elements visible in BankAdmin.

Class Methods

The BankAdmin class provides methods that other objects call when they need to update the user interface. These methods are as follows:

  • setCustomerTextFields: When true enables the user to enter or change information in the customer tab. When false, the fields are disabled.

  • fillCustomerTextFields: Uses a CustomerDetails object to display customer information in the customer tab

  • clearCustomerTextFields: Clears the contents of the customer fields in the customer tab

  • setAccountTextFields: When true enables the user to enter or change information in the account tab. When false, the fields are disabled.

  • fillAccountTextFields: Uses an AccountDetails object to display account information in the account tab

  • clearAccountTextFields: Clears the contents of the account fields in the account tab

  • resetAll: Calls setCustomerTextFields and setAccountFields, setting all the fields to disabled

The following methods interact with the controller session beans to create and update customer and account information:

  • createAccount: uses an AccountDetails object to create a new account

  • updateAccount: uses an AccountDetails object to update an account information

  • createCustomer: uses a CustomerDetails object to create a new customer

  • updateCustomer: uses a CustomerDetails object to update a customer’s information

The UI-elementMouseReleased methods are linked to the GUI controls in BankAdmin. They call the previous methods to enable/disable the GUI fields, and create/update accounts and customers.