I load selectOneMenu items on ajax event "focus" because list of items is to big and I do not want to prepare it on Bean loading. The best way for me it is to load it on selectOneMenu focus. After list loading Jsf needs to update selectOneMenu component but it closes dropdownlist every time. Is it way to update selectOneMenu items without closing dropDownList?
<p:selectOneMenu id="companyEntity"
value="#{docBean.docIncomingEntity.companyEntity}"
effect="fade"
rendered="#{docBean.companyPersonSwitch == 0}"
filter="true"
converter="omnifaces.SelectItemsConverter"
filterMatchMode="contains">
<f:selectItems value="#{companyBean.companyEntityList}"
itemLabel="#{item.name}"
itemValue="#{item}"
var="item"/>
<p:ajax event="focus" listener="#{companyBean.loadAllCompaniesList()}" update="companyEntity"/>
</p:selectOneMenu>
You don't need to build lazy loading yourself. PrimeFaces has built in lazy loading for the
p:selectOneMenucomponent. You simply have to add the attributedynamic="true"and it will lazy load the items. You can find a demo in the showcase.See:
If you really have a lot of items, you are better of using the
p:autoCompletecomponent. AutoComplete displays suggestions while the input is being type. It features various options, customizable content, multiple selection, effects and events.See: