Java Reference
In-Depth Information
registrationBeanList.add(populateBean(
"MS", "Carol", "Jones", 35));
registrationBeanList.add(populateBean(
"MRS", "Glenda", "Murphy", 39));
registrationBeanList.add(populateBean(
"MISS", "Stacy", "Clark", 36));
registrationBeanList.add(populateBean(
"MR", "James", "Fox", 40));
registrationBeanList.add(populateBean(
"DR", "Henry", "Bennett", 53));
return "success";
}
public List<RegistrationBean> getRegistrationBeanList() {
return registrationBeanList;
}
public void setRegistrationBeanList(
List<RegistrationBean> registrationBeanList) {
this.registrationBeanList = registrationBeanList;
}
private RegistrationBean populateBean(String salutation,
String firstName, String lastName, Integer age) {
RegistrationBean registrationBean;
registrationBean = new RegistrationBean();
registrationBean.setSalutation(salutation);
registrationBean.setFirstName(firstName);
registrationBean.setLastName(lastName);
registrationBean.setAge(age);
return registrationBean;
}
}
Notice that the bean has a property named
registrationBeanList
of type
java.util.List
. This is the property we used as the value of the
value
property
in the
<h:dataTable>
tag in the page above.
The bean's
populateList()
method will be called from another JSP via dynamic
navigation. This method populates the
registrationBeanList
property in the bean.