Following example explains how to show grid without using
data control and using a java list in ADF
Sample
table source which is shown above image.
<af:table var="r"
rowBandingInterval="0" id="t26o" width="350"
contentDelivery="immediate" autoHeightRows="10"
value="#{pageFlowScope.TestBean.studentList}">
<af:column
sortable="false" headerText="Name"
id="c1171cido">
<af:outputText value="#{r.name}"
id="ot223cido"/>
</af:column>
<af:column
sortable="false" headerText="Age"
id="c169emae">
<af:outputText value="#{r.age}"
id="ot223emae"/>
</af:column>
<af:column
sortable="false" headerText="Address"
id="c169emao">
<af:outputText value="#{r.address}"
id="ot223emao"/>
</af:column>
</af:table>
Bind Student list for above grid
//studentList for grid
private List<Student> studentList = new
ArrayList<Student>();
//Getter and Setter for
studentList
public void
setStudentList(List<TestBean.Student> studentList) {
this.studentList = studentList;
}
return studentList;
}
Adding Students objects to list
//Add student objects for
studentList
public void showPopup(ActionEvent actionEvent)
{
studentList.clear();//Clear
previous data list
studentList.add(new
Student("Suresh", 28, "Colombo 6"));//Add student
studentList.add(new Student("Nilum",
26, "Colombo 2"));//Add student
ppStudents.show(new
RichPopup.PopupHints());//Show grid in a popup
}
This student class maps to above grid
//Student class, Which is
shown in grid
public class Student {
private String name;
private int age;
private String address;
public Student(String name, int age,
String address) {
this.name = name;
this.age = age;
this.address = address;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setAge(int age) {
this.age = age;
}
public int getAge() {
return age;
}
public void setAddress(String address)
{
this.address = address;
}
public String getAddress() {
return address;
}
}
All java codes implemented in TestBean.