Invoke a method from Managed Bean when JSPX Page Loads in ADF.

Requirment -invoke a method from Managed Bean when JSPX Page Loads in ADF.

Suppose you have some method in managed bean, which you want to call on page load.For that
Your managed bean should implement implements PagePhaseListener i.e

public class vinayManagedBean implements PagePhaseListener{ }

You should import “oracle.adf.controller.v2.lifecycle.PagePhaseListener;”
Now you will be calling method in beforePhase event of ADF page life cycle.In side the beforePhase ,pageLoad method will be called.You can write your custom method there.

public void beforePhase(PagePhaseEvent pagePhaseEvent) {
if (pagePhaseEvent.getPhaseId() == Lifecycle.PREPARE_MODEL_ID) {
onPageLoad();
}
}

public void afterPhase(PagePhaseEvent pagePhaseEvent) {
if (pagePhaseEvent.getPhaseId() == Lifecycle.PREPARE_RENDER_ID) {
// onPagePreRender();
}
}

public void onPageLoad() {
if (!AdfFacesContext.getCurrentInstance().isPostback()) {
// add your onPageLoad event here

// to set the View Criteria on the Iterator
doSomeOperation();  ///your custom method.
}
}

After all then right click on .jspx page and go to page definitions file .In your JSPX page definition make sure you add the ControllerClass that points to the managed bean that handles the onPageLoad event.

<pageDefinition xmlns="http://xmlns.oracle.com/adfm/uimodel" version="11.1.2.60.17" id="InspectionTaskHomePageDef"
                Package="oper.view.pageDefs" ControllerClass="vinayManagedBean">
  <parameters/>

By doint this whenever you page loads, the onPageLoad() method gets invoked which inturn invokes the v() method. You can even call multiple methods in onPageLoad() method.

Note:- It will not work in jsff.

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….