Tuesday, September 24, 2013

Enabling UI Shell 12c/11g Multitasking Behavior

The main goal of this post is to describe how to enable multitasking functionality in out of the box UI Shell template for ADF applications. Different UI Shell tabs could run different transactions and allow user to commit/rollback data in the scope of individual tab. Every UI Shell tab runs different ADF task flow loaded from the menu.

Here is sample application, enabled with multitasking UI Shell - TFActivationApp.zip. This application is built with single AM module, serving three VO's - Departments, Employees and Jobs. There will be separate ADF task flows, for each of these data objects, loaded in UI Shell tabs. AM module:


There is single data control defined:


Perhaps you would wonder - how this could work in multitasking environment and run multiple transactions, as there is single AM. This would work with ADF isolated task flows, as for each ADF isolated task flow, there is new AM instance created on runtime automatically. As there will be three ADF isolated task flows, one per VO - there will be three (at least three) AM instances created on runtime. One AM instance per ADF isolated task flow:


This is a key part to enable multitasking in UI Shell - make sure to use ADF isolated task flow loaded from the menu.

Firstly, let's run ADF task flows in UI Shell with default - shared mode. Two tabs are opened, modify Department Name in the first task flow:


Go to the second tab and modify First Name:


Press Save in the same tab - Employees. Check the log and you will see that data from both tabs (ADF shared task flows) was commited:


This is not what we want, ideally only data from current tab should be commited. To achieve that, go and set Isolated mode for the ADF task flows (if using ADF task flow template, this can be done centrally):


With isolated mode enabled, when you open new UI Shell tab and load ADF task flow:


New AM instance is created automatically, meaning new transaction is assigned for the ADF task flow loaded in UI Shell tab. We can observe new AM instance creation from the log:


With isolated mode turned on, changes made in UI Shell tabs are commited only for currently active tab:


Even if there are changes made in multiple tabs, changes only from currently active tab are commited. We can observe this from the log - commit is executed for currently active tab AM instance only:


To prove this, we can open second UI Shell tab, where changes were made previously - press Cancel and changes will be reverted:


Multitasking is working, but we need to test another aspect - validation handling. Ideally user should be able to navigate between UI Shell tabs, without being blocked by validation errors. When commiting data in active tab, there should be no validation errors displayed from other UI Shell tab.

Go to the first UI Shell tab - Departments and press Create button to insert new record:


Without typing any data, try to go to the second UI Shell tab - there will be validation errors reported and user will be blocked in the current tab:


In order to resolve this and allow navigation to the different tab, we need to set Immediate = true property for the tab item. This is UI Shell, you could get source code and modify it. This would require change UI Shell library in your project. There is another way - use MDS Seeded Customization to modify out of the box UI Shell, this is what I'm using in this sample application.

Enable MDS Seeded Customization for the project in ADF View section:


Don't forget to define SiteCC class in adf-config.xml, this class handles site level customizations global for all users:


To perform actual MDS Seeded Customization, switch JDeveloper to the Customization mode:


Once JDeveloper restarts in Customization mode, select Show Libraries option for your application, this will list all the libraries attached:


You can go and browse through the library contents, in this example - Oracle Extended Page Templates (it contains UI Shell). Open template page - dynamicTabShell and set Immediate = true for the tab item, this would allow to switch between tabs ignoring validation errors in the current UI Shell tab:


JDeveloper generates new file - MDS Seeded Customization file, this is where customization is stored and applied later on runtime:


Let's repeat the same test - insert new record in Departments tab:


We can navigate to the different UI Shell tab, but there are validation errors rendered from the first tab, when trying to submit data in the current tab - not good:


This can be fixed with a hint from my previous blog post - Skip Validation for ADF Required Tabs. You should set SkipValidation = true in the main page definition, the one which implemented UI Shell page:


It works now - data from second tab can be saved successfully, independently from validation state in the first tab:


Go to the first tab, you can see there are validation messages available. These messages are displayed in the scope of currently opened tab only:


One more good thing, I want to share with you - closing ADF task flows in UI Shell. When tab is closed in UI Shell, ADF task flow is destroyed automatically and finalizer is invoked, where you could release custom resources used by the ADF task flow. Closing tab in UI Shell:


Finalizer is invoked - we can see this from the log:


Finalizer must be defined in the ADF task flow properties:


Finalizer bean is defined in the same ADF task flow, request scope:


14 comments:

Java Technical Stuff said...

Nice post but i have to do that but got null pointer exception while launching the taskflow.

Can u just tell me how u r launching the task flow from the link and what extra things i have 2 do for that.

Andrej Baranovskij said...

Are you using my sample application? It works well on my machine, you should run with JDEV 12c.

There is no any extra steps, just run sample app.

Andrejus

Java Technical Stuff said...

Hi,
I am using u r sample its working fine but i want to develop this referncing u r workspace so couldn't launch the task flow its showing UI Component is null

Andrej Baranovskij said...

Then you should check source code in the sample :)

Andrejus

Anonymous said...

Hi Andrejus,

Thanks for this post and for all others !

Is it possible to enable multitasking between two jsp pages who used the UI Shell template?

Sébastien

Anonymous said...

For each AM Instance creation, How many VO instances it created at runtime is it only one which it is accessing or all 3 ( emp vo, dep vo jobs vo )

does the log message shows this

Also is this behavior is only with UI Shell ? or it is same in normal pages without UI Shell

Andrej Baranovskij said...

There will be different VO instances per each AM.

This would work without UI Shell also, same concept.

Andrejus

Anonymous said...

Hi Andrej,

I am using Jdev 11.1.1.7 with Ui shell.
We are trying to implement the uncommitted data save popup , but seems it does not work with this version of jdev. I am not able to see the popup.
I turned on the uncommitedDataWarningFlag on , In my modules i have set the BTF to critical, but i cant see the popup.
I tried to write a function in my managed bean to detect the transaction isdirty and open a popup , (this works) but i fail to get this on close icon click as its not available to me.
Do I need to override the ui shell code to meet those changes or is there a work around ?

Unknown said...

I'm unable to open either of the three menu items(employees , departments and jobs). When i click on any one of them , I get the below error
*****
ADF_FACES-60097: For more information, Please see the server's error log for an entry beginning with: ADF_FACES-60096: Server Exception during PPR, #5
*****
I have downloaded the zip but I have a doubt. Where will this application get a database from?

Andrej Baranovskij said...

You need to configure ADF BC connection to use your local HR schema.

Andrejus

Anonymous said...

Hi Andrejus,

We are following a very similar use case. However we are experiencing an issue where UI components in one TF instance are being affected by the other TF instance. We have checked the "Share data controls with calling task flow to isolated, and our managed beans are in pageFlowScope. any suggestions?

Thanks,

Alex

Unknown said...

Set the managed bean scope to backing scope.

kalis said...

Hi Andrejus,
Very good post,
I am not able to download the sample app TFActivationApp.zip,
the link has been changed?
Thanks,
With regards,
kali.
OSSi.

Andrej Baranovskij said...

Please refer to my post how to download old samples: https://andrejusb.blogspot.hk/2017/08/my-blog-samples-download-repository-for.html

Andrejus