What Happens When You Create Master-Detail Tables and Forms

Displaying Master-Detail Data 5-5 When a specific master data object is displayed in the top form, the first related detail data object is displayed in the form below it. The user must use the form navigation to scroll through each subsequent detail data object. ■ ADF Master Table, Detail Table : Displays the master and detail objects in separate tables. When a specific master data object is selected in the top table, the first set of related detail data objects is displayed in the table below it.

5.3.2 What Happens When You Create Master-Detail Tables and Forms

When you drag and drop an accessor returned collection from the Data Controls panel, JDeveloper does many things for you, including adding code to the JSF page and the corresponding entries in the page definition file.

5.3.2.1 Code Generated in the JSF Page

The JSF code generated for a prebuilt master-detail widget is similar to the JSF code generated when you use the Data Controls panel to create a read-only form or table. If you are building your own master-detail widgets, you might want to consider including similar components that are automatically included in the prebuilt master-detail tables and forms. The tables and forms in the prebuilt master-detail widgets include a panelHeader tag that contains the fully qualified name of the data object populating the form or table. You can change this label as needed using a string or an EL expression that binds to a resource bundle. If there is more than one data object in a collection, a form in a prebuilt master-detail widget includes four commandButton tags for range navigation: First, Previous, Next , and Last. These range navigation buttons enable the user to scroll through the data objects in the collection. The actionListener attribute of each button is bound to a data control operation, which performs the navigation. The execute property used in the actionListener binding invokes the operation when the button is clicked. If the form displays a single data object, JDeveloper automatically omits the range navigation components.

5.3.2.2 Binding Objects Defined in the Page Definition File

Example 5–1 shows the page definition file created for a master-detail page that was created by dropping WarehouseStockLevelList, which is a detail object under the ProductFindAll object, on the page as an ADF Master Form, Detail Table. The executables element defines two accessorIterators: one for the product the master object and one for WarehouseStockLevels the detail object. At runtime, the UI-aware data model and the row set iterator keep the row set of the Tip: If you drop an ADF Master Table, Detail Form or ADF Master Table, Detail Table widget on the page, the parent tag of the detail component for example, panelHeader tag or table tag automatically has the partialTriggers attribute set to the id of the master component. At runtime, the partialTriggers attribute causes only the detail component to be rerendered when the user makes a selection in the master component, which is called partial rendering. When the master component is a table, ADF uses partial rendering, because the table does not need to be rerendered when the user simply makes a selection in the facet. Only the detail component needs to be rerendered to display the new data. 5-6 Java EE Developers Guide for Oracle Application Development Framework detail collection refreshed to the correct set of rows for the current master row as that current row changes. The bindings element defines the value bindings. The attribute bindings that populate the text fields in the form are defined in the attributeValues elements. The id attribute of the attributeValues element contains the name of each data attribute, and the IterBinding attribute references an iterator binding to display data from the master object in the text fields. The attribute bindings that populate the text fields in the form are defined in the attributeValues elements. The id attribute of the attributeValues element contains the name of each data attribute, and the IterBinding attribute references an iterator binding to display data from the master object in the text fields. The range navigation buttons in the form are bound to the action bindings defined in the action elements. As in the attribute bindings, the IterBinding attribute of the action binding references the iterator binding for the master object. The table, which displays the detail data, is bound to the table binding object defined in the table element. The IterBinding attribute references the iterator binding for the detail object. Example 5–1 Binding Objects Defined in the Page Definition for a Master-Detail Page executables variableIterator id=variables iterator Binds=root RangeSize=25 DataControl=SupplierFacadeLocal id=SupplierFacadeLocalIterator accessorIterator MasterBinding=SupplierFacadeLocalIterator Binds=productFindAll RangeSize=25 DataControl=SupplierFacadeLocal BeanClass=oracle.fodemo.supplier.model.Product id=productFindAllIterator accessorIterator MasterBinding=productFindAllIterator Binds=warehouseStockLevelList RangeSize=25 DataControl=SupplierFacadeLocal BeanClass=oracle.fodemo.supplier.model.WarehouseStockLevel id=warehouseStockLevelListIterator executables bindings action IterBinding=productFindAllIterator id=First RequiresUpdateModel=true Action=first action IterBinding=productFindAllIterator id=Previous RequiresUpdateModel=true Action=previous ... attributeValues IterBinding=productFindAllIterator id=attribute1 AttrNames Item Value=warrantyPeriodMonths AttrNames attributeValues ... tree IterBinding=productFindAllIterator id=productFindAll nodeDefinition DefName=oracle.fodemo.supplier.model.Product AttrNames Item Value=attributeCategory Item Value=listPrice Item Value=minPrice Item Value=objectVersionId Item Value=productId Item Value=productName Item Value=productStatus Displaying Master-Detail Data 5-7 AttrNames nodeDefinition tree tree IterBinding=warehouseStockLevelListIterator id=warehouseStockLevelList nodeDefinition DefName=oracle.fodemo.supplier.model.WarehouseStockLevel AttrNames Item Value=lastUpdateDate Item Value=objectVersionId Item Value=productId Item Value=quantityOnHand Item Value=warehouseId AttrNames nodeDefinition tree bindings

5.3.3 What Happens at Runtime: ADF Iterator for Master-Detail Tables and Forms