This post talks about a basic requirement that is creating bean data control in an ADF Application. Here I'll show you 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 a model and view controller project
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
In the next step, I have selected Custom CRUD operation support in ADF Data Control Features
Click on Next and don't change access mode, the default value is Scrollable
Click on Finish and you can see all the details
Now you can see a DataControl.dcx file is created in the project, In short bean data control is ready for use.
Right-click on the 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.
Check to create button, click on that and see a new row added in the ADF table.
Cheers 🙂 Happy Learning