Friday, December 6, 2013

ADF client interfaces

Only the services available to the client are

1) Application Module through interface ApplicationModule
2) View Objects through the interface ViewObject
3) View Row object through the interface Row

Entity Objects are not exposed to the clients .

ADF - Basic data types

ADF business packages for datatypes are oracle.jbo.domain and oracle.ord.im .ADF data types are optimized for better performance.In two case we need to use java datatypes - java.lang.String and java.math.BigDecimal

Basic data types are as below :
oracle.jbo.domain.Number
oracle.jbo.domain.Date
oracle.jbo.domain.DBSequence
oracle.jbo.domain.RowID
oracle.jbo.domain.Timestamp - Time stamp object
oracle.jbo.domain.TimestampTZ - For timestamp based on timezone
oracle.jbo.domain.TimestampLTZ- Local timezone based
oracle.jbo.domain.BFileDomain - Binary file object
oracle.jbo.domain.BlobDomain - BLOB
oracle.jbo.domain.ClobDomain - CLOB

oracle.ord.im.OrdImageDomain
oracle.ord.im.OrdAudioDomain
oracle.ord.im.OrdVedioDomain
oracle.ord.im.OrdDocDomain

oracle.jbo.domain.Struct
oracle.jbo.domain.Array



Overview of ADF business component implementation



- Standard Java and XML based implementation
- Metadata driven robust code
- Source code support for debugging in ADF declarative debugger
- Application server and database independence
- Java Enterprise Edition design pattern support . Business component implements all standard design patterns
- Source code organization through packages : oracle.jbo package for interfaces and oracle.jbo.server package for implementation classes.

ADF Active Data Model Overview

 - ADF maintained active data model of row set
- Data model defines business objects specific to your application
-  Row set contains the data
- UI and data model are synchronized
- UI updates the rowset of Application Module's data model
- No CRUD operation directly. CRUD operations are done through view objects
- ADF decoratively binding UI components with data model
- Data appears in UI without re-querying the database. Changes in the database reflects in the UI.
- Active data model supports custom code through custom methods in Application Module



Wednesday, December 4, 2013

ADF Choosing SQL platform,Connection and Datatype Map

First time when you create the business component you will see the window below.
You can create or select connection through the above interface.SQL platform option support Oracle,DB2 or any other SQL92 complaint databases.

Datatype Map : The default option is Java Extended for oracle. Oracle Domains data type map is getting used for applications which do not use adf faces.Data types are created in oracle.jbo.domain packages.java.math.BigDecimal extends java.math.Number for numeric data in Java Extended For Oracle data type map and oracle.jbo.domain.Number in Oracle Domain map.All new fusion applications should use Java Extended for Oracle map and other other one is basically provided for backward compatibility.We cannot change the map once created.
SQL platform can be overridden through adf-config.xml file

   

ADF Buisiness components

In ADF using business components developers no need to write the infrastructure code
  a) Connection to database
  b) Retrieval of data from the database
  c) Locking mechanism of db records
  d) Transaction management

All above actions are handled by the ADF framework.Also ADF supports declarative development and reuse of the business logic through multiple sql based views.

Some of the high level features of business components are

- Simplify data access
- Enforcement of business domain validation  and business logic
- Supporting sophisticated UIs with multipage units of work
- Implementing high performance service oriented architecture
- Streamlining application customization

Following are the main components of business components

- Entity Objects
 Entity objects represents rows in database .Entity objects ensure business logic are consistently enforced.It supports associations to other entity objects
- View Layer
Represents a SQL query.Enables re-use of business logic through multiple sql based views.

- Application Modules
Is a transnational component that UI client use to work with application data. Application Module holds view objects and other custom methods.

Sunday, December 1, 2013

Using ADF Faces Dialog framework

-          Use ADF faces dialog framework to create dialog in application doesn't uses ADF controller and task flows 
-          Enables display a page or series of pages in a separate browser windows

-          If application uses fusion technology you should use task flows to create popups 
Create a control flow case and view activity in adfc-config.xml file as below.

Look at the dialog:syntax used.

Code for dia_view1.jspx 

<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
        <af:document title="dia_view1.jspx" id="d1">
            <af:form id="f1">
                <af:button text="button 1" id="b1" action="dialog:toView2" useWindow="true" windowModalityType="applicationModal" windowHeight="200"
                           windowWidth="300" launchListener="#{pageFlowScope.DialogBackingbean.launchListener}"
                           returnListener="#{pageFlowScope.DialogBackingbean.dialogReturnListener}"/>
            </af:form>
        </af:document>
    </f:view>
</jsp:root>

The adf command button uses the properties highlighted .Also look into the launch listener and return Listener code.

dia_view2.jspx 


<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
        <af:document title="dia_view2.jspx" id="d1">
            <af:outputText value="First Name : #{pageFlowScope.username}" id="ot1"/>
            <af:form id="f1">
                <af:button text="Close" id="b1" immediate="true">
                    <af:returnActionListener/>
                </af:button>
                <af:button text="Cancel " id="b2" actionListener="#{pageFlowScope.DialogBackingbean.testAction}"/>
            </af:form>
        </af:document>
    </f:view>
</jsp:root>

A close and cancel button is provided to demonstrate both ways of closing the popup.

The DialogBackingbean java bean code below.

package view.test;

import javax.faces.event.ActionEvent;

import oracle.adf.view.rich.component.rich.output.RichOutputText;
import oracle.adf.view.rich.context.AdfFacesContext;

import org.apache.myfaces.trinidad.event.LaunchEvent;
import org.apache.myfaces.trinidad.event.ReturnEvent;

public class DialogBackingbean {
    private RichOutputText outTextBind;

    public DialogBackingbean() {
    }

    public void listenerMethod(ReturnEvent returnEvent) {
        System.out.println("Return Listener..");
        // AdfFacesContext.getCurrentInstance().getPageFlowScope().put("testValue", "Testing");
        String retVal = (String) AdfFacesContext.getCurrentInstance().getPageFlowScope().get("retVal");
        System.out.println(retVal);

        this.getOutTextBind().setValue(retVal);
        AdfFacesContext.getCurrentInstance().addPartialTarget(this.getOutTextBind());
    }

    public void setOutTextBind(RichOutputText outTextBind) {
        this.outTextBind = outTextBind;
    }

    public RichOutputText getOutTextBind() {
        return outTextBind;
    }

    public void testAction(ActionEvent actionEvent) {
        User user = new User();
        user.setUsername("SuneeshVR");
        AdfFacesContext.getCurrentInstance().returnFromDialog(user, null);
    }

    public void launchListener(LaunchEvent launchEvent) {
        System.out.println(" Launch Listener");
       // Using the below code we can pass the parameter to the popup page.
        launchEvent.getDialogParameters().put("username", "suneesh");
    }

    public void dialogReturnListener(ReturnEvent returnEvent) {
      System.out.println("Inside dialog ret listener..");
     
      User user =(User)returnEvent.getReturnValue();
      System.out.println(user.getUsername());
    }
}

User bean is a simple java bean having the username property.