Friday, 30 November 2012

Populate ADF table from Managed Bean

To create a ADF table and populate it from backing bean, define a List in backing bean and populate it with table data. Also the EL #{row.col1} won't work since String.getCol1() does not exists. So define a pojo class to populate the row values. In below example, its Employee.

In adf page :

<af:table var="row" rowBandingInterval="0" id="t1"
              <af:column sortable="false" headerText="EmpId" id="c1">
                <af:outputText value="#{row.empid}" id="ot2"/>
              <af:column sortable="false" headerText="EmpName" id="c2">
                <af:outputText value="#{row.empname}" id="ot1"/>

In managed bean:

public class SampleManagedBean {
    private List<Employee> empList;

    public SampleManagedBean() {

    public void populateList() {
        empList=new ArrayList();
        empList.add(new Employee(1, "Emp1"));
        empList.add(new Employee(2, "Emp2"));
        empList.add(new Employee(3, "Emp3"));

    public void setEmpList(List<Employee> empList) {
        this.empList = empList;

    public List<Employee> getEmpList() {
        return empList;

In Employee class :

public class Employee {
    private int empid;
    private String empname;
    public Employee(int id,String name) {

    public void setEmpid(int empid) {
        this.empid = empid;

    public int getEmpid() {
        return empid;

    public void setEmpname(String empname) {
        this.empname = empname;

    public String getEmpname() {
        return empname;

You can download the SampleApp here

No comments:

Post a Comment