ADF Solution – Logout on Closing Browser

In this blog we will implement solution for problem of Handling Browser Close Event. Browser doesn’t send any event to the server to handle such events. The requirement is to logout and invalidate the user’s session when closing browser without logging out. This process is a part of application security, and it is important for performance improvement. The trick is to use ADF Bounded Task flow’s feature Run as Dialog. I will explain this technique.

I have developed sample application LogoutOnClosingBrowser.zip

in ADF (12.2.1.2.0).

We will go through this scenario:

When user starts application in the browser session created automatically.

User Login with Username & Password:

1

1) The Login button called bounded Task flow as Dialog in external-window.

Remember to change property useWindow=”true” in the Login button, which call task flow as dialog.

2

When user try to Logout from logout button, task flow execute After Listener to Invalidate Session and the logout action is working fine.

3

2) Configuring Finalizer to bounded task flow to handle Closing Browser Event.

4

We need to differentiate between two cases: Logout normally done from Logout button and Browser Closed.

Add <af:setPropertyListener> under the logout button, to send logoutFlag_P parameter equal true to Finalizer, if Logout action done from Logout button.

3(2)

 

3) Creating Security Bean and methods like this:

Logout Method: To handle Logout action.

5

Finalizer Method: To manage finalizing of the task flow.

6

Invalidate Session Method: To kill session after logging out.

7

To logout would be simply to close browser, and the user’s session will invalidate.

8

9

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

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