Oracle ADF Features

Oracle Application Development Framework (Oracle ADF) is an advanced Rapid Application Development(RAD) Framework for J2EE applications mainly targeted for B2B Applications.

It is a proprietary software maintained by Oracle in 3 flavors:

Features-

  • RAD Framework with most commonly used components of any Front End Application available as inbuilt feature
  • Model-View-Controller (MVC) design pattern and offers an integrated solution that covers all the layers of this architecture with solution to such areas as:
    • ORM and Data Persistence
    • Reusable Task-flow approach,
    • Rich Web user interface elements,
    • Data binding to UI,
    • Security
    • Customization via sandboxes etc
  • Separation of Business Logic implementation details, via metadata and use of this metadata-driven architecture enables developers to focus on the business logic and user experience.
  • Drag-n-Drop features, via JDeveloper IDE, provides the ease to use and customize.
  • ADF Skin Editor: New ADF Skin editor for visually creating and modifying the appearance of ADF Faces applications.(JDeveloper 11G and above)
  • JSF 2.0: JSF 2.0 support in the IDE and for ADF applications. (JDev 11g R2 release)
  • ADF Faces and Data Visualization Tools (DVT) support touch gestures for interactivity on the touch-enabled devices, such as touch support for drag and drop, tooltips, data tips, and context menus.
  • ADF Faces and DVT components are certified on iPad. Additionally, ADF DVT Graph and Gauge components support rendering in HTML5.
  • MDS is metadata service that is used to store metadata information. When you use ADF, it generates lot of internal files about its own components and DB binding details. All these are stored internally by ADF into MDS.
  • ADS (Active Data service)- This is used in ADF to push any data changes automatically from the back end into the portal layer. This is different from Ajax which is used to send request from UI to data service layer.

How to create a Custom ADF Component

In this tutorial, we will create a custom ADF Component.

Create new files and package structure as shown:

Structure
Create a Custom ADF Component

Source Code of the required files is as below:

Final Output:

final
Create a Custom ADF Component

Retrieve GET parameters from URL in Managed Bean in Oracle ADF

For obtaining parameter from URL in java code in Oracle ADF use the below code
URL:
http://127.0.0.1:7101/Application-ViewController-context-root/faces/page.jspx?paramName=Testing123
Use the code:
String test = FacesContext.
getCurrentInstance().getExternalContext().getRequestParameterMap().get("paramName");

How to add DVT Graph Programmatically

This tutorial is to show how to inject a DVT graph programmatically in Oracle ADF

Step 1: Define a List Data Model:

Java Code for Data

        List<Object[]> listObject = null;
        if (listObject == null) {
            listObject = new ArrayList<Object[]>();
            Object[] obj1 = { "Example_Bar_1", "Series_1", 10 };
            Object[] obj2 = { "Example_Bar_1", "Series_2", 15 };
            Object[] obj3 = { "Example_Bar_1", "Series_3", 75 };
            listObject.add(obj1);
            listObject.add(obj2);
            listObject.add(obj3);
        }

JSFF Code where the code will be injected:

<?xml version='1.0' encoding='windows-1252'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
 xmlns:dvt="http://xmlns.oracle.com/dss/adf/faces">
 <jsp:directive.page contentType="text/html;charset=windows-1252"/>
 <f:view>
 <af:document title="demo" id="d1">
 <af:form id="f1">
 <af:panelGroupLayout id="pgl1" styleClass="container" binding="#{backingBeanScope.graphBean.container}"/>
 </af:form>
 </af:document>
 </f:view>
</jsp:root>

Java Code to inject Graph @ Runtime:

[Note]:container is the binding to the af:panelGroupLayout under which you wish to inject the graph
        List<Object[]> listObject = null;
        if (listObject == null) {
            listObject = new ArrayList<Object[]>();
            Object[] obj1 = { "Example_Bar_1", "Series_1", 10 };
            Object[] obj2 = { "Example_Bar_1", "Series_2", 15 };
            Object[] obj3 = { "Example_Bar_1", "Series_3", 75 };
            listObject.add(obj1);
            listObject.add(obj2);
            listObject.add(obj3);
        }
        UIGraph graph = new UIGraph();
        graph.setGraphType(UIGraph.PIE);
        graph.setTabularData(listObject);
        container.getChildren().add(graph);

Result:

2015-08-14_1742

 

How to add ValueChangeListener Programmatically

Using an EL String, we can add ValueChangeListener in Oracle ADF using the below code:

private static MethodBinding getValueChangeListener(String el) {
        Class[] parms = new Class[] { ValueChangeEvent.class };
        MethodBinding mb =
            FacesContext.getCurrentInstance().getApplication().createMethodBinding(el,
                                                                                   parms);
        return mb;
    }

pass the EL Expression to the util method

ui.setValueChangeListener(getValueChangeListener("#{pageFlowScope.demoBean.valueChangeListener}")); 

 

How to Add an ActionListener programmatically

Using an EL String, we can add ActionListener in Oracle ADF using the below code:

private ActionListener getActionListener(String el) {
        //here Testbean is the name of ManagedBean
        MethodExpression methodExp = getMethodExpressionForAction(el);
        return new MethodExpressionActionListener(methodExp);
    }
private MethodExpression getMethodExpressionForAction(String actionName) {
        Class[] argtypes = new Class[1];
        argtypes[0] = ActionEvent.class;

        FacesContext facesCtx = FacesContext.getCurrentInstance();
        Application app = facesCtx.getApplication();
        ExpressionFactory elFactory = app.getExpressionFactory();
        ELContext elContext = facesCtx.getELContext();
        return elFactory.createMethodExpression(elContext, actionName, null, argtypes);
    }

pass the EL Expression to the util method

ui.addActionListener(getActionListener("#{pageFlowScope.demoBean.actionListener}")); 

 

See exact query execution in Oracle ADF

Challenge

You want to be able to see all the sql-statements and DML-statements that your ADF application is executing.

Solution

  1. Just add the following java option to the run configuration : -Djbo.debugoutput=console
    While this will give you everything you need, you get a lot of clutter and it is difficult to see the information you are looking for.
  2. ADF Logger: While you just run your application, no special run configuration or debug setting is needed, you can change the log level of the different ADF components.  The change is immediate active, no rerun or stopping of the jvm is needed.
    In case you want to see the SQL and DML statements you need to set the oracle.jbo.common.ADFLoggerDiagnosticImpl to FINEST, anything lower will not show the statements.

How to set this logger level?

Follow this procedure to use the logger level:

  1. Just run or debug your application.
  2. In the Log-pane you should see your application starting up.
  3. In this pane, there is an Action-menu.  Choose here the “Oracle Diagnostic Logging”-option.
  4. This will open a new tab, called “logging.xml”.
  5. Now walk through the tree until you find the

    oralce.jbo.common.ADFLoggerDiagnosticImpl

  6. And then select in the Level column “Finest” or type “TRACE:32”.
  7. This change is active immediately. You should see appearing the SQL-statements in the Log pane when you are walking through your application.

ADFLogger_1

ADFLogger_2

ADFLogger_3

Ref:blog