Database application development is a feature of JBuilder Professional and Enterprise. Distributed application development is a feature of JBuilder Enterprise.
Many data applications provide status information about the data in addition to displaying the data itself. For example, a particular area of a window often contains information on the current row position, error messages, and other similar information. dbSwing includes a JdbStatusLabel
component which provides a mechanism for such status information. It has a text
property that allows you to assign a text string to be displayed in the JdbStatusLabel
. This string overwrites the existing contents of the JdbStatusLabel
and is overwritten itself when the next string is written to the JdbStatusLabel
.
The JdbStatusLabel
component automatically connects to whichever DataSet
has focus. The JdbStatusLabel
component doesn't display the data from the DataSet
but displays the following status information generated by the DataSet
:
To add the JdbStatusLabel
to the UI of your existing application:
JdbStatusLabel
. This application should include a JdbTable
component, a Database
component, and a QueryDataSet
component. If you do not have such an application, use the files created for the "Retrieving data for the tutorials" topic.
Make sure the layout for the project's contentPane
is set to null
.
Double-click the Frame
file in the project pane of the AppBrowser to open it in the content pane, then click the Design tab that appears at the bottom of the AppBrowser.
Click the dbSwing tab of the component palette and click the JdbStatusLabel
component.
Draw the JdbStatusLabel
below the JdbTable
component. jdbStatusLabel1
component automatically connects to whichever DataSet
object has focus.
You typically use a JdbStatusLabel
component in conjunction with another UI component, usually a JdbTable
that displays the data from the DataSet
. This sets both components to track the same DataSet
and is often referred to as a shared cursor
.
Once the JdbStatusLabel
is added, you'll notice that the JdbStatusLabel
component displays information that the cursor is on Row 1 of x (where x is the number of records in the DataSet
).
Double-click the QueryDataSet
. This displays the Column designer. Select the
Last_Name and First_Name columns and set the required
property to true
for both in the Inspector. Set the SALARY column's min
property to 25000.
Run the application.
To test its display of validation information:
JdbStatusLabel
indicating that the row cannot be posted due to invalid or missing field values.
Enter a value for the FIRST_NAME and LAST_NAME columns. Enter a number in the SALARY column (1000) that doesn't meet the minimum value. When you attempt to move off the row, the JdbStatusLabel
displays the same message that the row cannot be posted due to invalid or missing field values.
By setting the text of the JdbStatusLabel
at relevant points in your program programmatically, you can overwrite the current message displayed in the JdbStatusLabel
with your specified text. This text message, in turn, gets overwritten when the next text is set or when the next DataSet
status message is generated. The status message can result from a navigation through the data in the table, validation errors when editing data, and so on.