Tutorial 1: Simple Forms-Based Application

This tutorial describes how to build a simple form-based database application that allows users to view and edit customer records from the Accounts table. Using Database Xcessory, you simply select fields from the Schema Browser window and drag them to the application under construction. Database Xcessory will automatically set all the resources to the correct values.

A Simple Forms-Based Application

Creating the Container

Widgets in an Xt (X Toolkit) based application are arranged in a hierarchical parent-child structure. Shell widgets are parents to containers that contain other containers and more fundamental primitive widgets. The primitive widgets are usually the ones into which you enter data and with which you interact.

Any window in your finished application must have a container, which must be inside a shell. The container holds the widgets that make up the form.

Using Database Xcessory, all you have to do to begin is create a container. This is because Database Xcessory will automatically create a shell if you create a container without a parent.

Bulletin board

The container we'll use in this application is a bulletin board (XmBulletinBoard). The bulletin board allows you to place children (labelled text fields, in this case) anywhere inside the bulletin board. A bulletin board imposes no constraints on the position of its children. The advantage of using the bulletin board as a container is that it is very easy to use. The disadvantage, for more sophisticated applications, is that it doesn't do anything special when the user resizes the window.

Creating a bulletin board

Use the following steps to create a bulletin board widget that will serve as the parent widget for the XiDBDataField widgets you will create later in this tutorial.

  1. In the Palette, click on the Containers tab to display the Container widgets.
  2. Click on Bulletin Board.

Notice the square widget outline that appears.

  1. Move the outline to the location on the root window where you want to place the bulletin board.
  2. Hold down MB1 and drag down and to the right to resize the widget to 4 inches wide by 3 inches long on your display.

A top level shell widget is automatically created with a bulletin board inside of it. The hierarchy of these widgets is displayed as a tree display in the Browser window. The top level shell is typically used for windows that will be displayed most often in an application. You can create other types of shells, depending on the application. These are described in the Builder Xcessory Users Guide andBuilder Xcessory Reference Manual.

Using the Schema Browser to Add Data Fields

Oracle users

  • Because Oracle is case-insensitive, the Schema Browser renders all names uniformly in uppercase.

Once you've created a container, the next step is to add the labelled data fields using the Schema Browser window. You can use the Schema Browser as if it were a palette of Data Presentation widgets. Drag field names from the Schema Browser to the application. Database Xcessory then creates data fields, graphs, tables, and other Data Presentation widgets with the resources automatically set to display and edit that field (if editable; for example, if you create a graph instead of a data field, that graph is not editable).

Adding labeled fields

Use the following steps to add labelled data fields as children of the bulletin board container you have already created:

  • Select Sample Data from the View menu to display the Sample Data window at the bottom of the Schema Browser window.
  • Select OrderEntry from the Database list (Sybase users) or DBPak from the Owner list (Oracle users).

The Database list (Sybase) or Owner list (Oracle) is located in the upper right corner of the Schema Browser. To display all available databases (Sybase), or owners (Oracle), click on the down arrow. Click on a database name (in this case, OrderEntry) or owner name (in this case DBPak) to select it.

  • Select Accounts from the Tables list.

The Tables list is located on the left side of the Schema Browser. Click on the Accounts table to select it.

The Columns window list now shows all the columns that correspond to the Accounts table along with their data types. The Sample Data window at the bottom of the Schema Browser now displays data that has been read from the first set of rows in the table. 

Declarations of Accounts Table (Sybase version).

Selecting Data Fields

Check that Data Field is selected in the Object Type option menu of the Schema Browser. (The Object Type option menu is located in the upper left corner of the Schema Browser.)

To display the option menu:

  • Click on the currently-selected menu item.
  • To make a new selection, click on a different menu item. That item is then displayed as the currently-selected menu item, and the option menu is no longer displayed.

The Object Type option menu displays the type of widget that will be created when you drag a field from the Schema Browser. Most other DBPak widgets can also be created with the Schema Browser.

Toggling on the Labeled Fields

Check that Labeled Fields is toggled on in the Schema Browser Option menu. The Option menu is in the menu bar at the top of the Schema Browser. The Labeled Fields menu option is toggled on by default.

  • Select Account_Number, Name, Address, and City from the column list, and drag them on to the Bulletin Board.


Multiple Columns Selected

One XiDBDataField will be created in your interface for each column definition selected. These widgets are pre-configured to display data from the columns selected in the Schema Browser.

Database Xcessory creates the Data Source, Query and Data Field widgets. The children of the bulletin board, in the Browser object instance hierarchy look like the Instance Hierarchy shown below:

Instance Hierarchy

Notice that two objects, q_Accounts (Query widget) and orderEntry (Database Access widget) for Sybase, or q_ACCOUNTS andtest for Oracle, have been created but are not physica>