I trie to not load the p:selectOneMenu
item list when the page is loaded, because the list is too big. I set the attribute dynamic="true"
to have lazy loading, but it always loads the list on page load. Instead I want to load it only when user starts opens the p:selectOneMenu
.
My xhtml
<p:selectOneMenu id="companyEntity"
value="#{docBean.docIncomingEntity.companyEntity}"
effect="fade"
style="width: 100%"
dynamic="true"
filter="true"
converter="omnifaces.SelectItemsConverter">
<f:selectItems value="#{companyBean.loadAllCompaniesList()}"
itemLabel="#{item.name}"
itemValue="#{item}"
var="item"/>
</p:selectOneMenu>
My Bean
...
public List<CompanyEntity> loadAllCompaniesList() {
return companyDAO.selectAllCompanies();
}
My DAO
public List<CompanyEntity> selectAllCompanies() {
return em.createQuery("select a from CompanyEntity a order by a.name", CompanyEntity.class)
.getResultList();
}