Sat. Dec 4th, 2021

Explanation: Data controls are an abstraction provided by ADF Model that enable us to work with data and business services in a declarative manner and easily create UI components.

We use the Bean Data Control type to create Data Controls for Plain Java Objects (POJOs) and JPA-based Java service facade classes.

Requirement: I have a POJO based Java classes and we want to use it as a Data Control to populate data onto an Oracle ADF page. Basically, we want to create a Bean Data Control in Oracle ADF which will help us to play with the data.

Solution: For solution of the above requirement follow the steps as shown below:

Step 1: Create an Oracle ADF Fusion Web Application with the name as BeanDataControlSample. This application should have both the Model project and the ViewController project.

Step 2: Create a StudentDetails POJO class inside the Model Project.

For that right click Model Project > New > From Gallery.

Select Java Class > Click OK

Give the POJO class Name as StudentDetails > Click OK

Step 3: This StudentDetails class represents a Student and captures his details like Name, Date of Birth and Phone Number.

Thus, the complete code for the StudentDetails.java class is as below:

package model;

public class StudentDetails {

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

    public StudentDetails() {
        super();
    }

    public StudentDetails(String name, String phoneNo, String dateOfBirth) {
        this.name = name;
        this.phoneNo = phoneNo;
        this.dateOfBirth = 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;
    }
}

Similarly, let us create the second POJO class with name as School that holds the list of Students.

package model;

import java.util.ArrayList;

public class School {

    public ArrayList<StudentDetails> student = new ArrayList<StudentDetails>();

    public School() {
        super();
        if (student.size() == 0) {

            student.add(new StudentDetails("Susanto Paul", "6978654537", "04/05/1986"));
            student.add(new StudentDetails("Shobhit Agarwal", "8978654537", "09/09/1988"));
            student.add(new StudentDetails("Moumita Deb", "7978654537", "08/12/1990"));
            student.add(new StudentDetails("Amrita Chakraborty", "9978654537", "02/06/1993"));
            student.add(new StudentDetails("Anjali Paul", "5978654537", "1209/1992"));
        }
    }

    public void setStudent(ArrayList<StudentDetails> student) {
        this.student = student;
    }

    public ArrayList<StudentDetails> getStudent() {
        return student;
    }
}

Step 4: Now right click on School class and select Create Data Control

Click Next

Check Custom CRUD (Create/Read/Update/Delete) option > Click Next

Let the Access Mode be Scrollable > Click Next

Click Finish

Now, we can see that the DataControl.dcx file is created inside the Model project.

And the entry in the Data Controls palette will be as shown below:

Step 5: Now, create a demo.jspx page in the ViewController project.

Drag and drop student from the Data Controls palette into the demo.jspx as a Table > Select Single Row radio button > Click OK

Drop and drop Create operation as a button on the demo.jspx page.

Save all and run the demo.jspx page. Thus, the ran application is as below:

When we click on the Create button a new row is added in the table.

Hence, the solution to our requirement.

If you like the post please comment, share, and do join me on Facebook. Please subscribe to my YouTube Channel for video tutorials.

Thanks & Regards,
Susanto Paul

 815 total views,  2 views today

By Susanto Paul

Susanto is an Oracle ACE, a qualified MCA, MBA, and a highly-skilled Senior Oracle Specialist. He is an enthusiastic Blogger and YouTuber who helps learners to solve their complex problems more efficiently. He has 9+ years of experience in multiple technologies like AWS, Oracle ADF, Oracle APEX, Oracle JET, Oracle VBCS, Oracle IDCS, Oracle PL/SQL, Oracle Integration Cloud, Java, JDBC, Servlets, JSP, Spring, Hibernate, HTML5, CSS3, JavaScript, TypeScript, NodesJS, Angular, MySQL, Oracle WebLogic Server, JUnit, JMeter, Selenium Web Driver, etc. He is a certified: Oracle Certified Professional Java SE 6 Programmer, Oracle ADF 11g Certified Implementation Specialist, Oracle Cloud Platform Application Integration 2020 Certified Specialist, Oracle Cloud Infrastructure Foundations 2020 Certified Associate, and Oracle Cloud Infrastructure Developer 2020 Certified Associate

Leave a Reply

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

satta king chart