0% found this document useful (0 votes)
10 views46 pages

16-ADF Binding

The document provides an overview of the Oracle ADF Binding Layer, detailing the data binding concepts and the architecture of ADFm. It explains how data controls abstract business services and how bindings facilitate the connection between UI components and data collections. Additionally, it covers the creation and usage of various binding types, including iterator, value, and action bindings, along with examples of their implementation in Java.

Uploaded by

chakradhar s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views46 pages

16-ADF Binding

The document provides an overview of the Oracle ADF Binding Layer, detailing the data binding concepts and the architecture of ADFm. It explains how data controls abstract business services and how bindings facilitate the connection between UI components and data collections. Additionally, it covers the creation and usage of various binding types, including iterator, value, and action bindings, along with examples of their implementation in Java.

Uploaded by

chakradhar s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

16

Section 16
Oracle ADF – Binding Layer
What Is Data Binding?

• Declarative data binding facility


• Implements the JSR-227
JSR 227 specification
• Implemented as data control:
• Any Business Service
• Any UI
The Heart of ADF: ADFm

Desktop Browser-Based

ADF Swing Office JSP JSF ADF Faces View

St t
Struts JSF/ADF Controller
C t ll Controller

ADF Model (JSR 227) M d l


Model

Java EJB BAM BPEL Web ADF BC BI XML Portlet Business


Services Services
Toplink
The Heart of ADF: ADFm

Desktop Browser-Based

ADF Swing Office JSP JSF ADF Faces View

St t
Struts JSF/ADF Controller
C t ll Controller

Databinding Layer M d l
Model

Datacontrol Layer

Java EJB BAM BPEL Web ADF BC BI XML Portlet Business


Services
Toplink Services
ADF Faces architecture using ADF
MODEL UI RENDERING

ADF Ajax Page Lifecycle

ADF Binding
Expr. Language “bindings” Object
ADF DataControl

Ajax Render
Kit UI Component

EJB 3.0 Web Service BPEL …

Client
RDBMS
Fusion Application Development with
Oracle JDeveoper 11g and Oracle ADF

ADF Data Controls


About Data Controls

• Web application developer don’t need to know about


the classes that comprise a data control
• They are exposed to the ADF binding layer only
• Knowledge about the data control internals is
important for data control developers
• DataControl implementations
p
• manage connections to data providers
• handle exceptions raised by the business service
• manage the iterator binding to RowIterators in the data
provider
ADF Model Data Control Concepts

• Abstracts the implementation of Business Services


• Uses standard metadata interface to describe the services’
services
operations and data collection
• At design time, simplifies binding components to data control
operation or data collection
• At run time, wires business service data controls to UI bindings
from XML files
• Has
H th the ffollowing
ll i b benefits:
fit
• You write less code.
• You work the same way with any UI and Business Service
technology.
• You gain useful run-time features because you do not have to
code them yourself.
ADF 11g Built-in Data Controls

• ADF Business Components


• Java Class
• EJB
• URL (XML or CSV)
• Web Service
• E b
Essbase
• Place Holder
• Add your own
Application Module in the Data Control
Palette
• ADF BC data controls are
exposed through an
application module.
• Data controls are usable
with drag-and-drop
drag and drop.
ADF BC Application Module as
Data Control

Application Module

View Object

Cli t Method
Client M th d

Operation

Nested Application
Module
Fusion Application Development with
Oracle JDeveoper 11g and Oracle ADF

ADF Data Binding


g
ADF Data Bindings Concepts

• Data bindings abstract the details of accessing data from data


collections and of invoking its operations.
• There are three kinds of declarative bindings objects:
• “Iterator bindings”
• to bind to an iterator that tracks the current row in a
data collection (Results returned to page)
• “Value
Value bindings”
bindings
• to connect UI components to attributes in a data
collection (Text values entered on page)
• “Action
Action bindings”
bindings
• to invoke custom or built-in operations on a data control
or its data collections (Create Button)
ADFm: Data Controls and Data
Bindings
User interface

Data bindings

Data controls

Business Services
ADF Model Overview

What is a binding?
A binding exposes a property or table from the underlying
model in a generic Expression Language (EL)–accessible
way.
<af:inputText
< f i tT t value=
l
Text
“#{bindings.Ename.inputValue}”>
Binding

<af:commandButton
Action
Binding
actionListener=
Data ADFM
“#{bindings.Commit.execute}”>
control Bindings
<af:selectItems items=
List
“#{bindings.Deptno.items}”>
Binding

<af:table value=
Tree “#{bindings.DeptView.collectionModel}”>
Binding
ADF Model Overview

How are bindings created?


• Each page has its own set of bindings.
• All the bindings for a given page are defined in a PageDef.xml file.
• PageDefinition is also called the
BindingContainer.
Text
• The mapping from viewId to pageDef is binding
in the DataBindings.cpx file
Action
binding
viewId BindingContext PageDefinition
browse.jspx DataBindings.cpx browsePageDef.xml
List binding

Table
#{bindings.DeptView}
g p binding
ADF Binding in the ADF Faces UI
Fusion Application Development with
Oracle JDeveoper 11g and Oracle ADF

PageDef
g – The Data
Binding Configuration
PageDef.xml File

The key data binding artifact:


• Is accessible via the visual editor’s context menu or the link on its
Bindings tab
• Describes the service usage of a particular page, panel, or region
XML File
Fil content:
t t
• Default location controlled by the ADFm Settings > PageDef
subpackage project property
• Run-time
Run time location determined by the DataBindings.cpx
DataBindings cpx file (see
<context-param> CpxFileName in web.xml)
Three sections (in order of interest, and not appearance):
1 Bindings
1.
2. Executables
3. Parameters
Bindings Sections

• Accessed via the “bindings” object on the HTTP request


conventionally via Expression Language (EL):
• #{bindings} provides access to everything defined in the
Binding Container or page definition.
• Individual bindings (such as Table Bindings):
• Are objects
• Have attributes other
than value
• Are accessible via EL
• Example:
#{bindings.Products.rangesize}
Identifying Types of Bindings

Several types
y of g
generic bindings:
g
Types of Bindings: Attribute

Attribute binding
g example:
• Binds inputText component to a String value.
• In this example, the binding has a validate method that
must be called before the binding is updated.
• Use the <af:validator> tag to call this method.
<af:inputText value=“#{bindings.ProductName.inputValue}”>
<f:validator binding=“#{bindings
binding= #{bindings.ProductName.validator}
ProductName validator}”/>
/>
</af:inputText>

• Boolean attribute binding: Convert between any underlying


database type (0 or 1,
1 true or false,
false yes or no,
no and so
on) and a primitive Boolean object.
<af:selectBooleanCheckbox
value #{bindings.ContactableFlag.inputValue} />
value=“#{bindings.ContactableFlag.inputValue}”/>
Types of Bindings: Table

Table binding:
<af:table value="#{bindings.OrdersView2.collectionModel}" var="row"
rows="#{bindings.OrdersView2.rangeSize}“
emptyText="#{bindings.OrdersView2.viewable ?
'No rows yet.' : 'Access Denied.'}"
fetchSize="#{bindings.OrdersView2.rangeSize}">
<af:column sortProperty="OrderId" sortable="false"
headerText="#{bindings.OrdersView2.hints.
OrderId.label}"> PageDef
<af:outputText value="#{row.OrderId}"><tree IterBinding="OrdersView2Iterator"
<af:convertNumber id="OrdersView2">
groupingUsed="false" <nodeDefinition DefName="demomodel.
queries.OrdersView">
pattern="#{bindings.OrdersView2.hints.OrderId.format}"/>
<AttrNames>
</af:outputText> <Item Value="OrderId"/>
</af:column> ...
... </AttrNames>
</af:table> </nodeDefinition>
</tree>
Types of Bindings: List

List binding:
g Exports a list of legal
g values, enabling
g the
user to select one.
<af:selectOneChoice
value #{bindings.SupplierStatus.inputValue}
value="#{bindings.SupplierStatus.inputValue}"
label="#{bindings.SupplierStatus.label}"
required="#{bindings.SupplierStatus.hints.mandatory}"
testId="selectOneChoice1">
<f:selectItems value="#{bindings.SupplierStatus.items}"/>
</af:selectOneChoice>

<list IterBinding="Supplier1Iterator"
Uses="LOV_SupplierStatus"
id="SupplierStatus"
id= SupplierStatus DTSupportsMRU=
DTSupportsMRU="false"/>
false />
Types of Bindings: Action

Action bindingg example: This is a bindingg to an ADFm


built-in operation (can also bind to a business method.)

<af:commandButton actionListener=“#{bindings.Commit.execute}”
disabled=“#{!bindings.Commit.enabled}”/>

<action id="Commit" InstanceName="SupplierDataControl"


DataControl= SupplierDataControl
DataControl="SupplierDataControl"
RequiresUpdateModel="true"
Action="commitTransaction"/>
Using View Level Operations in Action
Bindings: Inserting a New Row
Use CreateInsert for:
• An editable table control
• A table with a single, current
editable row
• A master/detail page, if you want
the newly created master row to
correctly show no existing detail
rows
Binding Objects in the Executables
Section
The executables element of the page definition file
defines the following types of executable binding
objects:
• iterator: Basic link from data to binding
• methodIterator: Links results of method call to a binding
• accessorIterator: Links to detail collections for nested
objects
• variableIterator: Accesses data
local to page definition file
• invokeAction: Automatic lifecycle
invocation of method binding
Binding Objects in the Parameters
Section
The parameters element of the pageg definition file
defines the parameters for the page.
• Parameter binding objects declare the parameters that the
page evaluates at the beginning of a request.
• Page parameters are evaluated once during the Prepare
Model phase.
• Define the value of a parameter in the page definition file
using:
• Static values
• Binding expressions
• EL expressions that assigns
a static value
Fusion Application Development with
Oracle JDeveoper 11g and Oracle ADF

DEMO

Explore PageDef file


Fusion Application Development with
Oracle JDeveoper 11g and Oracle ADF

ADF Data Binding


g
Registry
Bindings MetaData Summary
Binding Context

Structure
Definition(s)
Page Definition(s) Binding Container Data Control
*.xml
*PageDef.xml

Binding Context Data Control


Definition
e to Description
DataBindings.cpx *.dcx
p File
DataBindings.cpx
g

• Provides the metadata from which the Oracle ADF binding


objects are created at run time
• Uses XML syntax
• Specifies:
• <pageMap>
• <dataControlUsages>
• <pageDefinitionUsages>
Fusion Application Development with
Oracle JDeveoper 11g and Oracle ADF

Java in ADF Data Binding


g
Binding Classes – The Java in ADF

• Bindings
g are defined in XML at designtime
g
• Binding objects are created at Runtime
• Generic Binding classes start with "JUCtrl"
• Specific ADF Faces binding classes start with
"FacesCtrl"
• Adapt the generic binding layer to component model
requirements
• Expose extra methods to be used in action listeners
• makeCurrent
• Labels
• Developers usually work with a subset of these classes
Class Diagram
Example: Accessing the Binding
Container from Java

import oracle.adf.model.BindingContext;
import oracle.binding.BindingContainer;

BindingContext bctx = BindingContext.getCurrent();
BindingContainer bindings = null;
bindings = bctx.getCurrentBindingsEntry();
Example: Executing a Method Binding
in Java

import oracle.binding.OperationBinding;
import oracle.jbo.domain.Number;

DCBindingContainer bindingsImpl = (DCBindingContainer)
bctx.getCurrentBindingsEntry();
OperationBinding relocateEmployees = null;
relocateEmployees = bindings.getOperationBinding("relocateEmployees");
HashMap<Number,Number> emps = new HashMap<Number,Number>();
emps.put(new Number(103),new Number(90));
emps.put(new Number(104),new Number(90));
emps.put(new Number(105),new Number(100));
relocateEmployees.getParamsMap().put("employees",emps);
relocateEmployees execute();
relocateEmployees.execute();
Example: Changing the value of an
Attribute Binding in Java

import oracle.binding.AttributeBinding;

AttributeBinding departmentName =
(AttributeBinding) bindings.get ("DepartmentName");
String oldValue = (String) departmentName.getInputValue();
String newValue = oldValue+"_new";
departmentName.setInputValue(newValue);
Example: Reading attributes from a
List Binding in Java

import oracle.jbo.uicli.binding.JUCtrlListBinding;
import oracle.jbo.domain.Number;

JUCtrlListBinding listBinding = null;
listBinding = (JUCtrlListBinding) bindings.get("JobId");
ViewRowImpl selectedListRow = null;
selectedListRow = (ViewRowImpl) listBinding.getSelectedValue();
String jobIdValue = (String) selectedListRow.getAttribute("JobId");
Number maxSalary = (Number) selectedListRow.getAttribute("MaxSalary");
Fusion Application Development with
Oracle JDeveoper 11g and Oracle ADF

ADF and SOA


Oracle ADF and SOA

• ADF data binding g is a SOA-enabling


g framework:
• Abstracts client interfaces from business services
• Uses implementation-agnostic meta-data binding layer
• D t control
Data t l defines
d fi service
i contract
t t
• Binds user interfaces to Web services
• Reads from remote or local WSDL file
• Web Services can be accessed through one of the
following options
• Web Services Data Control
• Web Services Proxy accessed from JavaBean Data Control
Oracle ADF and SOA

Service Transformation Service


Interface Layer Implementation
ADF
Faces
SOA Infrastructure

Dataco
W

Bind
S Place Order

ding

ontrol
ADF D
Swing L

JSP
Web Service Datacontrol: Step-by-Step

1. Create data control based on


a web
eb ser
service
ice
2. Edit web service data control
name and WSDL reference
3 Select methods to expose in
3.
data control
Creating the WS Proxy

• Web Service Proxyy g


generates a Java client from the
web service's WSDL file
• Using a POJO Wrapper for the Web Service Proxy,
developers can
• Select individual Web Service methods to expose to ADF
• Pre-process data before it gets exposed to ADF or send back
to Web Service
• Proxy generates all the required classes, including
Java bean representation of complex types
• Web service proxies or POJO wrapper is exposed to
ADF as Java bean data control
Creating a Web Services Proxy

You might also like