ADF – Groovy for Total Sum of a Column in a Table

ADF – Groovy for Total Sum of a Column in a Table

We will be looking in this article as how we can add Total of a column in a table. Very often we require to have total of a column in a table. For example , we might need total sum of Salary column in the table.
We will be leveraging power of Groovy in accomplishing this task.
So lets see how we can do this.
Use Case :- Add a Total Salary Attribute below Salary column in Employees Table.
Model Project
Considering that we have EmployeesView VO object which is based on Employees EO, go to attributes of VO and click add new attribute. Select “Add new Attribute”. It will by default be transient. Give this attribute  name as TotalSal.
Now go to View Accessors tab and click on green + sign to create new View Accessor.
Select EmployeesView from the first window and shuttle it so that you can see like below.
Do ok and it should be like below screenshot.
Now go to attributes tab and select the new transient attribute (TotalSal).
Give its Default value as Expression and give Groovy expression as EmployeesView1.sum(“Salary”) .
View Project
Create a new page. Drag and Drop EmployeesVO from data control and create a new read only table “without” TotalSal Attribute.
Now go to Salary Column in Structure and do a right click and select footer from facet as shown below.
Now from EmployeesView1 in DataControl, drag and drop TotalSal column in this new footer facet.
Now go to bindings and create a new binding for this variable.
 And change the value of footer output text with this binding.
Save all and run this page.
Hope this was useful.
Happy Learning !!
Rohan Walia

Oracle ADF Mobile goes production

ADF developers you are now mobile developers! Start building iOS and Android applications that leverage HTML5 and Java – with JDeveloper and Oracle ADF

Today, Oracle released the ‘Oracle Application Development Framework (ADF) Mobile’, the long awaited for mobile development framework. You can load it as zip file for installation from a file from Oracle ADF Mobile web page. Go to the download tab and make sure you select the ‘Oracle ADF Mobile’ from the list.

On the Oracle http://www.oracle.com/technetwork/developer-tools/adf/overview/adf-mobile-096323.html web page you find additional material, including a demo of an application build using ADF Mobile.
The extension allows to create application for iOs and Android!

Some key Features –

 Develop once, and deploy to Apple iOS and Google Android devices, from the same code base.
 Reuse your development skills and tools – development is done mostly in Java and web-based technologies such as CSS, using visual editors and wizards in Oracle JDeveloper.
 Deliver a flexible runtime architecture –application can be constructed using a combination of the declarative ADF
AMX UI components, local HTML5 developed using third
party frameworks, and remote HTML pages.
 Support mobile-optimized user experiences, for both tablets and smart phones.
 Integrate with device native services – such as on-device camera, location-based service, contact applications, etc, to
support application functionality.
 Work offline – the entire application can run on-device against a local database.
 Secure – integrate with enterprise security infrastructure, and provide authentication and access control services. All
data/credential stores and communication channels are encrypted.

Key Components of Oracle ADF Mobile
Oracle ADF Mobile-based application is consisted of the follow key components:
 Thin native framework for each supported platform
 PhoneGap libraries in the container to support device services integration
 HTML5 based UI components that deliver a device-native user experience
 A light weight Java VM is embedded to support the application logic written in Java
 An encrypted SQLite database engine
 Encrypted credential store and authentication/authorization services.

I will try to explore more and come back again…….

Adding number for Primary key in oracle ADF using groovy by sequence

Requriement – To create a primary key using sequence in Oracle ADF while create operation.

We have the primary key for any table.

We open the EO of that table. Go to attribute tab. select Primary key ID and go to property.

Select the default value to be “Expression” . and put value as

(new oracle.jbo.server.SequenceImpl(“SEQUENCE_NUMBER”,adf.object.getDBTransaction())).getSequenceNumber()

see the below screen shot

That it.. When you use create operation.Primary key will be generated automatically.

Happy Coding….