Wednesday, 19 December 2012

ADF POJO Data Control

POJO data control obtains the structure of the data from POJOs (plain, old Java objects).
To create data control, right-click a Java class file (in the Application Navigator), and choose Create Data Control.

Steps:

In  Model project :
1. Create a pojo (java class). eg. Product.java

package model.pojo;

public class Product {
    private String productId;
    private String productName;
    public Product() {      
        super();
    }
    public Product(String productId,String productName) {      
       this.productId=productId;
       this.productName=productName;          
    }
    public void setProductId(String productId) {
        this.productId = productId;
    }

    public String getProductId() {
        return productId;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getProductName() {
        return productName;
    }
}

 2. Create Service Bean class. e.g. ProductBean.java

package model;
import java.util.ArrayList;
import java.util.List;
import model.pojo.Product;

public class ProductBean {
    private List<Product> products=new ArrayList();
    public ProductBean() {
       this.createData();
    }
   
    private void createData(){
        products.add(new Product("101","Alto"));
        products.add(new Product("102","Benz"));
        products.add(new Product("103","Chevrolet"));
        products.add(new Product("104","Cruze"));
        products.add(new Product("105","Accord"));
    }
   
    public List<Product> findAllProducts() {
        return products;
      }  
}


3. Right click on ProductBean.java and choose "Create Data Control".

In ViewController project:
4. Create a jspx page.

5. In Data Controls panel, drag and drop the data collections on jspx page as ADF Table.

6. Run the jspx page.

Find the sample app here

4 comments:

  1. Hi,
    Instead of populating the list through constructor i am creating a button which will call the createData() function.on clicking the button my table is not displaying any data.

    ReplyDelete
  2. When I try download the Sample appear this message File not found.

    ReplyDelete
  3. Now if want to delete it then how to do it ?

    ReplyDelete