Adding DataExpress components to your application

Database application development is a feature of JBuilder Professional and Enterprise. Distributed application development is a feature of JBuilder Enterprise.

You can use the JBuilder visual design tools to add DataExpress components to your application. The visual design tools are available on the Design tab in the content pane.

JBuilder visual design tools

You add DataExpress components by clicking them on the DataExpress tab of the component palette, then dropping them into either the UI designer or the component tree (lower left pane of the AppBrowser in design view). JBuilder will automatically generate the corresponding source code for you.

Even though the DataExpress components are not visual, JBuilder displays them in the DataExpress folder in the component tree so you can select them and set their properties using the Inspector.

For more information on the JBuilder visual design tools, see "Designing a User Interface" in Building Applications with JBuilder.

You will need two DataExpress components to import data from a text file:

Follow the steps below to add these components to your application:

  1. Click the Design tab at the bottom of the content pane for Frame1.java.
  2. Click the TextDataFile component  () on the DataExpress tab of the component palette.

  3. Click anywhere in the component tree to add it to your application. textDataFile1 appears in the DataExpress folder of the component tree.

  4. Click the TableDataSet component () and add it to the application. It appears as tableDataSet1.

  5. Choose File|Save All to save your work.

Setting properties to connect the components

The next step is to connect the DataExpress components so that they can "talk" to each other by setting the appropriate component properties. You use the Properties tab of the Inspector to do this. The Inspector displays the properties for the component that is selected in the UI designer or in the component tree. For more information on using the Inspector, see the online help topic "Setting component properties in the Inspector."

The first property you need to set is the fileName property of the TextDataFile component. This property tells JBuilder where to find the text file containing the data for textDataFile1.

  1. Select textDataFile1 in the component tree. The Inspector displays the properties for this component on the Properties tab.

    Note: You can only select DataExpress components in the component tree since they are non-visual components.

  2. Click in the the edit area next to the fileName property in the Inspector (the property value field). It changes color to show that it is active for editing.
  3. Click the ellipsis button to display the File Name dialog box.
  4. Click the Browse button to display the Open dialog box, and browse to /jbuilder/samples/DataExpress/TextDataFile/employee.txt. Click Open.
  5. Click OK to close the File Name dialog box.
  6. Click the Source tab to view the resulting source code, which should look similar to:
    textDataFile1.setFileName("/usr/local/jbuilder/samples/com/borland/
    	samples/DataExpress/TextDataFile/employee.txt"); 
    
Note: This tutorial will not work if you use a different text file than employee.txt at this time. This project also contains a SCHEMA file needed to import this text file. Later examples show you how to work with your own data files. See "Importing data from a text file."

Now you need to connect tableDataSet1 to the textDataFile1 component.

  1. Click the Design tab and select tableDataSet1 in the component tree.
  2. Click the dataFile property value, then click the down arrow and select the entry for textDataFile1.
  3. Click the Source tab to see the source code generated for this:
    tableDataSet1.setDataFile(textDataFile1);
  4. Choose File|Save All to save your work.

The employee.txt file is designed to work with the default settings stored in the TextDataFile component for properties such as delimiter, separator, and locale. If it was designed differently, the appropriate properties could be set at this point.


Creating the application structure Creating a user interface