Friday, November 9, 2012

ADF BC View Accessor To Centralize Business Logic Processing

I was implementing today one use case, where it was required to compare current row status with the data returned by another query (no master-detail relationship). Such use case can implemented in many ways in ADF - custom method on AM with combination of expression on ADF UI, etc. I decided to go different path and centralize processing logic into VO itself by using View Accessor (same as LOV's are defined in ADF). This allows to simplify implementation part on ADF UI - only simple access to VO attribute will be required, without calling any custom methods from ADF BC (all the job will be done already on VO level).

Here you can download sample application - This app logic allows to render in green these location lines, where at least one department exists:

There are 2 VO's, no View Link between them:

DepartmentsView VO is designed to check if at least one department exists for the current location. There is bind variable defined:

Here is important point now - Locations VO defines View Accessor (simply add it through the wizard) for Departments VO:

This means we are going to have access to Departments VO result set from Locations VO. Moreover, we can define Bind Variable value declaratively:

To complete use case, there is transient attribute defined of boolean type:

Getter method for this attribute is overriden in VO Row Implementation class. Here we are accessing View Accessor and check if at least one row exists:

And to complete, on ADF UI we only need to set color condition for table columns:

If current location got at least one department - it will be highlighted in green:


Unknown said...

Hi Andrejus thanks for your very usefull posts.

I am new to ADF mobile. I am creationg the amx's and moving the components to the view below. When I run it from simulator I am getting unable to load data control. I have created a webservice based on plsql package and trying to use it in mobile adf. I am missing something.Please help me on this.

Andrej Baranovskij said...

Please check this post:


Anonymous said...

Hi Andrejus, Can you help me on this pls.

I have 2 view accessors and one view accessor's(first) bind variable is the out come of 2nd view accessor(second).Where can i handle this ?

I am thinking of writing the code of accessing the secondVA and getting the value and setting it to the firstVA at firstVA's getter method.Is this right approach ?