Using ADF Model Data Binding in a Java EE Web Application 2-13
Figure 2–6 Data Controls Panel Context Menu
Depending on the component you select from the context menu, JDeveloper may display a dialog that enables you to define how you want the component to look.
The resulting UI component appears in the JDeveloper visual editor, as shown in Figure 2–7
.
Figure 2–7 Databound UI Component: ADF Table
2.3.2 What Happens When You Use the Data Controls Panel to Create UI Components
When a web application is built using the Data Controls panel, JDeveloper does the following:
■
Creates a DataBindings.cpx file in the default package for the project if one does not already exist, and adds an entry for the page.
DataBindings.cpx files define the binding context a container object that holds
a list of available data controls and data binding objects for the application. Each DataBindings.cpx
file maps individual pages to the binding definitions in the page definition file and registers the data controls used by those pages.
Figure 2–8 shows a DataBindings.cpx file in the overview editor of JDeveloper.
Tip: Instead of creating automatically bound UI components using
the Data Controls panel, you can create your UI first and then bind the components to the ADF Model layer. For more information, see the
Using Simple UI First Development section of the Oracle Fusion Middleware Fusion Developers Guide for Oracle Application Development
Framework.
2-14 Java EE Developers Guide for Oracle Application Development Framework
Figure 2–8 DataBindings.cpx File in the Overview Editor
Example 2–3 shows the code from the corresponding XML file.
Example 2–3 DataBindings.cpx File
?xml version=1.0 encoding=UTF-8 ? Application xmlns=http:xmlns.oracle.comadfmapplication
version=11.1.1.54.7 id=DataBindings SeparateXMLFiles=false Package=oracle.fodemo.supplier ClientType=Generic
ErrorHandlerClass=oracle.fodemo.frmwkext.CustomErrorHandlerImpl definitionFactories
factory nameSpace=http:xmlns.oracle.comadfcontrollerbinding className=oracle.adf.controller.internal.binding.
TaskFlowBindingDefFactoryImpl dtfactory className=oracle.adf.controller.internal.dtrt.binding.
BindingDTObjectFactory definitionFactories
pageMap page path=templatesStoreFrontTemplate.jspx
usageId=oracle_fodemo_supplier_StoreFrontTemplatePageDef page path=browse.jspx usageId=oracle_fodemo_supplier_browsePageDef
page path=suppliersupplierDetails.jspx usageId=oracle_fodemo_supplier_supplierdetailPageDef
page path=login_error.jspx usageId=oracle_fodemo_supplier_login_errorPageDef
. . . pageMap
pageDefinitionUsages page id=oracle_fodemo_supplier_StoreFrontTemplatePageDef
path=templates.StoreFrontTemplatePageDef page id=oracle_fodemo_supplier_browsePageDef
Using ADF Model Data Binding in a Java EE Web Application 2-15
path=oracle.fodemo.supplier.pageDefs.browsePageDef page id=oracle_fodemo_supplier_supplierdetailPageDef
path=oracle.fodemo.supplier.pageDefs.supplierdetailPageDef page id=oracle_fodemo_supplier_login_errorPageDef
path=oracle.fodemo.supplier.pageDefs.login_errorPageDef . . .
pageDefinitionUsages dataControlUsages
dc id=GenericServiceFacadeLocal path=oracle.fodemo.supplier.model.GenericServiceFacadeLocal
dc id=SupplierFacadeLocal path=oracle.fodemo.supplier.model.SupplierFacadeLocal
dataControlUsages Application
For more information about the .cpx file, see the Working with the DataBindings.cpx File section of the Oracle Fusion Middleware Fusion Developers
Guide for Oracle Application Development Framework.
■
Creates the adfm.xml file in the META-INF directory. This file creates a registry for the DataBindings.cpx file, and is used by the applications metadata layer to
allow customization and personalization of the application. Example 2–4
shows an example of an adfm.xml file.
Example 2–4 adfm.xml File
MetadataDirectory xmlns=http:xmlns.oracle.comadfmmetainf version=11.1.1.0.0
DataBindingRegistry path=oraclefodemosupplierDataBindings.cpx MetadataDirectory
■
For web applications, registers the ADF binding filter in the web.xml file. The ADF binding filter preprocesses any HTTP requests that may require access to
the binding context. For more information about the filter, see the Configuring the ADF Binding Filter section of the Oracle Fusion Middleware Fusion Developers
Guide for Oracle Application Development Framework.
■
Adds the following libraries to the project:
– ADF Model Runtime
– ADF Model Generic Runtime
■
Adds a page definition file if one does not already exist for the page to the page definition subpackage. The default subpackage is view.pageDefs in the
adfmsrc directory.
The page definition file pageNamePageDef.xml defines the ADF binding container for each page in an application’s view layer. The binding container
provides runtime access to all the ADF binding objects. Figure 2–9
shows a page definition file in the overview editor of JDeveloper.
2-16 Java EE Developers Guide for Oracle Application Development Framework
Figure 2–9 Page Definition File
■
Configures the page definition file, which includes adding definitions of the binding objects referenced by the page.
Example 2–5 shows the corresponding
XML for a page definition.
Example 2–5 Page Definition File
pageDefinition xmlns=http:xmlns.oracle.comadfmuimodel version=11.1.1.54.43 id=browsePageDef
Package=oracle.fodemo.supplier.pageDefs parameters
executables variableIterator id=variables
page path=templates.StoreFrontTemplatePageDef id=pageTemplateBinding Refresh=ifNeeded
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 Refresh=ifNeeded searchRegion Criteria=__ImplicitViewCriteria__
Customizer=oracle.jbo.uicli.binding.JUSearchBindingCustomizer Binds=productFindAllIterator
id=ImplicitViewCriteriaQuery executables
bindings tree IterBinding=productFindAllIterator id=productFindAll
nodeDefinition DefName=oracle.fodemo.supplier.model.Product
Using ADF Model Data Binding in a Java EE Web Application 2-17
Name=productFindAll0 AttrNames
Item Value=productId Item Value=productName
Item Value=costPrice Item Value=listPrice
Item Value=minPrice Item Value=productStatus
AttrNames nodeDefinition
tree methodAction id=removeProduct RequiresUpdateModel=true
Action=invokeMethod MethodName=removeProduct IsViewObjectMethod=false DataControl=SupplierFacadeLocal
InstanceName=SupplierFacadeLocal.dataProvider NamedData NDName=product
NDValue={bindings.productFindAllIterator.currentRow.dataProvider} NDType=oracle.fodemo.supplier.model.Product
methodAction action IterBinding=productFindAllIterator id=Delete
RequiresUpdateModel=false Action=removeCurrentRow bindings
pageDefinition
For more information about the page definition file, see the Working with Page Definition Files section of the Oracle Fusion Middleware Fusion Developers Guide for
Oracle Application Development Framework.
■
Adds prebuilt components to the view page. These prebuilt components include ADF data bindings that reference the binding
objects in the page definition file. Example 2–6
shows a JSF page that contains components that have been bound using ADF Model data binding. Note that
values of the output text components are bound to values of the productsFindAll
binding object, as defined in the page definition file in Example 2–5
.
Example 2–6 JSF Page with ADF Model Data Binding
. .
. af:column sortProperty=costPrice sortable=false
headerText={bindings.productFindAll.hints.costPrice.label} id=c6 align=right
af:outputText value={row.costPrice} id=ot1 af:convertNumber groupingUsed=false
pattern={bindings.productFindAll.hints.costPrice.format} af:outputText
af:column af:column sortProperty=listPrice sortable=false
headerText={bindings.productFindAll.hints.listPrice.label} id=c1 align=right
af:outputText value={row.listPrice} id=ot6 af:convertNumber groupingUsed=false
pattern={bindings.productFindAll.hints.listPrice.format} af:outputText
af:column af:column sortProperty=minPrice sortable=false
headerText={bindings.productFindAll.hints.minPrice.label}
2-18 Java EE Developers Guide for Oracle Application Development Framework
id=c3 align=right af:outputText value={row.minPrice} id=ot3
af:convertNumber groupingUsed=false pattern={bindings.productFindAll.hints.minPrice.format}
af:outputText af:column.
. .
.
■
For applications that use ADF Faces, adds all the files, and configuration elements required by ADF Faces components. For more information, see the Oracle Fusion
Middleware Web User Interface Developers Guide for Oracle Application Development Framework.
2.3.3 What Happens at Runtime