6-4 Java EE Developers Guide for Oracle Application Development Framework
Before you begin: Define two data sources: one for the list data source that provides the dynamic list of
values, and the other for the base data source that is to be updated based on the user’s selection.
To create a selection list bound containing dynamically generated values: 1.
From the Data Controls panel, drag and drop the attribute onto the JSF page and choose Create Single Selections ADF Select One Choice.
The Edit List Binding dialog displays. The accessor returned collection containing the attribute you dropped on the JSF page is selected by default in the Base Data
Source list.
To select a different accessor returned collection, click the Add icon next to the list. 2.
Select the Dynamic List radio button. The Dynamic List option lets you specify one or more base data source attributes
that will be updated from another set of bound values.
3. Click the Add button next to List Data Source.
4.
In the Add Data Source dialog, select the accessor returned collection that will populate the values in the selection list.
5. Accept the default iterator name and click OK.
The Data Mapping section of the Edit List Binding dialog updates with a default data value and list attribute. The Data Value control contains the attribute on the
accessor returned collection that is updated when the user selects an item in the selection list. The List Attribute Control contains the attribute that populates the
values in the selection list.
6. You can accept the default mapping or select different attributes items from the
Data Value
and List Attribute lists to update the mapping. To add a second mapping, click Add.
7. Click OK.
6.2.3 What Happens When You Create a Fixed Selection List
When you add a fixed selection list, JDeveloper adds source code to the JSF page and list and iterator binding objects to the page definition file.
Example 6–1 shows the page source code after you add a fixed SelectOneChoice
component to it.
Example 6–1 Fixed SelectOneChoice List in JSF Page Source Code
af:selectOneChoice value={bindings.city.inputValue} label={bindings.city.label}
f:selectItems value={bindings.city.items} af:selectOneChoice
Note: The list and base collections do not have to form a
master-detail relationship, but the attribute in the list collection must have the same type as the base collection attributes.
Creating Databound Selection Lists 6-5
The f:selectItems tag, which provides the list of items for selection, is bound to the items property on the CountryId list binding object in the binding container
In the page definition file, JDeveloper adds the definitions for the iterator binding objects into the executables element, and the list binding object into the bindings
element, as shown in Example 6–2
.
Example 6–2 List Binding Object for the Fixed Selection List in the Page Definition File
executables variableIterator id=variables
iterator Binds=root RangeSize=25 DataControl=SupplierFacadeLocal id=SupplierFacadeLocalIterator
accessorIterator MasterBinding=SupplierFacadeLocalIterator Binds=addressesFindAll RangeSize=25
DataControl=SupplierFacadeLocal BeanClass=oracle.fodemo.supplier.model.Addresses
id=addressesFindAllIterator executables
bindings list IterBinding=addressesFindAllIterator id=city DTSupportsMRU=true
StaticList=true AttrNames
Item Value=city AttrNames
ValueList Item Value=redwood city
Item Value=fremont Item Value=stockton
ValueList list
bindings
6.2.4 What Happens When You Create a Dynamic Selection List
When you add a dynamic selection list to a page, JDeveloper adds source code to the JSF page, and list and iterator binding objects to the page definition file.
Example 6–3 shows the page source code after you add a dynamic
SelectOneChoice component to it.
Example 6–3 Dynamic SelectOneChoice List in JSF Page Source Code
af:selectOneChoice value={bindings.orderId.inputValue} label={bindings.orderId.label}
required={bindings.orderId.hints.mandatory} shortDesc={bindings.orderId.hints.tooltip}
id=soc1 f:selectItems value={bindings.orderId.items} id=si1
af:selectOneChoice
The f:selectItems tag, which provides the list of items for selection, is bound to the items property on the orderId list binding object in the binding container.
In the page definition file, JDeveloper adds the definitions for the iterator binding objects into the executables element, and the list binding object into the bindings
element, as shown in Figure 6–4
.
6-6 Java EE Developers Guide for Oracle Application Development Framework
Example 6–4 List Binding Object for the Dynamic Selection List in the Page Definition
File
executables variableIterator id=variables
iterator Binds=root RangeSize=25 DataControl=FODFacadeLocal id=FODFacadeLocalIterator
accessorIterator MasterBinding=FODFacadeLocalIterator Binds=orders1FindAll RangeSize=25
DataControl=FODFacadeLocal BeanClass=oracle.model.Orders1
id=orders1FindAllIterator iterator Binds=root RangeSize=25 DataControl=FODFacadeLocal
id=FODFacadeLocalIterator1 accessorIterator MasterBinding=FODFacadeLocalIterator1
Binds=ordersFindAll RangeSize=-1 DataControl=FODFacadeLocal
BeanClass=oracle.model.Orders id=ordersFindAllIterator
executables bindings
list IterBinding=orders1FindAllIterator id=orderId DTSupportsMRU=true StaticList=false
ListIter=ordersFindAllIterator AttrNames
Item Value=orderId AttrNames
ListAttrNames Item Value=orderId
ListAttrNames ListDisplayAttrNames
Item Value=orderId ListDisplayAttrNames
list bindings
By default, JDeveloper sets the RangeSize attribute on the iterator element for the ordersFindAll
iterator binding to a value of -1 thus allowing the iterator to furnish the full list of valid products for selection. In the list element, the id
attribute specifies the name of the list binding object. The IterBinding attribute references the iterator that iterates over the order1FindAll collection. The
ListIter attribute references the iterator that iterates over the ordersFindAll
collection. The AttrNames element specifies the base data source attributes returned by the base iterator. The ListAttrNames element defines the list data source
attributes that are mapped to the base data source attributes. The ListDisplayAttrNames
element specifies the list data source attribute that populates the values users see in the list at runtime.
6.3 Creating a List with Navigation List Binding
Navigation list binding lets users navigate through the objects in a collection. As the user changes the current object selection using the navigation list component, any
other component that is also bound to the same collection through its attributes will display from the newly selected object.
In addition, if the collection whose current row you change is the master collection in a data model master-detail relationship, the row set in the detail collection is
automatically updated to show the appropriate data for the new current master row.