5 Customizing ADF Bindings

This chapter describes how to use ADF Model binding editors to customize control bindings in ADF Swing applications. The control is bound to the data model using ADF bindings. JDeveloper creates ADF bindings when you insert a control from the Data Controls panel.

This chapter includes the following sections:

5.1 About Customizing ADF Bindings

When you insert a control from the Data Controls panel, the control is bound to the data model using ADF bindings. You can then edit the bindings using the binding editors.

ADF Swing provides model objects for Swing controls that are responsible for marshaling interaction between the Swing controls and the ADF Business Components view object's row set iterator. The ADF Swing implementation of Swing models are called control bindings.

The UI components in an ADF Swing application bind to ADF Business Components view objects. For example, an ADF Swing databound panel might have a text field (JTextField) for the First name and Last name that allows the user to view and modify business component attribute values.

The type of control binding used for a given Swing control depends on the actions performed by the control. In some case, controls work with multiple control bindings that define different interactions. Table 5-1 shows the bindings that ADF Swing defines for the various Swing controls.

Table 5-1 Control Bindings for Controls in ADF Swing

ADF Control Binding Swing Control

Action binding

Button

Attribute binding

Label For

Password

TextArea

TextField

TextPane

EditPane

Array Combobox binding

JUArrayComboBox

Boolean binding

Checkbox

Bounded Range binding

ProgressBar

ScrollBar

Slider

Formatted Text Field binding

Formatted Text Field

Iterator binding

Navigation Bar

List binding

ComboBox

List

Radio Button Group

Spinner

List binding in LOV Mode

Spinner

Button LOV binding

Button LOV

Scroll binding

ScrollBar

Slider

Table binding

Table

Tree Node binding

Tree

Graph binding

JUSingleTableGraphBinding

JUMasterDetailTableGraphBinding


5.2 How to Customize ADF Bindings for ADF Swing Panels

You can use the control binding editors in JDeveloper to customize the characteristics of any databound UI component that you create using the Data Controls panel.

Note:

Modifications to a data binding may create discrepancies between the data binding and the UI component used to display the data. For example, if you edit the data binding of a table to display one less column of attribute values, you must use the Java visual editor to remove the column from the source.

To customize a UI component's binding from the Java visual editor:

  1. Use the Data Controls panel to insert the UI component into your Java panel.

    For more information, see Section 2.11, "How to Create ADF Swing Edit Forms from the Data Controls Panel."

  2. With the UI component displayed in the Java visual editor, right-click the component and choose Edit Bindings to view the binding editor.

    You can also click the Bindings tab in the Java visual editor and double-click the binding in the Bindings list.

5.3 How to Customize an ADF Action Binding

You can customize an ADF action binding on the Button UI control that you insert from the Data Controls panel.

An action binding lets users initiate actions on the attributes and collections of the specific business service. Actions are defined by the business service's class methods and will appear in the Operations folders displayed in the Data Controls panel.

When you use the Data Controls panel to insert the action as a button, the action binding editor displays the corresponding selections. You can use the action binding editor to change the data collection and action. Or, when you want the action to apply to all data collections in the current document's binding context, you can select a data control and a corresponding action.

Note:

If the custom method accepts parameters, the actual value for parameters may be specified through the Properties window. The action binding editor does not support entering value for the method arguments.

For certain business services, the ADF data control for that business service may support standard actions. For example, in the case of ADF Business Components, these standard actions are available:

  • Commit or rollback the changes to all bound data collections in the binding context of the data control.

  • Move to the first, next, previous, or last row in the data collection's range.

  • Create a row or delete the current row.

  • Reset data from the data collection cache on all rows.

  • Execute the data collection query to get the latest data from the database.

  • Initiate a query on the data collection.

  • Obtain the current row from the data collection.

When users initiate the action, the bound data collection is immediately updated. The UI reflects the change through any control bindings that use the same data collection as the action binding.

To set an action binding:

  1. Open the data panel in the Java visual editor.

    For more information, see Section 2.9, "How to Create an Empty ADF Swing Form."

  2. In the Data Controls panel, expand the Operations folder for the data collection or data control.

    Note:

    The Data Controls panel hierarchy represents operations (such as Create and Delete) that apply to a specific data collection in the Operations folder below the data collection. When supported by the ADF data control for your business service, you can also select operations (such as Commit and Rollback) that apply to all data collections in the current document's binding context in the Operations folder at the top branch of the hierarchy.

  3. Drag the desired operation into the open document.

    JDeveloper adds code to the class file to bind the component to the operation.

  4. Display the action binding editor for the control.

    For more information, see Section 5.2, "How to Customize ADF Bindings for ADF Swing Panels."

  5. In the Data Collection list, select the collection or data control on which you want to perform the action.

    Expand the Operations folder under the root data control node when you want to select operations (such as Commit and Rollback) that apply to all data collections in the current document's binding context.

    Note:

    Add other UI controls to your data panel to display the results of the action on the data collection. Those controls need only set a control binding on the same data collection as the action binding to reflect the action in the UI.

  6. Select the Operation for the action to perform on the selected data collection.

  7. You should leave Iterator empty if you have selected a custom method, such as Commit or Rollback, which are actions on the ADF data control and do not require an iterator.

    If the Iterator list already displays a named iterator to access the selected data collection, you may leave the selection unchanged, or if you have selected one of the predefined actions provided by the business service data collection (for example, Next, Next Set, Previous, and Previous Set), click New and create the iterator so it appears in the dropdown list.

  8. Click OK to save the binding settings.

  9. Open the Properties window to define any method parameter values.

    You can also create an ADF Swing form that allows the user to supply the parameters of the method. For more information, see Section 3.8, "Binding a Method with Parameters in an ADF Swing Form."

JDeveloper adds the setModel() method in the jbInit() method to create the action binding. Example 5-1 shows the method which references DataControlId to specify the metadata after inserting a button from the Data Controls panel.

Example 5-1 Method Referencing DataControlId After Inserting Button

myButton.setModel((ButtonModel)panelBinding.bindUIControl("DataControlId", myButton));

Metadata for the new binding appears in the page definition file (PageDef.xml).

Notes:

The custom method argument definitions, if any, appear undefined until you use the Properties window to specify the values.

By default when you create an action binding for the same method more than once, the return location of the method is the same. This means if you want to create unique action bindings for the same method, you must edit the ReturnName attribute to supply a unique name for each binding. Normally, you will leave the location the same for duplicate usages of the same action binding (where each usage specifies different parameter values). This permits all bound controls in the binding context to find the result under the same return name.

5.4 How to Customize an ADF Attribute Binding

You can set an ADF attribute binding on these basic UI components that you insert from the Data Controls panel:

  • Password Field - mask the attribute value entered by the user

  • TextArea - display plain text with multiple lines

  • TextField - display plain text in a single line

  • JUImage - display an attribute of type BLOB or OrdMedia

  • JULabel - display the attribute value as a label

  • Label For - display the control hint label defined for ADF Business Components attributes

You can set an ADF attribute binding on these UI components to display various kinds of content (besides text):

  • Edit Pane - display various kinds of components that can be edited

  • TextPane - display various kinds of components, that should not be editable

The behavior of the attribute binding depends on the type of control used. Users may view and, in some cases, edit the value of a single attribute defined by a data collection. You use the attribute binding editor to select the data collection and attribute.

Note:

In an ADF Business Components project, you can make attribute values updatable by setting a control hint on the attribute. In that case, users will be able to edit the updatable attribute's values directly.

To set an attribute binding:

  1. Open the data panel in the Java visual editor.

    For more information, see to Generating an Empty ADF Swing Panel.

  2. In the Data Controls panel, drag the desired attribute to display into the open form or panel.

    Be sure to select an attribute and not a data collection.

  3. From the Add Child popup list, select the UI component that you want to add to the open document.

    The new UI component appears in the document you are editing.

  4. Display the attribute binding editor for the component.

    For more information, see Section 5.2, "How to Customize ADF Bindings for ADF Swing Panels."

  5. In the attribute binding editor, select the Data Source that contains the attribute you want to display.

  6. In the Attribute list, select a single attribute to display as the value of the control.

  7. If the iterator dropdown list already displays a named iterator to access the selected data collection, leave the selection unchanged. If the dropdown appears empty, click New and create the iterator so it appears in the dropdown list.

    Note:

    Changing the iterator selection in the dropdown list will remove the previously made attribute selection. Before you change the iterator selection, take note of the original attribute selection. If you need to, you can press Cancel to exit the binding editor without updating the original attribute selection.

  8. Click OK to save the binding settings.

Developer adds the setModel() method in the jbInit() method to create the control binding and reference DataControlId to specify the metadata. Example 5-2 shows the method created after inserting a text field from the Data Controls panel.

Example 5-2 Set Model Method for Attribute Binding

myTextField.setDocument((Document)panelBinding.bindUIControl("DataControlId", myTextField));

Metadata for the new binding appears in the binding definition (PageDef.xml).

5.5 How to Customize an ADF Array Combobox Binding

You can set an ADF array combobox binding on the JUArrayComboBox UI control that you insert from the Data Controls panel.

The array combobox binding lets the user view and, in some cases, edit the values displayed from a list defined by an attribute that specifies an array. You use the array binding editor to select the data collection and attribute.

Note:

In an ADF Business Components project, you can make attribute values updatable by setting a control hint on the attribute. In that case, users will be able to edit the updatable attribute's values directly.

To set an array combobox binding:

  1. Open the data panel in the Java visual editor.

    For more information, see Section 2.10, "How to Create an Empty ADF Swing Panel."

  2. In the Data Controls panel, drag the attribute to display into the open form or panel.

    The attribute must be an attribute of a business service data collection that has been mapped as type oracle.jbo.domain.array in the data model project.

  3. From the Add Child popup list, select JUArrayComboBox.

    The new UI component appears in the document you are editing.

  4. Display the array combobox binding editor for the component.

    For more information, see Section 5.2, "How to Customize ADF Bindings for ADF Swing Panels."

  5. In the array combobox binding editor, select the Base Data Source that contains the attribute you want to display.

  6. In the Display Attribute list, select a single attribute of type array to display the values in the combobox control.

  7. Click OK to save the binding settings.

Developer adds the setModel() method in the jbInit() method to create the control binding and reference DataControlId to specify the metadata. Example 5-3 shows the method created after inserting the JUArrayComboBox from the Data Controls panel.

Example 5-3 Set Model Method for Array Binding

jUArrayComboBox.setArrayBinding((JUDefaultControlBinding)panelBinding.
 bindUIControl("DataControlId", jUArrayComboBox));

Metadata for the new binding appears in the binding definition (PageDef.xml).

5.6 How to Customize an ADF Boolean Binding

You can set an ADF boolean binding on the checkbox UI component that you insert from the Data Controls panel.

The boolean binding lets users select the component and update an attribute in a data collection based on the component's selection state. You use the boolean binding editor to select the data collection and attribute on which you want the component to operate, then specify values corresponding to the component's selection state (for example, "true" for selected and "false" for unselected). You must know what values the bound attribute takes in order to supply meaningful values.

To set a boolean binding:

  1. Open the data panel in the Java visual editor.

    For more information, see Section 2.10, "How to Create an Empty ADF Swing Panel."

  2. In the Data Controls panel, drag the attribute to display into the open form or panel.

    Be sure to select an attribute and not a data collection.

  3. From the Add Child popup list, select Check Box.

    The new UI component appears in the document you are editing.

  4. Display the boolean binding editor for the component.

    For more information, see Section 5.2, "How to Customize ADF Bindings for ADF Swing Panels."

  5. In the Base Data Source list, select the data collection which contains the attribute you want to update.

  6. In the Attribute list, select the attribute to display with the values list.

  7. When you want to supply the values from a list binding, select the Server List Binding Name from the dropdown list.

  8. In the Selected State Value field, enter the value the model will use to update the attribute when the user makes the control appear selected.

  9. In the Unselected State Value field, enter the value the model will use to update the attribute when the user makes the control appear unselected.

  10. Click OK to save the binding settings.

Developer adds the setModel() method in the jbInit() method to create the control binding and reference DataControlId to specify the metadata. Example 5-4 shows the method created after inserting a checkbox from the Data Controls panel.

Example 5-4 Set Model Method for Boolean Binding

myCheckbox.setModel((ButtonModel)panelBinding.bindUIControl("DataControlId", myCheckbox));

Metadata for the new binding appears in the binding definition file (PageDef.xml).

5.7 How to Customize an ADF Bounded Range Binding

You can set an ADF bounded range binding on these UI controls that you insert from the Data Controls panel:

  • ProgressBar

  • ScrollBar

  • Slider

The behavior of the bounded range control binding depends on the type of control used. Users may view and, in some cases, edit the value of a single attribute defined by a data collection. You use the bounded range binding editor to select the data collection and attribute, then define the range of permissible values. You must know what values the bound attribute takes in order to supply a meaningful range.

Note:

In an ADF Business Components project, you can make attribute values updatable by setting a control hint on the attribute. In that case, users will be able to edit the updatable attribute's values directly.

To set a range binding:

  1. Open the data panel in the Java visual editor.

    For more information, see Section 2.10, "How to Create an Empty ADF Swing Panel."

  2. In Data Controls panel, drag the desired attribute to display into the open form or panel.

    Be sure to select an attribute and not a data collection.

  3. Add the control to the data panel.

    For more information, see Section 3.3, "How to Insert UI Components into ADF Swing Panels."

  4. Display the bounded range binding editor for the control.

    For more information, see Section 5.2, "How to Customize ADF Bindings for ADF Swing Panels."

  5. In the bounded range binding editor, select the Base Data Source that contains the attributes you want to display in the table.

  6. In the Attributes list, select a single attribute to display as the value of the control.

  7. If the iterator dropdown list already displays a named iterator to access the selected data collection, leave the selection unchanged. If the dropdown appears empty, click New and create the iterator so it appears in the dropdown list.

    Note:

    Changing the iterator selection in the dropdown list will remove the previously made attribute selection. Before you change the iterator selection, take note of the original attribute selection. If you need to, you can press Cancel to exit the binding editor without updating the original attribute selection.

  8. In the case of a ProgressBar, Slide, and ScrollBar control, you can specify a Minimum Display Value and a Maximum Display Value. These correspond to the start and end values supported by the control.

  9. In the case of the Slider and ScrollBar control, you can specify the Extent Value or interval between tick marks. Each tick mark corresponds to a possible value that the user could apply to the bound attribute.

    Note:

    In the case of the slider and scrollbar, attribute values are calculated by adding the control's minimum value to the product of the increment value and index of the selected tick mark. For example, if the minimum value is 20, the increment value is 10, and the user has selected the 3rd tick mark in the control, then the attribute value would be 20 + (10 x 3) = 50.

  10. Click OK to save the binding settings.

Developer adds the setModel() method in the jbInit() method to create the control binding and reference DataControlId to specify the metadata. Example 5-5 shows the method created after inserting a slider from the Data Controls panel.

Example 5-5 Set Model Method for Bounded Range Binding

mySlider.setModel((BoundedRangeModel)panelBinding.bindUIControl("DataControlId", mySlider));

Metadata for the new binding appears in the binding definition file (PageDef.xml).

5.8 How to Customize an ADF Formatted Text Field Binding

You can set an ADF formatted text field binding on the Formatted Edit Field UI component that you insert from the Data Controls panel.

The formatted text field binding lets the user view and edit the value of a single attribute defined by a data collection. You use the formatted text field binding editor to select the data collection and attribute. The editor also lets you select a formatter to display the bound attribute's value with a specific format mask applied.

Note:

In an ADF Business Components project, you can make attribute values updatable by setting a control hint on the attribute. In that case, users will be able to edit the updatable attribute's values directly.

To set a formatted text field binding:

  1. Open the data panel in the Java visual editor.

    For more information, see Section 2.10, "How to Create an Empty ADF Swing Panel."

  2. In the Data Controls panel, drag the attribute to display into the open form or panel.

    Be sure to select an attribute and not a data collection.

  3. Add the control to the data panel.

    For more information, see Section 3.3, "How to Insert UI Components into ADF Swing Panels."

  4. Display the formatted text field binding editor for the control.

    For more information, see Section 5.2, "How to Customize ADF Bindings for ADF Swing Panels."

  5. In the formatted text field binding editor, select Attribute in the topmost dropdown list, and select the Data Source that contains the attribute you want to display.

  6. In the Attribute list, select a single attribute to display as the value of the control.

  7. In the topmost dropdown list, select Format and then select the Formatter to use.

  8. Click OK to save the binding settings.

Developer adds the setModel() method in the jbInit() method to create the control binding and reference DataControlId to specify the metadata. Example 5-6 shows the method created after inserting a formatted edit field from the Data Controls panel.

Example 5-6 Set Model Method for Formatted Text Field Binding

jFormattedTextField.setDocument((Document)panelBinding.bindUIControl("DataControlId", jFormattedTextField));

Metadata for the new binding appears in the binding definition (PageDef.xml).

5.9 How to Customize an ADF Iterator Binding

You can set an ADF iterator binding on the NavigationBar UI control that you insert from the Data Controls panel.

You use an iterator binding on a NavigationBar control to manage the position of the current data object on the data collection. When the user clicks on the navigation bar buttons, the data object position changes and any other indicator control bound to the same data collection gets updated.

To set an iterator binding:

  1. Open the data panel in the Java visual editor.

    For more information, see Section 2.10, "How to Create an Empty ADF Swing Panel."

  2. In the Data Controls panel, drag the data collection to navigate into the open form or panel.

  3. Add the NavigationBar control to the data panel.

    For more information, see Section 3.3, "How to Insert UI Components into ADF Swing Panels."

Developer adds the setModel() method in the jbInit() method to create the control binding and reference DataControlId to specify the metadata. Example 5-7 shows the method created after inserting a navigation bar from the Data Controls panel.

Example 5-7 Set Model Method for Iterator Binding

jUNavigationBar.setModel(JUNavigationBar.createViewBinding(panelBinding, jUNavigationBar, "SelectedDataCollection", null, "IteratorId"));

Metadata for the new binding appears in the binding definition file (PageDef.xml).

To modify the number of rows the iterator can display:

  1. In the Applications window, right-click the data panel that contains the component for which you want to limit the range size and select Open.

  2. In the Java visual editor, click the Bindings tab and then from the Executables list select iterator corresponding to the navigation bar and click Edit.

    In most cases, you can select the control binding in the Bindings list to identify the corresponding iterator in the Executables list. Navigation bars are an exception since they do not require a control binding.

  3. In the Properties window, expand the Common section and edit the RangeSize value and press Enter.

    You can increase the value from the default value of 10 rows.

    Note:

    The value -1 and 0 have specific meaning: the value -1 returns all available objects from the collection, while the value 0 will return the same number of objects as the collection uses to retrieve from its data source.

To sort the columns in a table bound to an ADF iterator binding:

  1. In the Applications window, right-click the data panel that contains the table you want to sort and select Open.

  2. In the Java visual editor, click the Bindings tab and then from the Executables list select the iterator for the data collection to which the table is bound and click Edit.

    In most cases, you can select the control binding in the Bindings list to identify the corresponding iterator in the Executables list. Navigation bars are an exception since they do not require a control binding.

  3. In the Edit Iterator Binding dialog, click the Sort Criteria tab and use the arrow buttons to change the sort order for the columns in the table.

5.10 How to Customize an ADF List Binding

You can set an ADF list binding on the list UI control that you insert from the Data Controls panel.

A list binding lets users view a list consisting of attribute values from a data collection. You use the list binding editor to select the data collection and attributes to display.

To set a list binding:

  1. Open the data panel in the Java visual editor.

    For more information, see Section 2.10, "How to Create an Empty ADF Swing Panel."

  2. In the Data Controls panel, drag the data collection to display into the open form or panel.

  3. Add the list control to the data panel.

    For more information, see Section 3.3, "How to Insert UI Components into ADF Swing Panels."

    Note:

    When you use the Data Controls panel to drop a JList control into an ADF Swing panel or form, the list will initially display all attributes of the selected collection. To modify the list of display attributes, you can use the List Binding Editor.

  4. Display the list binding editor for the control.

    For more information, see Section 5.2, "How to Customize ADF Bindings for ADF Swing Panels."

  5. In list binding editor, select the Base Data Collection that contains the attributes you want to display in the list.

  6. In the Display Attributes list, select the attributes to display.

    You can add as many attributes as you like to the Display Attributes list.

  7. If the iterator dropdown list already displays a named iterator to access the selected data collection, leave the selection unchanged. If the dropdown appears empty, click New and create the iterator so it appears in the dropdown list.

    Note:

    Changing the iterator selection in the dropdown list will remove previously made attribute selections. Before you change the iterator selection, take note of the original attribute selections. If you need to, you can press Cancel to exit the binding editor without updating the original attribute selections.

  8. To rearrange the attributes of the list, select an attribute in the Display Attributes list and click a Move Selection arrow button to reposition the attribute in the list.

    The position of the attribute from top to bottom in the list determines the position of the attributes in the list from top to bottom.

  9. Click OK to save the binding settings.

Developer adds the setModel() method in the jbInit() method to create the control binding and reference DataControlId to specify the metadata. Example 5-8 shows the method created after inserting a list from the Data Control panel.

Example 5-8 Set Model Method for List Binding

myList.setModel((ListModel)panelBinding.bindUIControl("DataControlId", myList));

Metadata for the new binding appears in the binding definition file (PageDef.xml).

5.11 How to Customize an ADF List Binding in Enumeration Mode

You can set an ADF list binding in enumeration mode on these UI controls that you insert from the Data Controls panel:

  • ComboBox

  • List

  • Radio Button Group

  • Spinner

An enumeration mode binding lets users select a value from a display list to update an attribute in a data collection. You use the model list binding editor in enumeration mode to select the data collection and attribute on which you want the control to operate, then specify a set of values from which the user may select. You must know what values the bound attribute takes in order to supply meaningful choices.

To set a list binding in enumeration mode:

  1. Open the data panel in the Java visual editor.

    For more information, see Section 2.10, "How to Create an Empty ADF Swing Panel."

  2. In the Data Controls panel, drag the desired attribute to display into the open form or panel.

    Be sure to select an attribute and not a data collection.

  3. Add the control to the data panel.

    For more information, see to Section 3.3, "How to Insert UI Components into ADF Swing Panels."

  4. Display the list binding editor for the control.

    For more information, see to Section 5.2, "How to Customize ADF Bindings for ADF Swing Panels."

  5. In the Data Collection list, select the data collection that contains the attribute you want to update.

  6. In the Attribute list, select the attribute to display with the values list.

  7. If the iterator dropdown list already displays a named iterator to access the selected data collection, leave the selection unchanged. If the dropdown appears empty, click New and create the iterator so it appears in the dropdown list.

    Note:

    Changing the iterator selection in the dropdown list will remove the previously made attribute selection. Before you change the iterator selection, take note of the original attribute selection. If you need to, you can press Cancel to exit the binding editor without updating the original attribute selection.

  8. If the control is a combobox, list, or radio button group, enter the values in Set of Values in the order you want the control to display them. Press Enter to set the value and begin typing a new value. Values you supply must be valid for the attribute.

  9. If the control is a spinner, select Range of Values when you want the user to be able to choose from a range that you define. If you prefer to define a specific list, select Static Values and enter the values as described for list and combobox above.

  10. Click OK to save the binding settings.

Developer adds the setModel() method in the jbInit() method to create the control binding and reference DataControlId to specify the metadata. Example 5-9 shows the method created after inserting a spinner from the Data Controls panel.

Example 5-9 Set Model Method for Spinner Binding

mySpinner.setModel((SpinnerModel)panelBinding.bindUIControl("DataControlId", mySpinner));

Metadata for the new binding appears in the binding definition file (PageDef.xml).

5.12 How to Customize an ADF List Binding in LOV Mode

You can set an ADF list binding in LOV (list of value) mode on the Button LOV UI control that you insert from the Data Controls panel.

The Button LOV provides both the UI to display the selection and the UI (in the form of a separate window) to make the selection. All other controls require that your add a separate control to display the target of the user's selection.

A LOV mode binding lets users choose a value from a list that displays the data collection rows of one or more attributes. When the user makes the selection, the LOV updates one or more attributes of another data collection based on their selection. You use the list binding editor in LOV mode to define the source and target data collections, the binding between their attributes, and the attributes to display in the LOV.

To set a list binding in LOV mode:

  1. Open the data panel in the Java visual editor.

    For more information, see to Generating an Empty ADF Swing Panel.

  2. In the Data Controls panel, drag the attribute to display into the open form or panel.

    Be sure to select an attribute and not a data collection.

  3. Add the control to the data panel.

    For more information see Section 3.3, "How to Insert UI Components into ADF Swing Panels."

    Note:

    Move the Button LOV on the panel in a position near the form field that you want to receive the LOV selection.

  4. Display the list binding editor for the control.

    For more information, see Section 5.2, "How to Customize ADF Bindings for ADF Swing Panels."

To define the LOV to display:

  1. In the list binding editor, select the Binding Definition tab and select the data collections you want your LOV to use:

    • Base Data Source defines the collection that you want to use to display your list of values for selection. This should be a collection that is not constrained by a master data collection in the data model project.

    • List Data Collection is the collection that contains the attribute you want to receive the selected value in the ADF Swing panel. This should be the same data collection that your panel displays.

  2. If the iterator dropdown list already displays a named iterator to access the selected data collection, leave the selection unchanged. If the dropdown appears empty, click New and create the iterator so it appears in the dropdown list.

    Note:

    Changing the iterator selection in the dropdown list will remove previously made attribute selections. Before you change the iterator selection, take note of the original attribute selections. If you need to, you can press Cancel to exit the binding editor without updating the original attribute selections.

  3. Click Add to bind at least one attribute between the two data collections.

    The bottom area of the list binding editor displays a table with a list of possible LOV binding attributes between the collection used to display the list of values and the collection used to receive the attribute selection.

  4. Choose the attribute from the LOV Attributes dropdown that you want to use to supply the value to the field displayed in the ADF Swing form.

  5. Choose the attribute from the Target Attributes dropdown that you want to receive the value from the LOV.

  6. Click Add again to bind multiple attributes through the same LOV.

  7. Select the LOV Display Attributes tab and select the attributes that you want the LOV window to display.

    You can add as many attributes as you like to the Selected Attributes list, although you are not required to include the LOV binding attribute (the attribute that you want to display the selected value).

  8. Optionally, select the NULL Value Selection tab and supply a NULL value when the attribute supports it.

    This is the item the user may select when no other value applies

  9. Optionally, select the Runtime LOV Dialog Details tab and customize the display location and size of the LOV dialog.

  10. Click OK to save the binding settings.

Developer adds the setModel() method in the jbInit() method to create the control binding and reference DataControlId to specify the metadata. Example 5-10 shows the method created after inserting a list from the Data Controls panel.

Example 5-10 Set Model Method for List Binding

myList.setModel((ListModel)panelBinding.bindUIControl("DataControlId", myList));

Metadata for the new binding is added to the binding definition file (PageDef.xml).

To insert a control to display the updated LOV target attribute value:

  1. In the Data Controls panel, drag the attribute which you previously selected as the LOV binding's target attribute into the open panel.

  2. From the Add Child popup list, select the UI component that you want to insert to display the updated attribute value.

To modify the number of rows to display in the LOV:

  1. In the Applications window, right-click the data panel that contains the LOV component for which you want to limit the range size and select Open.

  2. In the Java visual editor, click the Bindings tab and then from the Executables list select iterator corresponding to the LOV component binding and click Edit.

    In most cases, you can select the control binding in the Bindings list to identify the corresponding iterator in the Executables list.

  3. In the Properties window, expand the Common section and edit the RangeSize value and press Enter.

    You can increase the value from the default value of 10 rows.

    Note:

    The value -1 and 0 have specific meaning: the value -1 returns all available objects from the collection, while the value 0 will return the same number of objects as the collection uses to retrieve from its data source.

For additional information about working with range size, see Section 10.4, "How to Limit Fetching of ADF Business Components Attributes in ADF Swing."

5.13 How to Customize an ADF LOV Button Binding

You can set an ADF list binding in LOV (list of value) mode on the Button LOV UI control that you insert from the Data Controls panel.

The Button LOV provides both the UI to display the selection and the UI (in the form of a separate window) to make the selection. All other controls require that your add a separate control to display the target of the user's selection.

A LOV mode binding lets users choose a value from a list that displays the data collection rows of one or more attributes. When the user makes the selection, the LOV updates one or more attributes of another data collection based on their selection. You use the list binding editor in LOV mode to define the source and target data collections, the binding between their attributes, and the attributes to display in the LOV.

To set a list binding in LOV mode:

  1. Open the data panel in the Java visual editor.

    For more information, see to Generating an Empty ADF Swing Panel.

  2. In the Data Controls panel, drag the attribute to display into the open form or panel.

    Be sure to select an attribute and not a data collection.

  3. Add the control to the data panel.

    For more information see Section 3.3, "How to Insert UI Components into ADF Swing Panels."

    Note:

    Move the Button LOV on the panel in a position near the form field that you want to receive the LOV selection.

  4. Display the list binding editor for the control.

    For more information, see Section 5.2, "How to Customize ADF Bindings for ADF Swing Panels."

To define the LOV to display:

  1. In the list binding editor, select the Binding Definition tab and select the data collections you want your LOV to use:

    • Base Data Source defines the collection that you want to use to display your list of values for selection. This should be a collection that is not constrained by a master data collection in the data model project.

    • List Data Collection is the collection that contains the attribute you want to receive the selected value in the ADF Swing panel. This should be the same data collection that your panel displays.

  2. If the iterator dropdown list already displays a named iterator to access the selected data collection, leave the selection unchanged. If the dropdown appears empty, click New and create the iterator so it appears in the dropdown list.

    Note:

    Changing the iterator selection in the dropdown list will remove previously made attribute selections. Before you change the iterator selection, take note of the original attribute selections. If you need to, you can press Cancel to exit the binding editor without updating the original attribute selections.

  3. Click Add to bind at least one attribute between the two data collections.

    The bottom area of the list binding editor displays a table with a list of possible LOV binding attributes between the collection used to display the list of values and the collection used to receive the attribute selection.

  4. Choose the attribute from the LOV Attributes dropdown that you want to use to supply the value to the field displayed in the ADF Swing form.

  5. Choose the attribute from the Target Attributes dropdown that you want to receive the value from the LOV.

  6. Click Add again to bind multiple attributes through the same LOV.

  7. Select the LOV Display Attributes tab and select the attributes that you want the LOV window to display.

    You can add as many attributes as you like to the Selected Attributes list, although you are not required to include the LOV binding attribute (the attribute that you want to display the selected value).

  8. Optionally, select the NULL Value Selection tab and supply a NULL value when the attribute supports it.

    This is the item the user may select when no other value applies

  9. Optionally, select the Runtime LOV Dialog Details tab and customize the display location and size of the LOV dialog.

  10. Click OK to save the binding settings.

Developer adds the setModel() method in the jbInit() method to create the control binding and reference DataControlId to specify the metadata. Example 5-11 shows the method created after inserting a button LOV from the Data Controls panel.

Example 5-11 Set Model Method for LOV Button Binding

myList.setModel((ButtonModel)panelBinding.bindUIControl("DataControlId", jButton1));

Metadata for the new binding is added to the binding definition file (PageDef.xml).

To insert a control to display the updated LOV target attribute value:

  1. In the Data Controls panel, drag the attribute which you previously selected as the LOV binding's target attribute into the open panel.

  2. From the Add Child popup list, select the UI component that you want to insert to display the updated attribute value.

To modify the number of rows to display in the LOV:

  1. In the Applications window, right-click the data panel that contains the LOV component for which you want to limit the range size and select Open.

  2. In the Java visual editor, click the Bindings tab and then from the Executables list select iterator corresponding to the LOV component and click Edit.

    In most cases, you can select the control binding in the Bindings list to identify the corresponding iterator in the Executables list.

  3. In the Properties window, expand the Common section and edit the RangeSize value and press Enter.

    You can increase the value from the default value of 10 rows.

    Note:

    The value -1 and 0 have specific meaning: the value -1 returns all available objects from the collection, while the value 0 will return the same number of objects as the collection uses to retrieve from its data source.

For additional information about working with range size, see Section 10.4, "How to Limit Fetching of ADF Business Components Attributes in ADF Swing."

5.14 What You May Need to Know About the LOV Dialog

The JButton control is unique when you specify an ADF Swing LOV (list of values) control binding because unlike other Swing controls that support the LOV control binding, a JButton control will display an LOV dialog. The dialog the user sees displays the attributes you specified for display in the LOV binding.

The LOV dialog supports several custom features:

  • Find-mode operations that may be initiated by the user when this feature is enabled.

  • Custom title and display location for dialog.

  • Ability to subclass JULovPanelInterface to display your own LOV dialog when the user clicks the JButton control with the LOV binding.

When Find-mode operation is enabled for the LOV binding on the JButton control, the user can set the LOV dialog into Find mode by clicking the Find button in the LOV dialog navigation bar. The LOV dialog in Find mode lets the user enter view criteria to execute a query on the bound view object rows. The LOV binding executes the query and displays only the rows that match the specified view criteria.

The user executes a Find-mode query through a LOV dialog by:

  1. Clicking Set to Find mode in the LOV dialog. navigation bar to display a single view criteria field for each bound attribute.

  2. Entering values in the view criteria field for the attributes they want to match.

    The entered value must include the appropriate comparison symbol (>, <, =). All values in the same view criteria are AND'ed together.

  3. Clicking Execute Query Button in the LOV dialog navigation bar to return the results to the LOV dialog.

For details about the usage of view criteria in ADF Business Components, see the JavaDoc for the oracle.jbo.ViewCriteria class.

5.15 How to Customize an ADF Scroll Binding

You can set an ADF scroll binding on these UI controls that you insert from the Data Controls panel:

  • ScrollBar

  • Slider

The scroll binding lets users view the relative position of the current data object in the bound data collection. The control thumb or indicator will be proportional to the number of data objects displayed out of the full range of the data collection. You use the scroll binding editor to select the data collection on which you want the control to operate.

To set a scroll binding:

  1. Open the data panel in the Java visual editor.

    For more information, see Section 2.10, "How to Create an Empty ADF Swing Panel."

  2. In the Data Controls panel, drag the data collection to scroll into the open form or panel.

  3. Add the control to the data panel.

    For more information, see Section 3.3, "How to Insert UI Components into ADF Swing Panels."

  4. Display the scroll binding editor for the control.

    For more information, see Section 5.2, "How to Customize ADF Bindings for ADF Swing Panels."

  5. In the scroll binding editor, select the Base Data Source that contains the data object to scroll.

  6. If the iterator dropdown list already displays a named iterator to access the selected data collection, leave the selection unchanged. If the dropdown appears empty, click New and create the iterator so it appears in the dropdown list.

    Note:

    Changing the iterator selection in the dropdown list will remove the previously made attribute selection. Before you change the iterator selection, take note of the original attribute selection. If you need to, you can press Cancel to exit the binding editor without updating the original attribute selection.

  7. You can determine the data collection object (row) count to use. Normally, leave Estimate Scrolling Range selected. You can select it if you want to count any rows from the database which have not yet been cached by the data collection.

    Note:

    This option is visible only when the data model project contains ADF business components; when other business services are created in the data model project, this option is not supported. In the case of an ADF Business Components data model project, this option appears selected by default because, when unselected (thereby forcing the actual row count), it may trigger an additional query.

  8. Click OK to save the binding settings.

Developer adds the setModel() method in the jbInit() method to create the control binding and reference DataControlId to specify the metadata. Example 5-12 shows the method created after inserting a slider from the Data Controls panel.

Example 5-12 Set Model Method for Scroll Binding

mySlider.setModel((BoundedRangeModel)panelBinding.bindUIControl("DataControlId", mySlider));

Metadata for the new binding appears in the binding definition file (PageDef.xml).

5.16 How to Customize an ADF Table Binding

You can set an ADF table binding on the Table UI control that you insert from the Data Controls panel.

A table binding lets users view a table consisting of attribute names (column headers) and values from a data collection. You use the table binding editor to select the data collection and attributes to display. You can also specify display properties for column attributes, including column width and a table cell editor to display.

Note:

In an ADF Business Components data model project, you can make attribute values updatable by setting a control hint on the attribute. In that case, users will be able to edit the updatable attribute's values directly in the table. Another control hint lets you change the label displayed by the column header for each attribute.

To set a table binding:

  1. Open the data panel in the Java visual editor.

    For more information, see Section 2.9, "How to Create an Empty ADF Swing Form."

  2. In the Data Controls panel, drag the desired data collection to display into the open form or panel.

  3. Add the table control to the data panel.

    For more information, see Section 3.3, "How to Insert UI Components into ADF Swing Panels."

    Note:

    When you use the Data Controls panel to drop a JTable control into an ADF Swing panel or form, the table will initially display all attributes (columns) of the selected collection. To modify the table's list of display attributes, you can use the Table Binding Editor, however, the changes will not be reflected immediately in the Java visual editor. In order to synchronize the visual editor with the table's binding information (saved in the form or panel's PageDef.xml file), you can either recompile the class file, or you can merely resize the table in the visual editor.

  4. Display the table binding editor for the control.

    For more information, seeSection 5.2, "How to Customize ADF Bindings for ADF Swing Panels."

  5. In table binding editor, display the Attribute Binding page and select the Base Data Source that contains the attributes you want to display in the table.

    Tables that you create must be based on scalar attributes of a collection or structured object. For example, if you attempt to drop the return() method of a complex collection (contains arrays) as a table, the collection's attributes will not be displayed because they are defined by accessors. You can drop individual accessors of the collection as a table because they define attributes.

  6. In the Available Attributes list, select the attribute to display and add it to the Selected Attributes list. You may add as many attributes as you like to the Display Attributes list.

  7. To rearrange the columns of the table, select an attribute in the Selected Attributes list and click a Move Selection arrow button to reposition the attribute in the list.

    The position of the attribute from top to bottom in the list determines the position of the columns in the table from left to right.

  8. Select Attribute Properties and optionally change the column width and cell editor to use.

  9. Click OK to save the binding settings.

Developer adds the setModel() method in the jbInit() method to create the control binding and reference DataControlId to specify the metadata. Example 5-13 shows the method created after inserting a table from the Data Controls panel.

Example 5-13 Set Model Method for Table Binding

myTable.setModel((TableModel)panelBinding.bindUIControl("DataControlId", myTable));

Metadata for the new binding appears in the binding definition file (PageDef.xml).

To customize table columns:

  1. In table binding editor, display the Attribute Properties page and view the list of attribute name (columns) that your table will display.

  2. Optionally, double-click in the Width field corresponding to the attribute whose column width you want to modify. The default width is determined by the size of the table displayed in the Java visual editor.

    You can also specify column widths by setting control hints at the level of the business component attribute. When the control hint width is specified, that value will appear in the Attribute Properties page of the table binding editor.

  3. Press Return to set the new width on the field.

  4. Optionally, click in the Editor field corresponding to the attribute whose editor you want to set. The default editor is a simple text field.

    Note:

    You can additionally specify format masks by setting the formatter and format control hints at the level of the business component attribute.

  5. Select an editor from the list and press the ellipses button to open the binding editor.

    In the case of the ComboBox and Spinner editors, you can select an existing binding from the page definition. The binding you select must be bound to the same attribute displayed in the table binding editor.

  6. Click OK to save the binding settings.

5.17 How to Customize an ADF Tree Binding

You can set an ADF hiearchical tree binding on the tree UI control that you insert from the Data Controls panel.

A tree binding lets users view a hierarchical list of attributes derived from master-detail relationships as specified by the business services in your data model project. You use the tree binding editor to define a set of rules that determine how the tree binding should traverse the relationships of the business service data collections you select.

In order for the tree binding to construct a tree with multiple branches, the business services should meet these requirements:

  • A starting or root data collection (for example, an ADF Business Components view object) that you will use as the control binding target.

  • One or more accessors (for example, an ADF Business Components viewlink) from that root collection and other data collections. The tree binding editor will display an allowable set of accessors for that node to drill down in to the next level.

Once you create the ADF binding for the tree control, you can use the tree control to let users navigate through the rows of the bound data collection. Currently, there is no navigation binding for the tree control, so you will need to add a JUTreeDefaultMouseListener on the control.

To set a tree binding:

  1. Open the data panel in the Java visual editor and add a JScrollPane container to the panel.

    For more information, see Section 2.10, "How to Create an Empty ADF Swing Panel."

  2. In the Data Controls panel, drag the data collection to display into the open form or panel.

  3. Add a Tree control to the scrollable panel.

    For more information, see Section 3.3, "How to Insert UI Components into ADF Swing Panels."

  4. Display the tree binding editor for the JTree control.

    For more information, see Section 5.2, "How to Customize ADF Bindings for ADF Swing Panels."

To define the root node of the tree:

  1. In the tree binding editor, click the Edit Rule tab to define the parent node rule to display from the master data collection.

    For example, a master collection of "customers" has a detail collection of "orders".

  2. In the Root Data Source list, select the data collection that you want to use to populate the tree root node.

    This is the master collection that defines the root node. For example, a customer's master collection that has an orders detail collection.

  3. Click the Add Rule icon button to complete the rule definition for the root node.

  4. In the Attributes list, select a single attribute to display as the parent nodes for the tree.

    For example, the last name of each customer. Currently, the JTree control is limited to displaying a single attribute for each branch.

  5. In the Accessor list, select the accessor that specifies the link between the master collection and the first branch in the tree.

    For example, an ADF Business Components accessor for the customers and orders collections, might appear as OrdersView in the list.

    Note:

    If your data model does not contain master-detail accessors for the data collections you select, the Accessor list will appear empty. You must define an accessor for your business service in your data model project for all branches of the tree except the leaf (terminal) nodes.

To define the branches of the tree:

  1. Select the parent tree-level rule and click the Add Rule icon button and select the child-branch collection to display from the master collection.

    This is the detail collection that defines the nodes for the tree. For example, an orders detail collection from which you will display order id information in the tree.

  2. In the Attributes list, select a single attribute to display as the branch nodes in the tree, for example, the last name of each customer.

  3. In the Accessor list, select the accessor that specifies the link between the first branch data collection and the next branch in the tree.

    For example, an ADF Business Components accessor for the orders and orderitems collections might appear as OrderItemsView in the list.

    Note:

    If the branch data collection you select has no further accessor defined for it in the data model project, the word <none> will appear in the list. This means no accessor is required because the selected collection's attribute will appear as leaf nodes in the tree.

  4. You may repeat these steps to define new branches in the tree as long as your business services support accessors to traverse the branches.

  5. Click OK to save the binding settings.

    The binding editor performs error checking for the rules you defined. It displays the following error messages:

    • "Invalid definition, either no root or no rules defined." Either you did not define a rule or you did not define a rule for the root node.

    • "Defined root not found in this Application Module." The view object usage name defining the root node cannot be found in the application module defined in the form binding.

    • "No rule found for accessor... ." There is no rule definition for every accessor in the rules table. Error checking does not verify that the number of polymorphic rules for a particular accessor; only that each accessor in the rules table has a rule definition.

Developer adds the setModel() method in the jbInit() method to create the control binding and reference DataControlId to specify the metadata. Example 5-14 shows the method created after inserting a tree from the Data Controls panel, the method which references DataControlId to specify the metadata.

Example 5-14 Set Model Method for Tree Binding

myTree.setModel((TreeModel)panelBinding.bindUIControl("DataControlId", myTree));

Metadata for the new binding appears in the binding definition file (PageDef.xml).

To add images to display in the tree binding editor:

The tree binding editor lets you choose icons to display for each node in a branch and the open and close icon for each branch. To view the icon choices in the tree binding editor, you must copy your icon image files to the src folder of your user interface project. Use the icon dropdown menus in the tree binding editor to make your choice; each menu displays all the image files in the current project/src folder.