ADF 12c Workshop – HR Example

This blog is an Oracle ADF 12c Workshop, based on HR task, contain Technical information, tips and tricks of ADF development. I’d like to share this workshop with you.

Workshop Overview

  • ADF Business Components generation
  • Add Calculated attributes to View object
  • Adding LOVs
  • Create New record before page load
  • Creating ADF Page Layout
  • Using Managed Beans
  • Add new record using ADF Bounded Taskflow
  • Search Functionality.
  • Sorting Data Dynamically (Run time)
  • Add Images to Application
  • Validation

I have developed this completed application HR_Example.zip.

in ADF (12.2.1.2.0).

The Page Example:

HR_Example

This view after page completed.

1

Search with LOVs

2

Snapshot of codes

4

I hope that this blog could help developers to build a better application based on ADF. If you have any questions i will be happy to answer you.

Creating Complex Task Flow in ADF – Part 2

In previous blog Creating Complex Task Flow in ADF – Part 1 we talked about creating bounded task flow and using ADF Train component. In this blog we will use other advanced features of ADF task flow. Such as Save Points (Explicit). It is very useful in case we need to split or delay transaction.

The Save Point capture the state of an ADF Fusion web application at a specific instance. This allows you to save application state and can be restored later.

An Explicit save point requires an end user action to enable task flow creates a save point, such as a click button. and it is available for both bounded and unbounded task flows.

I have developed sample application ComplexTaskFlow2.zip.

in ADF (12.2.1.2.0).

For implementing Save Point:

1) Preparing Task Flow to use Save Point: After creating the task flow in previous blog, Add a Method call activity to a bounded task flow to create a save point, and add Save Point Restore activity to restore application state and data associated with the created save points.

Add a task flow parameter to pass save point information for createSavePoint method.

a

2) Configuring application to use Save Point: In the Application Resources panel, Expand the Descriptors and ADF META-INF node, and open adf-config.xml.

In the overview editor, click the Controller navigation tab and then expand the Savepoints section and select the data source of data base connection:

b

A database table named ORADFCSAVPT is used to store save points information. If this database table does not exist, it is created automatically by ADF application.

3) Creating of Save Point: Use createSavePoint method to create save point and set the time to live in seconds to one month. The default value is 86400 seconds.

2

4) Restoring of Save Point: User should select the save point from a list populated programmatically then restore it by savePointRestore activity:

3.jpg

5) Removing Save Point: After the task flow’s state has been restored, Task flow invoke Save Point Restore Finalizer to execute removeSavePoint method and remove save point.

At Run time, User start registration task:

4

User click Save Later button to create save point:

14

User select save point from a list and click Restore button:

5

Task flow’s state of selected save point is restored:

666

User click Finish to save Employee registration and go back to main page.

7

Creating Complex Task Flow in ADF – Part 1

In this blog we will use advanced features of ADF task flow. Such as Train flows, Regions, Task Flow Parameters, Managing Transaction and Reentry.

The Train component represents a series of stops. Each train stop represents a page fragment in a flow. Which helps the user to walk through these stops one at a time and take a sequential path to complete.

I have developed this sample application –ComplexTaskFlow1.zip.

in ADF (12.2.1.2.0).

We need to create Bounded task flow Register_task-flow-definition.xml, where the end user can enter and review information to complete the Registration task.

a

The train stops are:

  • Personal
  • Job
  • Review

After creating the task flow, add activities to it, and configure control flow between the activities. and add Return activities to call Commit or Rollback transaction and go to the calling page.bTo display name in a train stop: In the task flow’s structure window, Insert Inside train-stop > Display Name and enter  the value in the property inspector.

There is a little trick when you are creating a Train flow based on same entity you need to skip validations on the page definition: SkipValidation=”true”.

1

At Run time, User click the Register button to start registration of new Employee.

The current train stop is the first train stop:

2

User navigate to the second train stop:

3

User navigate to the third train stop:

4

User click Finish to save new employee and go back to main page.

5

Filtering Modified Rows in ADF View Object

Some times we need to identify modified or new rows programmatically and determine row status, to be more clear for users.

2

I have developed this sample application –FilterModifiedRows.zip.

in ADF (12.2.1.2.0).

Initially we need to customize default selection in table to get selected row key and add it in java Map if it is not already existed.

Note that keys stored in Map with null values:

3

And also customize default creation action to create new row and get selected row key and add it in SelectedRows Map if it is not already existed:

4

Then, We need to check status for each row in view object to identify whether status is New or Modified. by invoking checkRows method which iterate over selectedRows Map elements and update elements values and increment counters:

5

We have to customize Commit, Rollback actions to commit or rollback changes and reset selectedRows Map and counters:

6

7

Remember to remove SelectedRowKeys property from table.

Finally we can write following expression in inline style of column of table, so that it can check all rows in table and differentiate between different status:

8

You can see  rows are highlighted by orange color after modifying, and highlighted by blue color after create new row. This informs user that he did changes in the table.

1

Update Data in Auto Commit ADF Table

Some times we need to save changes automatically, to avoid any corruption or connection down, so we need to implement auto saving.

I have developed sample application –AutoCommitTable.zip.

in ADF (12.2.1.2.0).

1

We need to check status of transaction, initially the transaction is not dirty (data is not changed). then if user changes any data the status is modified to “Modified”.

States are set to one of these values:

STATUS_INITIALIZED, STATUS_NEW, STATUS_MODIFIED, STATUS_DELETED and STATUS_DEAD.

In this example, user changes phone number to 123451, then just navigates to another row without saving, and changes will be saved automatically.

2
I will describe how it is implemented, You need to customize default behavior of Selection Listener for the table, You can determine unsaved changes with check if the data control transaction is Dirty, then invoke Commit operation:

4

And the util methods to evaluate and invoke default selection listener, to make selected row as current row:

5

6

we can check database to confirm changes are saved.

3