# Getting Started: Java Controls

## The Problem of Organizing Business Logic

When you model a real-world problem in a software application, you are faced with modeling the behavior of multiple business objects including the rules that govern their interactions. To model the business objects, you need some way to persistently represent their properties, that is, store the information in a database. To model the rules, you need to be able to break the business logic into smaller subtasks that comprise a complex interaction, and you need to have some way to encapsulate these subtasks such that they can be reused to model other interactions. For instance, if your software application is an online solution for a customer buying books or CDs, you need a way to save information regarding customers, books, CDs, credit cards, and so forth. In addition, buying a CD and buying a book are two tasks that have common subtasks, such as the use of a credit card to pay for the purchased item. You want to be able to separate this subtask and reuse it in both purchase scenarios.

## The Java Control Solution

WebLogic Workshop provides Java controls that make it easy for you to encapsulate business logic and to access enterprise resources such as databases, legacy applications, and external web services. Java controls that access enterprise resources are known as built-in controls. An example of a built-in control is a database control, which specializes in querying relational databases to access stored information.

Java controls that are specifically used to encapsulate business logic are called custom controls. A custom control can invoke other custom controls that handle parts of the larger task. For instance, a custom control that handles a book purchase might invoke another custom control that handles payment of a product by credit card. Also, a custom control can invoke built-in controls, such as a database control to retrieve the data required to execute the business task. For instance, a custom control that handles a book purchase might invoke a database control to verify that the book is still in stock.

## What This Tutorial Teaches

In this tutorial you will learn the basics of using a custom control to encapsulate business logic, and using a database control to query information stored in relational databases. You will create two controls to model a simplified login procedure. The procedure consists of a user submitting a name and receiving a greeting that is based on the number of times the user has submitted his/her name previously. To model this procedure you will create (1) a database control that creates records in a database regarding the number of visits by a user, and (2) a custom control that receives the user input, queries the database control to find out the status of the user, and returns a status-specific greeting.

Related Topics

Getting Started with Java Controls

Click the arrow to navigate to the next step.