Tuesday, August 5, 2014

Standard ADF BC Passivation/Activation for Transient View Object

If you want to implement transient View Object in ADF BC, you must make sure it will be passivation/activation ready, otherwise you may loose data. There are several ways how to achieve passivation/activation for such View Objects - override passivation/activation lifecycle and handle transient View Object rows programmatically or reinitialise transient View Object rows from Application Module prepareSession method. There is one more solution, I'm going to describe it in this post. It is based on dummy SQL based View Object, designed to to store transient attribute values.

Sample application - ADFTransientVOPassivationApp.zip, implements SQL based View Object with transient attributes. Instead of creating completely programmatic View Object, I have created SQL based with single Id attribute based on SQL expression and added transient attributes. This Id attribute is actually never used, it is there just for only reason - to simulate SQL based View Object. As a key attribute is selected one of the transient attributes:

SQL query doesn't fetch any rows, I'm using it only for a single reason - to simulate SQL based View Object. ADF BC knows how to passivate/activate SQL based View Objects automatically, so I'm going to use this feature and force passivation/activation for all transient attributes created for the same View Object:

Just make sure to select Passivate Including All Transient Values option, this will ensure all transient attributes will be passivates/activated automatically, without any coding intervention:

I'm going to test sample application with AM pooling off, this would simulate passivation/activation behaviour for each request:

On ADF UI side, I'm going to implement a table. To be able to enter rows successfully, for such SQL based View Object with transient attributes, I must enable ChangeEventPolicy = ppr option in Page Definition for the iterator:

Input components must be set with AutoSubmit = true option:

On runtime, when I enter rows, all data gets passivated - you can see this from the log. Three rows are entered, data for all attributes gets passivated/activated automatically:


AM said...

Hello Andrejus, could you please explain why we need the changeEventPolicy and autoSubmit settings for this test. The createInsert will submit a request to trigger activation/passivation. And since there is no business logic based on any attribute value change, even if ppr doesn't happen, the fields continue to show the correct value. Many Thanks in advance! AM

Andrej Baranovskij said...

This sample is set with AutoPPR and ChangeEventPolicy to make sure values will be registered for passivation, when navigating between records in the table.


DJ said...

Thanks Andrejus for useful information. This seems like a critical point to look into while doing ADF development. I have a question tied to this.

I am planning to build an application having Navigation Tree retrieved from Oracle Database using PLSQL database table. I am planning to store the array in one of the VO to use it show Navigation panel. Please let me know if this will be right approach to proceed considering this passivation and activation of application?


Andrej Baranovskij said...

Hi Deepak,

Yes, this sounds right. Passivation/activation is not really important for read-only data. If passivation/activation will ever happen - VO simply will re-fetch data automatically.


DJ said...

Thanks for the input. This helps in many ways. I think I missed point here, I was thinking of calling the PLSQL package at the time of login to do Database authentication and also getting the PLSQL Array of navigation in one call. This array will be kept for whole session. Parking this navigation data to a VO for entire session. I am assuming this will not be a problem in this case.

Here Roles and duties of the user are stored in different database and are being pulled from there once at the beginning of login.

Andrej Baranovskij said...

You should keep array in session scope. Passivation/activation affects only data from ADF BC. So, it seems like you should not have any problem.


DJ said...

This clarifies fully. Thanks a lot for your valuable inputs.

DJ said...

Hi Andrejus,

We tried this navigation and created a Programmatic VO to hold the navigation data fetch using domain object of ADF and PLSQL function. I am able to see the list view navigation panel first time but as soon as I refresh the pages using browser refresh, listview navigation gets hidden and there is no navigation panel.

Just to add, I have made the VO passivated and all the attributes(transient) are passivated to hold the data. I am not sure what is the miss I am doing here. Please let me know your thoughts.

Habib said...

Hi Andrejus, Thnaks for your useful posts.
I require to insert rows into static VO with transient attributes before page displays to user.
So I downloaded the sample application - ADFTransientVOPassivationApp.zip and then inserted rows into VO by am method in AM, and then run this method as a default activity of task flow. In this case only the last inserted row remains in VO and others row removed.
Also I've created a discussion for this issue here : https://community.oracle.com/thread/4138220