Sample database application
This chapter is centered on a real-world database application that any developer might create. It uses components from the JBCL and was created using the JBuilder design tools. Where necessary, the code generated by the design tools was modified to provide custom behavior. There are no tutorial steps on this application as it is intended to consolidate the individual "how to" topics in this book.
The completed files for this sample application are included in the samples\borland\samples\tutorial\dataset\dbsample directory of your JBuilder installation under the project name dbSample.jpr.
This application demonstrates the following functionality:
- Connects to the InterBase sample table, employee.gdb, using the Database and QueryDataSet components. (See Connecting to a database using JDBC and Querying a database.)
- Includes a custom menu that offers the same functionality as custom buttons on the application UI. The menus in this application were created using the Menu Builder. For information on creating menus with the Menu Builder, see About the Menu Designer topic in the User Guide.
Menu options are dynamically set and change depending on the current state of the application.
- Contains a GridControl which displays the the data while also demonstrating the following features:
- Includes a StatusBar control that displays navigation information, data validation messages, and so on.
Messages are written to the StatusBar control when appropriate, or when instructed programmatically. (See Displaying status information.)
- Displays a NavigatorControl when the application loads. Use this control to navigate through the data displayed in the grid. The NavigatorControl appears at the same location as the LocatorControl. You toggle which control displays by the corresponding menu option or the button whose text toggles between Display Navigator or Find.
- Allows you to locate data interactively by including the LocatorControl. (See Locating data with the LocatorControl) The LocatorControl is hidden initially and is displayed by clicking the Find button or selecting the corresponding menu option.
The LocatorControl has an associated TextFieldControl called "Find" that acts as the "label" for the LocatorControl. It is displayed when the Find button is pressed.
Pressing the Find button causes the following:
- The Find button changes to a label that says "display navigator".
- The LocatorControl is set to visible by toggling its visible property, and the user types in the value to search for. The LocatorControl watches for Enter to signal the end of the search criterion.
- The LocatorControl performs the search and results are displayed by the StatusBar component.
The LocatorControl disappears (its visible property set to false) when the Display navigator button is pressed.
- Resolves changes made to the data in the QueryDataSet by using default resolver behavior. (See Basic resolving.) The Save button of the NavigatorControl performs the save. Messages regarding the resolve process are displayed in the StatusBar control.
Sample international database application
Writing an international application involves additional complexities which impact application development, for example, using locales other than en_US (American english).
For an example of an international database application that includes many common features of a database application in addition to support for multiple languages and locales, see the IntlDemo.jpr file in the samples\borland\samples\intl directory of your
JBuilder installation.