Using Bean Data Control in Oracle ADF

Sharing is Caring

This post talks about a basic requirement that is creating bean data control in an ADF Application. Here I’ll show you that how to create POJO based Java class and use it as data control to populate data on the page.

Let’s start by creating a fusion web application with model and view controller project

Oracle ADF Application

Now create a POJO class PersonDetail in the model project, This class represents a person and captures his details like name, date of birth and phone number.

package beandatacontrol.model.bean;


public class PersonDetail {
    public PersonDetail() {
        // TODO Auto-generated constructor stub
    }

    public PersonDetail(String name, String phoneNo, String dateOfBirth) {

        this.name = name;
        this.phoneNo = phoneNo;
        this.dateOfBirth = dateOfBirth;

    }

    private String name;
    private String phoneNo;
    private String dateOfBirth;

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setPhoneNo(String phoneNo) {
        this.phoneNo = phoneNo;
    }

    public String getPhoneNo() {
        return phoneNo;
    }

    public void setDateOfBirth(String dateOfBirth) {
        this.dateOfBirth = dateOfBirth;
    }

    public String getDateOfBirth() {
        return dateOfBirth;
    }
}

The second class is Society that holds the list of people and it goes like this.

package beandatacontrol.model.bean;

import java.util.ArrayList;

import oracle.binding.AttributeContext;
import oracle.binding.RowContext;

public class Society {

    public ArrayList<PersonDetail> person = new ArrayList<PersonDetail>();

    public Society() {
        super();
        if (person.size() == 0) {
          
            person.add(new PersonDetail("Ashish Awasthi", "+91672938", "02/01/1991"));
            person.add(new PersonDetail("Shyam Kumar", "+91345545343", "06/09/1991"));
            person.add(new PersonDetail("Alex Smith", "+458954638", "08/02/1991"));
            person.add(new PersonDetail("Raghav Mani", "+914512698", "09/06/1991"));
            person.add(new PersonDetail("Ahmad Sheikh", "+7459654245", "12/05/1991"));
            
        }
    }

    public void setPerson(ArrayList<PersonDetail> person) {
        this.person = person;
    }

    public ArrayList<PersonDetail> getPerson() {
        return person;
    }
}

Now right click on Society class and select Create Data Control

Create Data Control of Bean

In the next step, I have selected Custom CRUD operation support in ADF Data Control Features

ADF Data Control Features

Click on Next and don’t change access mode, default value is Scrollable

Data Control Access Mode

Click on Finish and you can see all the details

Finish Data Control Creation

Now you can see a DataControl.dcx file is created in the project, In short bean data control is ready for use.

Bean Data Control

Right click on view controller project and create a page and drop person data control on the page as ADF table. Also, drop create operation as a button and run the application.

Bean Data Control table

Check create button, click on that and see a new row added in ADF table.

New Row Created in ADF Table

Cheers 🙂 Happy Learning

Related Posts

An Oracle ACE, Blogger, Reviewer, Technical Lead working on Oracle ADF

Leave a Reply

Your email address will not be published. Required fields are marked *