How to Refine Template Pages along with Globalization of Navigational Menus

Introduction
Believe me, folks if I could have given a chance to get into the financial domain, I would love to join. This example uses terms related to the financial domain and implements one of the great OOPS concepts that is inheritance. We all love to play with objects extending them, inheriting them, calling them, I like the inheritance feature of ADF Business Controller. It allows creating an inheritance tree of entity objects and viewing objects. Using this approach we can build our very own business model.

This example implements how to actually use inheritance in view controller layers.
Use Case
I have in my database three tables:

Deal – contains some common fields of some agreement with some customer

Loan – contains some extra fields specific for loan agreements

Forex – contains some extra fields specific for forex agreements

Model
In my model I’ve created three read-only VO’s:

VDeal – selects all fields from Deal table

VLoan – extends VDeal. Selects all fields from Deal and Loan tables

VForex – extends VDeal. Selects all fields from Deal and Forex tables

View Controller
Let’s create the Task Flow template to work with our model. In real life the task flow is going to contain a number of different activities, but, just to simplify this post, my task flow consists of one view activity only. Form View activity contains some form to show record from VLoan or VForex.

 

There you go, Task Flow template is created in the draft.
Task flows that implement this template are going to attach some real page fragment to the Form View activity in order to show a record of the corresponding deal (Loan or Forex). Obviously, some of the fields are common and it’s preferable to have the same look-and-feel and UI logic for these fields in every implementation. I’m going to create a page fragment template and put all common fields on it.

From the Data Controls palette I’m dragging VDeal and dropping it on the page as ADF Read-only Form:

After adding facet “extend Facet” for pages implementing this template and fixing some “design” issues I got the following page:

everything seems to be OK. But!!! Let’s have a look at the page definition file for our template page. The iterator’ binding points to VDeal view object:

<executables>
<variableiterator id=”variables”>
<iterator binds=”VDeal” datacontrol=”AppModuleDataControl” id=”VDealIterator” rangesize=”25″>
</iterator>
</variableiterator>
</executables>

Actually VDeal is just ancestor definition. Its instance will hardly be created. Pages implementing our template will have their own real VO instances of VLoan and VForex. To fix the problem I’m going to add some managed bean to my task flow template:

<adfc-config version=”1.2″ xmlns=”http://xmlns.oracle.com/adf/controller”>
<task-flow-template id=”deal-flow-template”>
<default-activity id=”__1″>FormView</default-activity>
<managed-bean id=”__5″>
<managed-bean-name id=”__4″>DealFlowBean</managed-bean-name>
<managed-bean-class id=”__3″>com.cs.vaibhav.inherit.view.DealFlow</managed-bean-class>
<managed-bean-scope id=”__2″>request</managed-bean-scope>
</managed-bean>
<view id=”FormView”></view>
<use-page-fragments>
</use-page-fragments>
</task-flow-template>
</adfc-config>
The next step is to change a little bit page definition file for page template:
<executables>
<variableiterator id=”variables”>
<iterator binds=”#{DealFlowBean.dealVOName}” datacontrol=”AppModuleDataControl” id=”VDealIterator” rangesize=”25″>
</iterator>
</variableiterator></executables>

I used EL expression to resolve VO’s name.

Ok. Let’s create taskflow to work with loans:

 

We have to add manually on the Loan task flow view activity and give it the same name Form View. We are implementing it by creating new page fragment based on the DealViewTemplate.

 

We put loan-specific extra fields (using drag-n-drop from the Data Controls palette) on the extend Facet of our page:

After that, we have to change PageDef for the new page fragment: change Binds=”VLoan” to Binds=”#{DealFlowBean.dealVOName}” and change given by default iterator ID from VLoan Iterator to VDeal Iterator.

<pagedefinition id=”LoanFormViewPageDef” package=”com.cs.vaibhav.inherit.view.pageDefs” version=”11.1.1.55.36″ xmlns=”http://xmlns.oracle.com/adfm/uimodel”>
<parameters>
<executables>
<variableiterator id=”variables”>
<page id=”pageTemplateBinding” path=”com.cs.blog.inherit.view.pageDefs.DealViewTemplatePageDef” refresh=”ifNeeded”>
<iterator binds=”#{DealFlowBean.dealVOName}” datacontrol=”AppModuleDataControl” id=”VDealIterator” rangesize=”25″>
</iterator>
<bindings>
<attributevalues id=”Principalamount” iterbinding=”VDealIterator”>
<attrnames>
<item value=”Principalamount”>
</item>
</attrnames>
<attributevalues id=”Currency” iterbinding=”VDealIterator”>
<attrnames>
<item value=”Currency”>
</item>
</attrnames>
<attributevalues id=”Interestrate” iterbinding=”VDealIterator”>
<attrnames>
<item value=”Interestrate”>
</item>
</attrnames>
</attributevalues>
</attributevalues>
</attributevalues></bindings></page></variableiterator></executables></parameters></pagedefinition>

Off-course we have to extend DealFlowBean and override the getDealVOName method.
And we need to define Loan Flow class for DealFlowBean in the definition of our task flow.

Finishing… Task flow for loans is complete and ready to be used. Using the same approach we create task flow for forex deals.
As a reward for our work we can enjoy the following working (!) pages for loan and forex deals:

 

You can download a sample application for this post here.

InheritanceExample — Email to get the file

 

Leave a Comment