Professional Documents
Culture Documents
DEVELOPMENT
FRAMEWORK (ADF)
Assorted Notes
Table of Contents
1 Overview of Fusion Middleware and ADF ................................................................... 1
2 Understanding Development Tool: JDeveloper ........................................................... 2
3 Modeling Database Schema ...................................................................................... 5
4 Building Business Service with Default ADF Business Components ............................. 14
5 Persisting Data using Entity Object .......................................................................... 17
6 Querying Data using View Object ............................................................................ 19
7 Exposing Business Service through the Application Module ....................................... 20
8 Declaratively Customizing Business Services ............................................................ 28
9 Validating Business Services ................................................................................... 29
10 Introducing User Interface Technologies .............................................................. 31
11 Getting Started with Rich User Interface ............................................................... 33
12 Planning Pages using Layout Components ............................................................ 34
13 Designing User Interfaces and Page Flows............................................................ 36
14 Interactively Controlling with Navigation Components ........................................... 37
15 Ensuring Reusability in Web Applications .............................................................. 39
16 Working with Scopes, Parameters and Partial Page Refresh ................................... 42
17 Responding to Managed Beans, Events and Listeners ............................................ 44
18 Binding Model Layer with Business Services and Databound View .......................... 52
19 Querying Data with Search Components ............................................................... 53
20 Implementing Transactions ................................................................................. 58
21 Understanding Data Controls and Bindings ........................................................... 75
22 Programmatically Customizing Business Services................................................... 83
23 Deploying ADF Applications ................................................................................. 90
24 Securing ADF Applications ................................................................................... 94
25 Debugging and Troubleshooting ADF Applications ................................................. 95
26 ADF Best Practices .............................................................................................. 98
27 Miscellaneous ..................................................................................................... 99
28 Advance ADF .................................................................................................... 100
29 Integrating ADF with Web Service ...................................................................... 101
i
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
ii
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
1/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
2/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
Enterprise Management: Operations and administration by running on a grid architecture
with grouping, backup, and other high availability technologies, and integrating with Oracle
Enterprise Manager for systems management. Includes Fusion Middleware Control, Oracle
WebLogic Server Administration Console, Oracle WebLogic Scripting Tool, Oracle Process
Manager and Notification Server.
3. BAM
Oracle Business Activity Monitoring (Oracle BAM) gives business executives the ability to monitor
their business services and processes in the enterprise, to correlate KPIs down to the actual
business process themselves, and most importantly, to change business processes quickly or to
take corrective action if the business environment changes.
Overview:
Creates dashboards, alerts, and reports in real-time with no coding
Provides the ability to close the loop with corrective actions
Delivers more than 35 different event visualizations
Provides integrated historical event correlation
Benefits:
Gain real-time visibility into critical business processes through push-based dashboards and
alerts powered by event-driven architecture
Ensure real-time awareness of SLA and KPI performance
Provide visibility into existing SOA, BPM, and EDA investments, as well as third-party
infrastructures such as databases, JMS servers, and Web services
Gain efficiency through pre-built integration with Oracle SOA Suite, Oracle BPM Suite, Oracle
Business Intelligence, and more
4. BPEL
BPEL (Business Process Execution Language) is an XML-based language that allows Web services
in a service-oriented architecture (SOA) to interconnect and share data. Business processes can
be described in two ways:
Executable business processes model the actual behavior of a participant in a business
interaction.
Business protocols, in contrast, use process descriptions that specify the mutually visible
message exchange behavior of each of the parties involved in the protocol, without revealing
their internal behavior. The process descriptions for business protocols are called abstract
processes.
BPEL is used to model the behavior of both executable and abstract processes. The scope
includes:
Sequencing of process activities, especially Web Service interactions
Correlation of messages and process instances
Recovery behavior in case of failures and exceptional conditions
Bilateral Web Service based relationships between process roles
5. Business Process
A business process is a collection of linked tasks that find their end in the delivery of a service or
product to a client. A business process has also been defined as a set of activities and tasks that,
once completed, will accomplish an organizational goal.
3/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
6. Agile Management
Agile management or agile project management is an iterative and incremental method
of managing the design and build activities for engineering, information technology, and new
product or service development projects in a highly flexible and interactive manner, for
example, agile software development.
8. Portlet Types
Web Clipping Allows the Portal Page Designer to clip page content from existing Web sites
Producer and deliver it as a portlet.
Omni PortletProvides a wizard-based experience to allow Page Designers to publish data
Producer from SQL, XML, Web Services, Spreadsheets and Web Page as customizable
charts, tables or lists.
Sample Portlet Provides sample portlets built with Omni Portlet for demonstration purposes
Producer only. Developers should not use them to create real-use portlet instances.
4/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
3. Constraints
5/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
Primary key: This constraint defines a column or combination of columns that uniquely
identifies each row in the table.
Syntax to define a Primary key at column level:
column name datatype [CONSTRAINT constraint_name] PRIMARY KEY
Syntax to define a Primary key at table level:
[CONSTRAINT constraint_name] PRIMARY KEY (column_name1,
column_name2,..)
column_name1, column_name2 are the names of the columns which define the Primary
Key.
The syntax within the bracket i.e. [CONSTRAINT constraint_name] is optional.
For Example: To create an employee table with Primary Key constraint, the query would
be like.
6/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
ALTER TABLE employee ADD CONSTRAINT PK_EMPLOYEE_ID PRIMARY KEY
(id)
);
Foreign key: This constraint identifies any column referencing the PRIMARY KEY in another
table. It establishes a relationship between two columns in the same table or between
different tables. For a column to be defined as a Foreign Key, it should be defined as a
Primary Key in the table which it is referring to. One or more columns can be defined as
Foreign key.
Syntax to define a Foreign key at column level:
[CONSTRAINT constraint_name] REFERENCES
Referenced_Table_name(column_name)
Syntax to define a Foreign key at table level:
[CONSTRAINT constraint_name] FOREIGN KEY(column_name) REFERENCES
referenced_table_name(column_name);
For Example:
1) Let's use the "product" table and "order_items".
Foreign Key at column level:
CREATE TABLE product
(product_id number(5) CONSTRAINT pd_id_pk PRIMARY KEY,
product_name char(20),
supplier_name char(20),
unit_price number(10)
);
CREATE TABLE order_items
(order_id number(5) CONSTRAINT od_id_pk PRIMARY KEY,
product_id number(5) CONSTRAINT pd_id_fk REFERENCES,
product(product_id),
product_name char(20),
supplier_name char(20),
unit_price number(10)
);
Foreign Key at table level:
CREATE TABLE order_items
(order_id number(5) ,
product_id number(5),
product_name char(20),
supplier_name char(20),
unit_price number(10)
CONSTRAINT od_id_pk PRIMARY KEY(order_id),
CONSTRAINT pd_id_fk FOREIGN KEY(product_id) REFERENCES
product(product_id)
);
2) If the employee table has a 'mgr_id' i.e, manager id as a foreign key which references
primary key 'id' within the same table, the query would be like,
CREATE TABLE employee
(id number(5) PRIMARY KEY,
name char(20),
dept char(10),
age number(2),
mgr_id number(5) REFERENCES employee(id),
7/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
salary number(10),
location char(10)
);
Not Null Constraint: This constraint ensures all rows in the table contain a definite value
for the column which is specified as not null. Which means a null value is not allowed.
Syntax to define a Not Null constraint:
[CONSTRAINT constraint name] NOT NULL
Example: To create an employee table with Null value, the query would be like
CREATE TABLE employee
(id number(5),
name char(20) CONSTRAINT nm_nn NOT NULL,
dept char(10),
age number(2),
salary number(10),
location char(10)
);
Unique Key: This constraint ensures that a column or a group of columns in each row have
a distinct value. A column(s) can have a null value but the values cannot be duplicated.
Syntax to define a Unique key at column level:
[CONSTRAINT constraint_name] UNIQUE
Syntax to define a Unique key at table level:
[CONSTRAINT constraint_name] UNIQUE(column_name)
For Example: To create an employee table with Unique key, the query would be like,
Unique Key at column level:
CREATE TABLE employee
(id number(5) PRIMARY KEY,
name char(20),
dept char(10),
age number(2),
salary number(10),
location char(10) UNIQUE
);
or
CREATE TABLE employee
(id number(5) PRIMARY KEY,
name char(20),
dept char(10),
age number(2),
salary number(10),
location char(10) CONSTRAINT loc_un UNIQUE
);
Unique Key at table level:
CREATE TABLE employee
(id number(5) PRIMARY KEY,
name char(20),
dept char(10),
age number(2),
salary number(10),
location char(10),
8/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
CONSTRAINT loc_un UNIQUE(location)
);
Surrogate key: A surrogate key in a database is a unique identifier for either an entity in
the modeled world or an object in the database. A surrogate key is a substitution for the
natural primary key. It is just a unique identifier or number for each row that can be used
for the primary key to the table. The only requirement for a surrogate primary key is that it
is unique for each row in the table. Data warehouses typically use a surrogate, (also known
as artificial or identity key), key for the dimension tables' primary keys. They can use Infa
sequence generator, or Oracle sequence, or SQL Server Identity values for the surrogate
key. It is useful because the natural primary key (i.e. Customer Number in Customer table)
can change and this makes updates more difficult. Some tables have columns such as
AIRPORT_NAME or CITY_NAME which are stated as the primary keys (according to the
business users) but, not only can these changes, indexing on a numerical value is probably
better and you could consider creating a surrogate key called, say, AIRPORT_ID. This would
be internal to the system and as far as the client is concerned you may display only the
AIRPORT_NAME.
Unique Key:
It can be more than one unique key in one table.
Unique key can have null values
It can’t be candidate key
The unique key can be null and may not be unique.
short:
A short data type is a 16-bit signed two's complement integer.
Minimum value is -32,768 (-2^15)
Maximum value is 32,767 (inclusive) (2^15 -1)
A short data type can also be used to save memory as a byte data type. A short is 2 times
smaller than an int
Default value is 0.
Example: short s = 10000, short r = -20000
9/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
int:
Int data type is a 32-bit signed two's complement integer.
Minimum value is - 2,147,483,648. (-2^31)
Maximum value is 2,147,483,647(inclusive). (2^31 -1)
Int is generally used as the default data type for integral values unless there is a concern
about memory.
The default value is 0.
Example: int a = 100000, int b = -200000
long:
A long data type is a 64-bit signed two's complement integer.
Minimum value is -9,223,372,036,854,775,808. (-2^63)
Maximum value is 9,223,372,036,854,775,807 (inclusive). (2^63 -1)
This type is used when a wider range than int is needed.
Default value is 0L.
Example: long a = 100000L, int b = -200000L
float:
A float data type is a single-precision 32-bit IEEE 754 floating point.
Float is mainly used to save memory in large arrays of floating point numbers.
Default value is 0.0f.
Float data type is never used for precise values such as currency.
Example: float f1 = 234.5f
double:
A double data type is a double-precision 64-bit IEEE 754 floating point.
This data type is generally used as the default data type for decimal values, generally the
default choice.
The double data type should never be used for precise values such as currency.
Default value is 0.0d.
Example: double d1 = 123.4
boolean:
A boolean data type represents one bit of information.
There are only two possible values: true and false.
This data type is used for simple flags that track true/false conditions.
Default value is false.
Example: boolean one = true
char:
A char data type is a single 16-bit Unicode character.
Minimum value is '\u0000' (or 0).
Maximum value is '\uffff' (or 65,535 inclusive).
Char data type is used to store any character.
Example: char letterA ='A'
10/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
6. What Is DB View?
In SQL, a view is a virtual table based on the result-set of an SQL statement. A view contains rows
and columns, just like a real table. The fields in a view are fields from one or more real tables in
the database. A database view displays one or more database records on the same page. A view
can display some or all of the database fields. Views have filters to determine which records they
show. Views can be sorted to control the record order and grouped to display records in related
sets. Views have other options such as totals and subtotals. A View in Oracle and other database
systems is simply the representation of a SQL statement that is stored in memory so that it can
easily be re-used. For example, if we frequently issue the following query
SELECT customerid, customername FROM customers WHERE countryid='US';
To create a view, use the CREATE VIEW command as seen in this example
CREATE VIEW view_uscustomers
AS
SELECT customerid, customername FROM customers WHERE countryid='US';
This command creates a new view called view_uscustomers. Note that this command does not
result in anything being stored in the database at all except for a data dictionary entry that defines
this view. This means that every time you query this view, Oracle has to go out and execute the
view and query the database data. We can query the view like this:
SELECT * FROM view_uscustomers WHERE customerid BETWEEN 100 AND 200;
And Oracle will transform the query into this:
SELECT * FROM (select customerid, customername from customers WHERE
countryid='US')
WHERE customerid BETWEEN 100 AND 200
8. Trigger-Assigned Values
To synchronize when database trigger updates a column, use Refresh After Update or Refresh
After Insert. To use a database sequence to generate a primary key:
The Set data type of attribute to DBSequence
Set Updatable to Never
Refresh After Insert is selected automatically
11/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
When you create a new entity row whose primary key is a DBSequence, a unique negative
number gets assigned as its temporary value. This value acts as the primary key for the
duration of the transaction in which it is created. At transaction commit time, the entity
object issues its INSERT operation using the RETURNING INTO clause to retrieve the actual
database trigger–assigned primary key value. Any related new entities that previously used
the temporary negative value as a foreign key will get that value updated to reflect the actual
new primary key of the master. You can set the Updatable property of a DBSequence-
valued primary key to Never because the end-user never needs to update this value.
12/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
13/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
2. DB Objects vs ADFC BC
Database Table vs Entity Object (EO)
Database View vs View Object (VO)
Foreign Keys relationships vs Entity Associations
SQL Queries vs Application Module (AM) operations
14/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
Referenced Pool Size = 1. This means AM will support only 1 user, if there will be more users -
AM pooling will be working and AM instance will be shared between users.
15/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
5. Business Services
Functions vs Procedures: - Functions return a single variable by value whereas
procedures do not return any variable by value. Rather they return multiple variables by
passing variables by reference through their OUT parameter.
Procedures vs Trigger: - We have control over the firing of a stored procedure but we
have no control over the firing of a trigger.
A foreign key is the key i.e. Attribute which refers to another table primary key. A reference
key is a primary key to the table referred to by another table.
Math.round(((adf.currentDate - DOB)/365)*100)/100 is the Age find Groovy
Expression.
(new
oracle.jbo.server.SequenceImpl("HR.DEPT_SEQ",adf.object.getDBTr
ansaction())).getSequenceNumber()
adf.currentDate for Current date.
The FetchSize attribute defines the number of rows that will be sent to the client in one
round-trip.
By default, the access mode is set to Scrollable, which is okay as long as you are not iterating
through a large data set, but if you are then you should change the Access Mode to Range
Paging or Range Paging Incremental.
in Batches of the field – which represents the FetchSize (see source) and controls the
number of records fetched simultaneously from the database. (n+1) n is the no. of rows
that need to be displayed.
The iterator’ s RangeSize attribute defines the number of records ADFm requests from the
ADF BC layer simultaneously. Both RangeSize and FetchSize should be synchronized.
Override PostChanges method in EntityImpl to insert PK entity need to be inserted first
instead of the Foreign key reference column.
16/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
2. Alternate Key
If any table has more than one candidate key, then after choosing the primary key from those
candidate keys, the rest of the candidate keys are known as an alternate key of that table. Like
here we can take a very simple example to understand the concept of alternate key. Suppose we
have a table named Employee which has two columns EmpID and EmpMail, both have not null
attributes and unique value. So, both columns are treated as a candidate key. Now we make
EmpID as a primary key to that table then EmpMail is known as an alternate key.
3. Discriminator
Select this option if this is a discriminator column for a polymorphic entity object. A polymorphic
entity usage is one that references a base entity object in an inheritance hierarchy and is
configured to handle subtypes of that entity as well. The entity-based UserList view object has the
User entity object as its primary entity usage. The view object partitions each row retrieved from
the database into an entity row part of the appropriate entity object subtype of User. It creates
the appropriate entity row subtype based on consulting the value of the discriminator attribute.
For example, if the UserList query retrieves one row for user ngreenbe, one row for manager
sking, and one row for technician ahunold.
4. Attribute Settings:
Change the following entity object settings for attributes that you select from a drop-down list:
Name: It is a valid Java identifier.
Type: It is a Java data type.
Property Set: Select a named property set to apply to this attribute. A property set is a
version of an existing domain that is XML-only (no Java) and does not enforce a data type.
Value Type: It indicates whether the default value is a literal or an expression.
Value: This is the default value (optional). This value is not propagated from the default
value, if any, in the database table.
Persistent: Select this option if the attribute is persistent; deselect for transient attributes.
Mandatory: This is selected by default for columns with NOT NULLconstraints.
Change Indicator: Select this option if the column is a change indicator, such as a
timestamp, to be used to indicate that a row has been changed by another transaction. (If
no columns are specified as change indicators, ADF BC does a column-by-column
comparison.)
17/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
Derived from SQL Expression: This indicates that this attribute is derived from a SQL
expression. When selected, you can enter the column Type and an Expression.
Discriminator: Select this option if this is a discriminator column for a polymorphic entity
object.
Primary Key: This is selected by default for columns with PRIMARY KEYconstraints.
Unique: Specify that the corresponding table column is to be generated with a UNIQUE
constraint.
Queryable: Specify that this attribute can occur in the WHEREclause of a view object
(selected by default except for LOBs).
Effective Date: The attribute is either the start or end date of a date range for which the
entity row is effective (used for a point of time snapshot to answer such questions as what
an employee’s salary was on January 30, 2004.)
History Column: Select to use this column to log changes to the database. You can log
changes only if you have implemented Java Authentication and Authorization Service (JAAS)
authentication, the selected attribute is persistent, you have not selected Primary Key,
Mandatory, or Discriminator, and the attribute is Char, Character, String, Date, Timestamp,
or Number. After you have selected History Column, you can select the history column type
(created on or modified on for a Dateor Timestamp attribute, created by or modified by for
a Char, Character, or Stringattribute, or version number for a Numberattribute).
Updatable: You can enable the attribute to always or never be updatable, or enable it to
be updated only before the entity is first posted (while new).
Refresh After: Specify whether to retrieve the value from the database after an update or
insert.
Database Column: This indicates the name and SQL data type of the column to which the
attribute is mapped.
18/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
19/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
2. Application module
Application Module Pool Behavior Configuration Parameters
Pool Configuration Parameter Description
Failover Transaction State Upon Managed Release Enables eager passivation of pending
(jbo.dofailover) transaction state each time an application
module is released to the pool in the
"Managed State" mode.
20/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
21/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
22/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
Note:
23/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
25/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
The next time that application module instance is used by a user session, it will reacquire a JDBC
connection from the JDBC connection pool and use it for the span of time that application module
is checked out of the application module pool (again, typically the span of one HTTP request).
Since the application module instance "unplugs" itself from the JDBC connection object used to
create the PreparedStatements it might have used during the servicing of the current HTTP
request, those PreparedStatements are no longer usable on the next HTTP request because
they are only valid in the context of the Connection object in which they were created.
So, when using the connection pooling mode turned on like this, the trade-off is slightly more
JDBC overhead setup each time, in return for using a smaller number of overall database
connections.
The key difference is seen when many application module pools are all using the same underlying
database user for their application connection.
If 50 different application module pools each have even just a single application module
instance in them, with jbo.doconnectionpooling=false there will be 50 JDBC
application connections in use. If the application module pooling parameters are set such
that the application module pools are allowed to shrink to 0instances after an appropriate
instance idle timeout by setting jbo.ampool.minavailablesize=0, then when the
application module is removed from its pool, it will put back the connection it is holding onto.
In contrast, if 50 different application module pools each have a single application module
instance and jbo.doconnectionpooling=true, then the amount of JDBC connections
in use will depend on how many of those application modules are simultaneously being used
by different clients. If an application module instance is in the pool and is not currently being
used by a user session, then with jbo.doconnectionpooling=true it will have released
its JDBC connection back to the connection pool and while the application module instance
is sitting there waiting for either another user to need it again, or to eventually be cleaned
up by the application module pool monitor, it will not be "hanging on" to a JDBC connection.
For the highest performance, Oracle recommends not disconnecting the application module
instance from its database connection on each check in to the application module pool.
Accordingly, the default setting of the jbo.doconnectionpooling configuration
parameter is false.
The pooling of application module instances is already an effective way to optimize resource
usage, and there are runtime efficiencies that Oracle ADF can gain if you do not have to
disconnect application module instances from their associated JDBC connection after each
release to the pool. Effectively, by pooling the application modules which are related one-
to-one with a JDBC connection, you are already achieving a pooling of database connections
that is optimal for most web applications.
In contrast to Oracle's default recommendation, one situation in which it might be opportune
to use database connection pooling is when you have a large number of application module
pools all needing to use database connections from the same underlying application user at
the database level. In this case, the many application module pools can perhaps economize
on the total overall database sessions by sharing a single, underlying database connection
pool of JDBC connections, albeit at a loss of efficiency of each one. This choice would be
favored only if total overall database sessions are of maximum priority.
26/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
27/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
28/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
Entity-level validation
As we know, an entity represents a row in the database table. Entity-level validation is
the business rule that is added to the database row. For example, the validation rule
that has to be applied to a row is termed as entity-level validation.
There are two unique declarative validators that will be available only for entity-level
validation—Collection and UniqueKey. The following diagram explains that entity-level
validations are applied on a single row in the EMP table. The validated row is
highlighted in bold.
Attribute-level validation
Attribute-level validations are applied to attributes. Business logic mostly involves
specific validations to compare different attribute values or to restrict the attributes to
a specific range. These kinds of validations are done in attribute-level validation. Some
of the declarative validators available in ADF are Compare, Length, and Range.
The following diagram explains that the validation is happening on the attributes in the
second row:
29/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
30/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
2. FacesServlet:
FacesServlet is a servlet that manages the request processing lifecycle for web applications
that are utilizing Java Server Faces to construct the user interface.
Class facesservlet: javax.faces.webapp.FacesServlet
3. View Port
A viewport is a display area that is capable of navigating independently of other viewports. A
browser window and a region are both examples of viewports. The root viewport displays the
main page in a browser window. The root viewport may have child viewports, for example, regions
on the page, but does not have a parent viewport
4. Request Context
Context holder for the request-specific state, like current web application context, current locale,
current theme, and potential binding errors. It provides easy access to localized messages and
Error instances.
Suitable for exposition to views, and usage within JSP's "useBean" tag, JSP scriptlets, JSTL EL,
Velocity templates, etc. Necessary for views that do not have access to the servlet request, like
Velocity templates. It can be instantiated manually, or automatically exposed to views as model
attribute via AbstractView's "requestContextAttribute" property.
6. View Layer
FacesConfig.xml contains navigations and resource bundle configuration information as follows.
resourcebundle.txt
8. Struts Vs ADF
Similarities:
Both of them use MVC (Model-View-Controller) architecture.
Struts have config file struts-config.xml, ADF has the config file adfc-config.xml.
Both have their own framework classes and API.
Differences:
Struts don’t have any support for declarative development.
Struts don’t have its own components to use in development whereas ADF comes with its
own Oracle ADF faces components.
Struts don't have any default persistence mechanism (i.e., default ORM) whereas ADF has a
default persistence mechanism if we use ADF BC.
9. JSF Vs ADF
BC components are not available with JSF.
Entire business logic in java code whereas in ADF declarative with minimal code.
Though you can use JSF declaratively, you need to bind the JSF components manually with
bean properties.
The Java code we write in the ADF application mainly uses the Framework's API. ADF mainly
uses ADF faces components in the development. So, we can also use other components like
JSF Core, JSF HTML and Trinidad components in ADF web application.
The main advantage of ADF is that we can blend any technology with it. For example, you
don't need to have ADF business components in your model; you can have plain java code
or EJBs as well.
32/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
2. Stretchable components
<af:decorativeBox>
<af:panelAccordion>
<af:panelBox>
<af:panelCollection>
<af:panelGroupLayout layout="scroll">
<af:panelGroupLayout layout="vertical">
<af:panelHeader>
<af:panelSplitter>
<af:panelStretchLayout>
<af:panelTabbed>
<af:region>
<af:table>
<af:tree>
<af:treeTable>
33/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
34/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
35/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
2. Controller Layer
“Parent Action” and “Task flow return” activities are not available on any unbounded task flow.
Parent Outcome of “Parent Action” navigates to the associated flow (acts as control flow case).
36/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
2. Dynamic Navigation
In most web applications, navigation is not static. The page flow doesn't just depend on which
button you click, but also on the inputs that you provide. For example, submitting a login page
may have two outcomes: success or failure. The outcome depends on a computation, namely,
whether the username and password are legitimate. To implement dynamic navigation, the submit
button must have a method reference, such as
<h:commandButton label="Login"
action="#{loginController.verifyUser}"/>
In our example, loginController references a bean of some class, and that class must have
a method named verifyUser, that which should look somewhat like this:
String verifyUser() {
if (...)
return "success";
else
return "failure";
}
37/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
4. Wildcards
You can use wildcards in the from-view-id element of a navigation rule, for example.
<navigation-rule>
<from-view-id>/secure/*</from-view-id>
<navigation-case>
. . .
</navigation-case>
</navigation-rule>
This rule applies to all pages that start with the prefix /secure/. Only a single * is allowed, and it
must be at the end of the ID string. If there are multiple matching wildcard rules, the longest
match is taken.
Instead of leaving out a from-view-id element, you can also use one of the following to
specify a rule that applies to all pages.
38/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
3. Resource Catalog
Application servers - developed before the ubiquity of web-based applications -
expose back-end business logic through various protocols, sometimes including HTTP, and
manage security, transaction processing, resource pooling, and messaging.
Database is an organized collection of data. The data is typically organized to model
aspects of reality in a way that supports processes requiring information.
File system is the underlying structure a computer uses to organize data on a hard disk. If
you are installing a new hard disk, you need to partition and format it using a file
system before you can begin storing data or programs.
Universal Description, Discovery and Integration (UDDI, pronounced /ˈjʊdiː/) is a
platform-independent, Extensible Markup Language (XML)-based registry by which
businesses worldwide can list themselves on the Internet, and a mechanism to register and
locate web service applications.
URL Adapter is a turn-key ready "out of the box" URL Builder and URLRewriting Engine.
It's fast, reliable, has an amazingly simple and modern administration console and is powered
by our fanatical support scheme.
WebDAV (World Wide Web Distributed Authoring and Versioning) is the Internet
Engineering Task Force (IETF) standard for collaborative authoring on the Web: a set of
extensions to the Hypertext Transfer Protocol (HTTP) that facilitates collaborative editing
and file management between users located remotely from each.
39/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
BAM is an event-driven reporting tool that generates alerts and reports in real time, based
on a continuously changing data stream, some of whose data may not be in the database.
Oracle BI Presentation Server is a layer between Oracle BI Analytics Server and a Web server.
Presentation Server maintains a web catalog that has information for different users. It helps
Web catalog administrator to grant permissions for all users and perform other
configurations.
Oracle BPEL Process Manager is a BPEL engine that is a member of the Oracle Fusion
Middleware family of products. It enables enterprises to orchestrate disparate applications
and Web services into business processes. The Virtual Content Repository allows content
contributors to access repositories using the content tools in the WebLogic Portal
Administration Console. The Virtual Content Repository also connects your repositories to
your portal application so that developers can deliver repository content to your portal users.
Web Services Description Language (WSDL pronounced "wiz'-dul") is an XML-based
interface definition language that is used for describing the functionality offered by a web
service.
Memory Scope is a simple application to free up the unused ram of your computer and
make it always fast and reactive.
41/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
42/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
ADF, it's always recommended to define backing beans in ether "adf-config.xml" or task flow
files.
43/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
44/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
In a JSF application that uses the ADF Model layer, the phases in the page lifecycle are as follows:
Restore View: The URL for the requested page is passed to the bindingContext object,
which finds the page definition file that matches the URL. The component tree of the
requested page is either newly built or restored. All the component tags, event handlers,
converters, and validators on the submitted page have access to
the FacesContext instance. If the component tree is empty, (that is, there is no data from
the submitted page), the page lifecycle proceeds directly to the Render Response phase. If
any discrepancies between the request state and the server-side state are detected, an error
will is thrown and the page lifecycle jumps to the Render Response phase.
JSF Restore View: Provides before and after phase events for the Restore View phase.
You can create a listener and register it with them before or after the event of this phase,
45/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
and the application will behave as if the listener were registered with the Restore View phase.
The Initialize Context phase of the ADF Model page lifecycle listens for the after(JSF
Restore View) event and then executes. The ADF Controller uses listeners for the before
and after events of this phase to synchronize the server-side state with the request. For
example, it is in this phase that browser back button detection and bookmark references are
handled. After the before and after listeners are executed, the page flow scope is available.
Initialize Context: The page definition file is used to create
the bindingContainer object, which is the runtime representation of the page definition
file for the requested page. The LifecycleContext class used to persist information
throughout the ADF page lifecycle phases is instantiated and initialized with values for the
associated request, binding container, and lifecycle.
Prepare Model: The ADF page lifecycle enters the Prepare Model phase by calling
the BindingContainer.refresh(PREPARE_MODEL) method. During the Prepare Model
phase, BindingContainer page parameters are prepared and then evaluated. If
parameters for a task flow exist, they are passed into the flow. Next, any executables that
have their refresh attribute set to prepareModel are refreshed based on the order of entry
in the page definition file's <executables> section and on the evaluation of
their RefreshCondition properties (if present). When an executable leads to an iterator
binding refresh, the corresponding data control will be executed, and that leads to the
execution of one or more collections in the service objects. If an iterator binding fails to
refresh, a JBO exception will be thrown and the data will not be available to display. If the
incoming request contains no POST data or query parameters, then the lifecycle forwards
to the Render Response phase. If the page was created using a template, and that template
contains bindings using the ADF Model layer, the template's page definition file is used to
create the binding container for the template. The container is then added to the binding
context. If any task flow executable bindings exist (for example, if the page contains a
region), the task flow binding creates an ADF Controller ViewPortContext object for the
task flow, and any nested binding containers for pages in the flow are then executed.
Apply Request Values: Each component in the tree extracts new values from the
request parameters (using its decode method) and stores those values locally. Most
associated events are queued for later processing. If you have set a
component's immediate attribute to true, then the validation, conversion, and events
associated with the component are processed during this phase and the lifecycle skips the
Process Validations, Update Model Values, and Invoke Application phases. Additionally, any
associated iterators are invoked. For more information about ADF Faces validation and
conversion, see the "Validating and Converting Input" chapter in the Oracle Fusion
Middleware Web User Interface Developer's Guide for Oracle Application Development
Framework.
JSF Apply Request Values: Provides before and after phase events for the Apply Request
Values phase. You can create a listener and register it with them before or after the event
of this phase, and the application will behave as if the listener were registered with the Apply
Request Values phase.
Process Validations: Local values of components are converted and validated on the
client. If there are errors, the lifecycle jumps to the Render Response phase. At the end of
this phase, new component values are set, any validation or conversion error messages and
events are queued on FacesContext, and any value change events are delivered.
Exceptions are also caught by the binding container and cached.
46/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
JSF Process Validations: Provides before and after phase events for the Process
Validations phase. You can create a listener and register it with them before or after the
event of this phase, and the application will behave as if the listener were registered with
the Process Validations phase.
Update Model Values: The component's validated local values are moved to the model
and the local copies are discarded. For any updateable components (such as
an inputText component), corresponding iterators are refreshed, if the refresh condition
is set to the default (deferred) and the refresh condition (if any) evaluates to true. If you
are using a backing bean for a JSF page to manage your UI components, any UI attributes
bound to a backing bean property will also be refreshed in this phase.
JSF Update Model Values: Provides before and after phase events for the Update Model
Values phase. You can create a listener and register it with them before or after the event
of this phase, and the application will behave as if the listener were registered with the
Update Model Values phase.
Validate Model Updates: The updated model is now validated against any validation
routines set on the model. Exceptions are caught by the binding container and cached.
Invoke Application: Any action bindings for command components or events are invoked.
JSF Invoke Application: Provides before and after phase events for the Invoke Application
phase. You can create a listener and register it with them before or after the event of this
phase, and the application will behave as if the listener were registered with the Invoke
Application phase.
Metadata Commit: Changes to runtime metadata are committed. This phase stores any
runtime changes made to the application using the Metadata Service (MDS). For more
information about using MDS to persist runtime changes
Initialize Context (only if navigation occurred in the Invoke Application lifecycle): The
Initialize Context phase listens for the beforeJSFRenderResponse event to execute. The
page definition file for the next page is initialized.
Prepare Model (only if navigation occurred in the Invoke Application lifecycle): Any
page parameters contained in the next page's definition are set.
Prepare Render: The binding container is refreshed to allow for any changes that may
have occurred in the Apply Request Values or Validation phases. Any iterators that
correspond to read-only components (such as an outputText component) are refreshed.
Any dynamic regions are switched if needed. The prepareRender event is sent to all
registered listeners, as is the afterJSFRenderResponse event.
Render Response: The components in the tree are rendered as the Java EE web container
traverses the tags on the page. State information is saved for subsequent requests and the
Restore View phase. To lessen the wait time required to display both a page and any
associated data, certain ADF Faces components such as the table component, use data
streaming for their initial request. When a page contains one or more of these components,
the page goes through the normal lifecycle. However, instead of fetching the data during
that request, a special separate request is run. Because the page has just rendered, only the
Render Response phase executes for the components that use data streaming, and the
corresponding data is fetched and displayed. If the user's action (for example scrolling in a
table), causes a subsequent data to fetch another request is executed. Tables, trees, tree
tables, and data visualization components all use data streaming.
JSF Render Response: Provides before and after phase events for the Render Response
phase. You can create a listener and register it with them before or after the event of this
phase, and the application will behave as if the listener were registered with the Render
Response phase.
47/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
48/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
Reset the value of InputText:
RichInputText input = (RichInputText) JSFUtils.findComponentInRoot(id);
input.setSubmittedValue(null);
input.resetValue();
AdfFacesContext.getCurrentInstance() .addPartialTarget(input);
In Bean class:
public List TableKey() {
List<Key> list= new ArrayList<Key>();
for(Object empKey:empsTable.getSelectedRowKeys())
empsTable.setRowKey(empKey);
JUCtrlHierNodeBinding data =
(JUCtrlHierNodeBinding)empsTable.getRowData();
list.add(data.getRow().getKey());
return list;
}
49/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
51/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
3. Tuning RangeSize:
rows and fetchSize are set the same as RangeSize. autoHeightRows value cannot be
larger than fetchSize attribute. The best practice is to set RangeSize to be
autoHeightRows+1.
For additional information refer:
https://vtkrishn.com/tag/fetchsize/
http://adfwithejb.blogspot.in/2015/05/understanding-aftable-property.html
52/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
We want to change the label of the ‘State’ field depending on the selected Value of the
‘CountryId’ field. The page is simply created by dragging the named criteria ‘All Queryable
Attributes’ onto the page as ‘Query with Table’.
To make the UI more interesting we use an af:selectOneChoice to select the country.
Depending on the selected country we like to show different labels for the ‘State’ field. If we select
the ‘United States of America’ as a country, the label should show ‘US States’, if we select
‘Germany’ we want to see ‘Bundesland’ and for Switzerland, we want to show ‘Kanton’. For the
remaining countries, we show ‘State’.
53/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
Here we see that the label changed to ‘Kanton’ for the country Switzerland. Selecting the USA will
change the label to ‘US State’
54/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
2. Implementation
To implement this we only need to add some groovy script to the model project. To be precise we
add groovy to the attribute label of the view which is used in the UI for the af:query.
Adding the groovy to the view will guarantee that the UI always shows the effect. In the sample
(download instructions below) you’ll find a second page where the view is dropped as a af:form.
Running this page you’ll see the same effect.
OK, let’s have a look at the groovy script
if (CountryId == 'US') {
return 'US State';
} else if (CountryId == 'DE') {
return 'Bundesland';
} else if (CountryId == 'CH') {
return 'Kanton';
} else if (CountryId != null) {
return CountryId + ' State';
} else {
return 'State';
}
The script checks for specific countries and depending on which country is currently selected it
return a special label. For country ‘DE’ it returns ‘Bundesland’, for country ‘CH’ it returns ‘Kanton’.
For other countries we return the country code we get from the country attribute and add ‘State’
to it. A special case we have to handle is if the country is null or empty. In this case, we return
‘State’.
Below we see that we add the script to the attributes ‘UI Hint’ tab as ‘Label’. This is only possible
in 12c, so if you are using an earlier version, you have to use java code to get the same result.
This is all we have to do. The sample which is build using JDev 12.2.1.2.0 can be downloaded
from BlogChangeQueryLabel. The sample uses the HR DB schema.
http://www.learnoracleadf.com/2013/05/programatic-handle-to-adf-query.html
55/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
if (attrDescriptor.getName().equalsIgnoreCase("EmployeeId")) {
// EmployeeId is one of the query items in the search pane
EmployeeId =
(String)((AttributeCriterion)criterion).getValues().get(0);
}
}
DCBindingContainer bc =
56/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
ViewCriteria vc = getViewCriteria(bc, qd);
//Execute the query Listener using EL. This will execute the query
component. If u see the exp, this was initially applied to QueryListener..
Later we assigned QueryListener to our custom method.
invokeMethodExpression("#{bindings.VOCriteriaQuery.processQuery}",
queryEvent);
57/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
20 Implementing Transactions
1. ADF TaskFlow Transaction Basics
<http://suneesh-adf.blogspot.com/2013/10/adf-taskflow-transaction-basics.html >
The transaction is a collection of works either committed or rollback. Create a calling and called
task flow to go through some of the transaction basics of task flow.
From the behavior section of the called task flow, you can see the following options
58/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
No Controller transaction is the default option means the called task flow does not
participate in any transaction management.
Always begin New Transaction - Transaction is created when entering to the task flow and
completes the task flow when exists the task flow
Always Use Existing transaction - Called task flow participates the existing transaction
User Existing transaction if possible - Participate the existing transaction if available or start
a new transaction if not available
restore-save-option
Use restore-save-option =true if you want to discard the changes the end-user makes with in a
called bounded task flow when the called bounded task flow exits. This option applies only if the
bounded task flow is entered by joining the existing transaction and a save point created on entry
No save point on task flow entry if selected prevent the creation of ADF model save point on task
flow entry if taskflow participate in 'Always Use existing transaction ' or 'User existing transaction
if Possible'. In this case, overhead associated with a save point is not created for the transaction.
End the transaction from task flow return activity by selecting the End transaction property to
commit or rollback.
59/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
Always begin new txn Begin new if one is not open Always begin new one
Always Use existing txn Throws an exception if txn is Invalid. The checkbox cannot
already open be deselected
Use Existing txn if Begin a new txn if one is not Always begin a new txn
possible already open
60/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
61/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
What is a DataControl Frame?
A DC Frame is a container that holds the state of all associated Data controls. It may be confusing
now, but you will get more clarity once we see an example. E.g. : Let’s take 2 different taskflows
"Employees" and "Departments", Both these Taskflows use the same Application Module(this is
very important), default settings and are used on the same page.
This is how it works internally.
62/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
A Commit/RollBack anywhere in the DCFrame would update all DC changes to
DataBase i.e. Commit/Rollback in Employees taskflow will Commit/Rollback changes in
Departments taskflow too.
Check out the below example with sample data. As you can see, Both the taskflows have the same
DC Frames.
63/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
What is Data Control Scopes?
Now that we have a good understanding of how Datacontrol Frames work, let's discuss Data
Control Scopes.
There are 2 different kinds of DC Scopes –
Shared (Default, It is what we saw in the previous example).
Isolated.
Now, what if we want to separate the transactions i.e. if a commit in Departments taskflow should
not affect Employees Taskflow?
We have an option in Taskflow level to separate the DataControl Frames,
Go to Taskflow behavior> Set the Transaction as "Isolated".
64/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
Here is the example with sample data -
Note: the DC frame, it is different for both taskflows. A similar example can be explained for
parent and child taskflows too. A solid understanding of datacontrol scopes will help understand
the next post in this series.
65/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
As you can see we have 2 iterators from 2 different Application modules in the parent as well as
child taskflow.
66/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
Case 1 (Default Taskflow Settings) -
Parent Taskflow
Transaction - No Controller Transaction
Data Control Scope - SHARED
Child Taskflow
Transaction - No Controller Transaction
Data Control Scope - SHARED
This is how it will work internally-
Key Observations
Since Datacontrol Scope is set to Shared, Both the Taskflows will share the same DC Frame.
Both AppModule1 and AppModule2 will create the Root Application Module which eventually
means 2 Connections, 2 Separate Commit/RollBack per transaction, etc.
In Parent/Child Taskflows, Commit in Employee Iterator 1 will not reflect changes in Employee
Iterator 2 and vice versa until a new control state is created.
A Commit/RollBack in Child Taskflow's Employee Iterator1 will update changes in Employee
Iterator1 of Parent Taskflow and vice versa because they share the same Transaction.
A Real Example - Notice the Transaction and AppModule
67/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
68/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
Case 2 -
Parent Taskflow
Transaction - No Controller Transaction
Data Control Scope - SHARED
Child Taskflow
Transaction - No Controller Transaction
Data Control Scope - ISOLATED
Key Observations
Since Datacontrol Scope of the child is set to Isolated, Both the Taskflows will have separate
DC Frames.
Since DC Frames are separate each of iterators will have Transactions of its own so
2 Taskflows * 2 AppModules = 4 Transactions, 4 Connections (Not good right?)
Commit/RollBack in any of the iterator will not affect any other.
A Real Example
69/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
70/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
Let’s use the same application used in the previous post and discuss more about Taskflow
Transactions Management
What is Transaction management in taskflow?
Transactions are managed by the Application Modules, as an application grows we might want to
use multiple data controls from different application modules in a single view.
Eg: If we use datacontrol from 3 different application modules (Assuming they are not nested in
Data Model) in one taskflow view, then we end up with 3 Root App Modules = 3 Database
connections and the important part is we need 3 separate commits to post all changes to DB.
ADF taskflows offer an elegant solution to such problems, which is to manage Transactions at
taskflow level.
Case 3:
Parent Taskflow
Transaction - Always Begin New Transaction
Data Control Scope - ISOLATED
Child Taskflow
Transaction - Use Existing Transaction if possible
Data Control Scope - SHARED
As we saw in Case 1 and 2, each Application module is created as Root with separate Transactions.
In Case 3 let’s make the Parent Taskflow begin new Transaction and Child to Use the Existing
Transaction.
71/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
Observations
Parent Taskflow begins a new Transaction at Taskflow level and Child taskflow uses the
same.
Only Root Application Module (App module 1) is created and App module 2 is nested inside
App Module 1. Hence overall only 1 Transaction and 1 DB Connection is used across different
application modules and taskflows.
Only one DCFrame is used.
A commit/rollback in any iterator will commit the changes to DB since they use one
Transaction.
There is also a better way to do it using taskflow return, which we can discuss later in a different
post.
72/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
Similarly, we can create multiple cases based on different Transaction management and
Datacontrol scope options, but with the above examples, you will be able to figure out those
combinations pretty easily.
E.g.:
Case 4:
Parent Taskflow
Transaction - No Controller Transaction
Data Control Scope - ISOLATED
Child Taskflow
Transaction - Always Begin New Transaction
73/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
Data Control Scope - ISOLATED
Case 5:
Parent Taskflow
Transaction - No Controller Transaction
Data Control Scope - ISOLATED
Child Taskflow
Transaction - Use Existing Transaction if possible
Data Control Scope - ISOLATED
Parent taskflow will use 2 Transactions and Child creates a new Transaction since no new
transaction already exists in the taskflow layer.
In my opinion, Don't use Transaction management options unless you are sure of its use.
In most cases, you needn't use it.
In simple terms -
Data Control Scope - To manage DC Frames.
Transaction management options - To manage DB Transactions in the taskflow layer instead
of in the model layer using Application Modules.
You can check out the application used in these blog posts from
https://github.com/bsatishinbox/FusionSamples/tree/master/TransactionFlows
74/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
2. ADF Bindings
Oracle Application Development Framework (Oracle ADF) provides several types of binding objects
to support the attributes and operations exposed by the Oracle ADF data controls for a particular
business object:
Iterator binding, one per accessor attribute that your page or panel displays. Iterates over
the business objects of the data collection and maintain the row currency and state.
Value bindings, one for each databound UI component. It provides access to data.
Action binding, specifically defined for a button component. It provides access to
operations defined by the business object.
You create these bindings in JDeveloper through your interaction with the Data Control
Palette, a visual editor, the Structure window, and the Property Inspector. You can
view the binding in your application in any one of several ways:
76/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
In the source code view of a web page, where binding references appear in expressions
that get evaluated at runtime using the expression language (EL) features. In the code
view, the expression looks like this:
<c:forEach var="rv"
items="${bindings.DataBindingObject.theCollectionProperty}"
The data binding object accesses the Oracle ADF binding container through the
bindings variable, which is a variable that specifies the namespace for the binding
containers in the ADF binding context. The binding container is initialized for Model
2&ndashstyle web applications in the Oracle ADF class
oracle.adf.controller.struts.actions.DataAction.
In the code view of a JClient panel or form, where the setModel() method call on the
UI component initializes the data binding object and accesses the binding container
through the ADF binding context (specified by the setBindingContext() method
call on the data panel).
The binding container is initialized from the PanelName UIModel.xml file in the JClient
project when the panel binding is created (by the JUPanelBinding panelBinding
constructor).
In the Structure window for either client type (web page or JClient panel), where the
data binding objects defined for each UI component in your view document appear in
the UI Model tab icon (UI Model) tab. To edit the declarative properties of the binding
definitions, right-click and choose Edit. To understand what values you can set for
runtime-only properties, select the binding node and press F1.
3. Model Layer
“DataBindings.cpx” will be created implicitly, when a data bound component (pagedef.xml)
was created.
6. Expression Language
Expression Language is used for adding additional logic to the runtime customization of page
components.
The examples provided in this document serve the following basic customization needs, and
whilst more advanced logic is possible venturing into great complexity may take your
customization beyond the scope that page composer is designed to support.
Dynamically set a field to default a specific value
Dynamically set the display properties of a specific field
Conditionally hide or disable a field or region
Generally, EL statements return either a value such as ‘Richard’, or a Boolean such as TRUE
if the test is a success. These are then used in setting ADF page component properties, such
as Value, Required, or Visible. The examples in this document include a mixture of return
values used for setting various properties. In ADF a partial page refresh is used to fire the
EL logic, and careful testing in a safe environment is needed to ensure your EL executes at
the expected places. An example might be properly defaulting values for fields upon actions
such as create, edit, and re-edit.
Expression Language (EL) is widely used in ADF Binding to reference items in the Binding
Context. In some scenarios, direct use of EL reference isn't enough and manipulation of
several EL references needed to accomplish the task. While you can always manipulate the
logics in a managed bean, if you want to go with "declarative", here is why I am saying
about.
Varchar2 type in SQL format (database) is converted to String automatically, but Number
type in SQL is converted to oracle.jbo.domain.Number format. EL inherit generic Java
API and can only recognize java.lang.Number type.
Therefore, if you have two EL binding references to two database Number attributes:
#{bindings.NumberAtt1.inputValue} and
#{bindings.NumberAtt2.inputValue}. If you want to evaluate if the first number
greater than the second number, you cannot use compareTo() method which belongs to
oracle.jbo.domain.Number and you cannot use #{A > B} because A or B is not
java.lang.Number
A simple conversion is to attach ".value" at the end of EL binding reference and it will convert
it to a java.lang.Double format type.
In JSF pages, a typical ADF data binding EL expression uses the following syntax to reference
any of the different types of binding objects in the binding container:
#{bindingVariable.BindingObject.propertyName}
where:
bindingVariable is a variable that identifies where to find the binding object being
referenced by the expression. The bindings variable is the most common variable used
in ADF binding expressions. It references the binding container of the current page. By
79/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
default, all components created from the Data Control Palette use the bindings variable
in the binding expressions.
BindingObject is the name of the binding object as it is defined in the page definition
file. The binding object name appears in the id attribute of the binding object definition
in the page definition and is unique to that page definition. An EL expression can
reference any binding object in the page definition file, including parameters,
executables, or value bindings. When you use the Data Control Palette to create a
component, JDeveloper assigns the names to the binding objects based on the names
of the items in the data control.
propertyName is a variable that determines the default display characteristics of each
databound UI component and sets properties for the binding object at runtime. There
are different binding properties for each type of binding object. For example, in the
following expression: #{bindings.SvrId.inputValue}
JSP 2.1 and JSF 1.2 - both of them use a unified Expression language. One major and the
most obvious difference is between $ and #. JSP 2.1 uses $ and JSF 1.2 uses # in an EL.
$ - immediate evaluation.
$ syntax executes expressions eagerly/immediately, which means that the result is
returned immediately when the page renders.
# - deferred evaluation.
# syntax defers the expression evaluation to a point defined by the implementing
technology. In general, JSF uses deferred EL evaluation because of its multiple
lifecycle phases in which events are handled. To ensure the model is prepared before
the values are accessed by EL, it must defer EL evaluation until the appropriate point
in the life cycle.
80/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
You should keep the following points in mind while using this binding in the application:
invokeAction is executed for each request from the web client. Use the appropriate Refresh
property for the invokeAction binding to decide the lifecycle phase at which the binding is
refreshed.
If the method contains page initialization logic and it is supposed to be executed only once during
the page load, check the feasibility of using a method call activity in the navigation flow definition
(bounded or unbounded task flow XML file), before the page renders, to invoke the method instead
of using invokeAction. If method call activity is not a viable option for you, make sure that the
framework is not triggering the invokeAction executable multiple times during the page
lifecycle by adding the appropriate refreshCondition.
Page: The <page> binding is used to refresh the data binding for the page template. This entry
will appear only if the current page is built by choosing a data-bound page template. The page
binding executable is refreshed during the Prepare Model phase. During this phase, the binding
container for the template is created based on the template's page definition file, and it is added
to the binding context.
Search region: <searchRegion> defines the executable binding definition for the query
component and Query By Example (QBE) criteria that appear on a UI table. This binds the
named view criteria to the iterator for data collection.
Task flow: <taskFlow> defines the binding for the task flow that is embedded in a region.
During the page lifecycle, the framework instantiates the binding container for a region's task
flow.
Multitask flow: <multiTaskFlow> defines the binding for an unknown number of task flows
whose IDs are decided at runtime. This is useful when you have a page that contains an unknown
number of regions. An example is the dynamic panelTabbed component where each tab is a
region, whose contents are decided at runtime.
8. Bindings
The bindings section in a page definition file defines value bindings as well as action bindings for
a web page. Value bindings bind the UI with the attribute value returned by an iterator, and action
bindings bind component actions (events) with operations from the underlying data model
exposed through data control. ADF supports the following binding types:
Action: The <action> binding defines bindings for built-in operations on the row iterator
object as well as on data control.
Method action: The <methodAction> binding defines bindings for custom methods
exposed through data control.
Attribute value: The <attributeValues> binding defines the binding for accessing
attribute values of the currently selected row in a data collection. Note that attribute binding
is accessed through the iterator executable.
Boolean value: The <button> binding (also known as Boolean binding) defines the
bindings for attribute types whose value takes the form of checked or unchecked states.
Data visualization components bindings: ADF provides data-binding supports for the
following graph types: Map
Gantt
Gauge
Graph
PivotTable
List: The <list> binding defines the bindings for a list of items. The list binding definition
can refer to the model-driven list, static list, or dynamic list. ADF also supports a variant of
81/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
list binding, the <listOfValues> binding, which offers more options on the UI such as
lazy loading, search and select, and range fetching.
Binding Business Services with User Interface
Tree bindings: The <tree> binding defines the binding for nested data collections that
are used for populating hierarchical UI components such as trees and hierarchy viewer
components. The tree binding even works for single-level collections as well. When you drag-
and-drop a collection as a table, JDeveloper generates tree binding although the data
collection is not hierarchical.
Table binding: The <table> binding defines the binding for a single-level collection of
data.
82/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
83/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
previous(): Steps backward, designating the previous row as the current row
reset(): Clears the “current row” designation and places the iterator in the slot before the
first row
setCurrentRow(Row row): Designates a given row as the current row In addition to the
RowSet and RowIterator interfaces, ViewObjectImpl implements the ViewObject
interface, containing the following methods:
applyViewCriteria(ViewCriteria criteria): Applies the view criteria to this view
object
createRowSet(java.lang.String name): Creates and names a row set for the view
object
createViewCriteria(): Creates a “Query by Example” view criteria object
findViewLinkAccessor(ViewLink vl): Finds the view link accessor attribute
getOrderByClause(): Retrieves the current ORDER BY clause of the view object’s query
statement
getQuery(): Retrieves the view object’s query statement
getViewCriteria(): Gets this view object’s view criteria
getViewLinkNames(): Retrieves the names of the view object’s View Links
getWhereClause(): Retrieves the current WHERE clause of the view object’s query
statement
isReadOnly(): Tests if the view object is read-only
setOrderByClause(java.lang.String expr): Sets the ORDER BY clause of the view
object’s query statement
setWhereClause(java.lang.String cond): Sets the WHERE clause of the view
object’s query statement
3. Dynamic VO:
84/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
public void changeDynamicVoQuery(String sqlStatement) {
ViewObject dynamicVO = this.findViewObject("DynamicVO1");
dynamicVO.remove();
dynamicVO = this.createViewObjectFromQueryStmt("DynamicVO1",
sqlStatement);
dynamicVO.executeQuery();
}
86/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
The following sequence diagram illustrates the sequence of actions and collaboration between
various framework components when an application module is checked out from the pool to serve
a new client when a client tries to grab an application module instance:
87/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
88/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
NodeList nl = parent.getElementsByTagName("USERDATA");
for (int i = 0; i < nl.getLength(); i++) {
Element e = (Element)nl.item(i);
String key = e.getAttribute("KEY");
String value = e.getAttribute("VALUE");
setRegionId(new Integer(value));
break;
}
}
super.activateState(parent);
}
89/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
90/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
91/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
92/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
93/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
94/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
<adf-faces-config xmlns=
"http://xmlns.oracle.com/adf/view/faces/config">
<debug-output>true</debug-output>
<skin-family>oracle</skin-family>
</adf-faces-config>
Enable debug Improves the readability of HTML markup in the web browser:
output.
Line wraps and indents the output.
Detects and highlights unbalanced elements and other common HTML
errors, such as unbalanced elements.
Adds comments that help you to identify which ADF Faces component
generated each block of HTML in the browser page.
Unless content compression is disabled, CSS style names and styles will appear
compressed and may be more difficult to read.
Disable JavaScript compression by setting the following in the web.xml file:
<context-param>
<param-name>
Disable
org.apache.myfaces.trinidad.DEBUG_JAVA_SCRIPT
JavaScript </param-name>
compression. <param-value>true</param-value>
</context-param>
Allows normally obfuscated JavaScript to appear uncompressed as the source.
Enable client side asserts by setting the following in the web.xml file:
<context-param>
<param-name>
Enable client side oracle.adf.view.rich.ASSERT_ENABLED
asserts. </param-name>
<param-value>true</param-value>
</context-param>
Allows warnings of unexpected conditions to be output to the browser console.
Enable clientside Enable clientside logging by setting the following in the web.xml file:
logging.
95/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
Configuration
Description
Recommendation
<context-param>
<param-name>
oracle.adf.view.rich.ASSERT_ENABLED
</param-name>
<param-value>true</param-value>
</context-param>
Unless client side logging is enabled, log messages will not be reported in the
client.
Enable more detailed server side logging shut down the application server,
enter the following setting in the logging.xml file, and restart the server:
or
setLogLevel(logger="oracle.adf” level=”CONFIG”,
addLogger=1)
Enable more
detailed server or
side logging.
In Oracle Enterprise Manager Fusion Middleware Control, use the Configuration
page to set oracle.adf, oracle.adfinternal, and oracle.jbo to level CONFIG.
Unless server side logging is configured with a log level of CONFIG or higher,
useful diagnostic messages may go unreported.
Allowed log level settings are: SEVERE, WARNING, INFO, CONFIG, FINE,
FINER, FINEST, ALL. Oracle recommends CONFIG level or higher; the default is
SEVERE.
Disable HTTP cache headers by setting the following in the web.xml file:
<context-param>
Disable HTTP <param-name>
cache headers. org.apache.myfaces.trinidad.resource.DEBUG
</param-name>
<param-value>true</param-value>
</context-param>
96/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
Configuration
Description
Recommendation
Unless HTTP cache headers are disabled, the browser will cache resources to
ensure fast access to resources.
After changing the setting, clear the browser cache to force it to reload
resources.
97/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
98/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
27 Miscellaneous
1. Miscellaneo9us
Iterative development lets you make changes to your Framework application while it is running
on the Integrated WebLogic Server and immediately see the effect of those
changes simply by refreshing the current page in your browser.
99/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
28 Advance ADF
1. Managed bean interface and event handler method:
100/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
101/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
102/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
103/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
104/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
105/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
106/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
107/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
35 Tools
1. Junit
JUnit is an open-source framework to write and run test cases for java programs. In the case of
web applications, JUnit is used to test the application without a server. This framework builds a
relationship between the development and testing process.
Advantages of JUnit
JUnit addresses the above issues; It’s used to test an existing class. Suppose, if we have a
Calculation class then, we need to write CalculationTest to test the Calculation class.
Using JUnit we can save testing time.
In real-time, in the web application development, we implement JUnit test cases in the DAO
classes. DAO classes can be tested without a server.
With JUnit, we can also test Struts / Spring applications but most of the time we test only
DAO classes. Even some times service classes also tested using JUnit.
Using JUnit, if we want to test the application (for web applications) then a server is not
required so the testing becomes fast.
2. ANT
Ant is an abbreviation for Another Neat Tool. Ant is a Java-based build tool created as part of the
Apache open-source project. You can think of it as a Java version of make. Ant scripts have a
structure and are written in XML. Similar to make, Ant targets can depend on other targets.
108/109
ADF Essentials Training by Deepak Bhagat
Oracle Application Development Framework (ADF) Assorted Notes
Ant uses an XML file for its configuration. The default file name is build.xml. Ant builds are based
on three blocks: tasks, targets and extension points.
A task is a unit of work that should be performed and is small, atomic steps, for example, compile
source code or create Javadoc. Tasks can be grouped into targets.
A target can be directly invoked via Ant. Targets can specify their dependencies. Ant will
automatically execute all dependent targets.
For example, if target A depends on B and Ant is instructed to run A, it first runs B before running
A. In your build.xml file you can specify the default target. Ant executes this target if no explicit
target is specified.
109/109
ADF Essentials Training by Deepak Bhagat