This is a feature of JBuilder Professional and Enterprise.
Use the PickList
property editor to set properties associated with a picklist or lookup relationship between two DataSet
objects.
To display this property editor, choose the pickList
property from the Inspector when any Column
of a StorageDataSet
is selected in the structure pane. The values specified in this dialog are stored in an instance of a PickListDescriptor
object.
You can use the pickList field for providing values to a column using a picklist to enter a new value to a column, and it also covers creating a lookup that will display values from another column. The links are to topics in the Database Application Developer's Guide book.
This type of lookup displays a list of choices in a drop-down list. The choices that populate the list come from the unique values of a column of another data set. The tutorial gives the steps for looking up a value in a picklist for data entry purposes, in this case for selecting a country for a customer or employee. In this example, the pickList
property of a column allows you to define which column of which data set will provide values for the picklist. The choices will be available for data entry in a visual component, such as a table, when the application is running.
There are many other things you can do with a picklist. For more ideas, see the pick list sample in the dbSwing samples directory. If you downloaded your version of JBuilder, samples are available by downloading the Samples Pack.
This type of lookup retrieves values from a specified table based on criteria you specify and displays it as part of the current table. In order to create a calculated column, you need to create a new Column
object in the StorageDataSet
, set its calcType
appropriately, and code the calcFields
event handler. The lookup values are only visible in the running application. Lookup columns can be defined and viewed in JBuilder, but JBuilder-defined lookup columns are not resolved to or provided from its data source, although they can be exported to a text file.
An example of looking up a field in a different table for display purposes is looking up a part number to display a part description for display in an invoice line item or looking up a zip code for a specified city and state.
The lookup()
method uses specified search criteria to search for the first row matching the criteria. When the row is located, the data is returned from that row, but the cursor is not moved to that row. The locate()
method is a method that is similar to lookup()
, but actually moves the cursor to the first row that matches the specified set of criteria. For more information on the locate()
method, see "Locating data".
The lookup()
method can use a scoped DataRow
(a DataRow
with less columns than the DataSet
) to hold the values to search for and options defined in the Locate
class to control searching. This scoped DataRow
will contain only the columns that are being looked up and the data that matches the current search criteria, if any. With lookup, you generally look up values in another table, so you will need to instantiate a connection to that table in your application.
For more information on creating pick lists, see the class description for PickListDescriptor
.
Select the DataSet
object that contains the data for display in the pick list. The data set must be instantiated to display in this list.
When a DataSet
is selected, the grid fills with the following data:
The DataSet name | Read-only property that displays a list of all columns in the DataSet specified in the Picklist/Lookup Dataset field. |
Data Type | Read-only property that displays the data type of each column in the DataSet specified in the Picklist/Lookup Dataset field. The data type of the column determines what choices are displayed in the "destination" column drop down; only similar data types can be specified. |
Show in picklist | Select this option to select the Column components to read from when filling in data from the pick list DataSet into the columns specified in the "destination" Columns property.
If your pick list contains multiple columns, you must also set the |
(DataSet name) | Select the "destination" Column components to be filled in when an entry in the pick list is selected. This property is also used for the display of lookup values and if not set, your application may generate a java.lang.NullPointerException error. |
Select the name of the Column
in the pick list DataSet
to display for this (the column whose pickList
is being defined) column in data-aware controls.
Note: If you set this property but omit to specify a column in the "destination" column, your application will generate an error when run, likely a java.NullPointerException
error.
Select this option to have JBuilder enforce data constraints such as minimum or maximum value for the destination columns.