I am running an application using JSF2.0 and Primefaces 2.2RC2
I have run the profiler on my project and determined there was a bottleneck coming from a UISelectItems list. The list was being populated like 6 times on each action in my application.
The UISelectItem list was being populated in a getter method called getCountryList() and it looked like this
public UISelectItems getCountryList() throws Exception {
Collection List = new ArrayList();
List<Countries> c_list = myDao.getCountryList();
for( QcardCountries c : c_list ) {
list.add(new SelectItem(c.getCountryId().toString(), c.getCountryName());
}
UISelectItems countries = new UISelectItems();
countries.setValue(list);
return countries;
}
This works when I call in the views like so
<f:selectItems binding="#{myBean.countryList}" />
but again it is called like 6 times for each button or action I make in the application.
I then attempted to move the creation of the List into a method that was called on @PostContruct but when I do that the list does not show up when I use
<f:selectItems binding="#{myBean.countryList}" />
It just shows up as empty. Does anyone know how to properly create a list so it is only created one time and can be called throughout an entire users session to populate a dropdown list?