I would like to load list of <f:selectItems>
only when user opens <p:selectOneMenu>
.
I tried this way but doesn't work:
<p:selectOneMenu id="bases" value="#{sucesoBB.suceso.base}" converter="EntitiesCachedConverter" >
<f:selectItem itemLabel="" itemValue="" />
<f:selectItems value="#{sucesoBB.bases}" var="base" itemValue="#{base}" itemLabel="#{base.id} - #{base.descripcion}" />
<p:ajax event="click" onstart="#{sucesoBB.bases == null or sucesoBB.bases.size() ==1 or sucesoBB.bases.empty()?'cargaBases();':''}" />
</p:selectOneMenu>
<p:remoteCommand name="cargaBases" update="bases" actionListener="#{sucesoBB.cargaBases}" />
How can I achieve this?
A "dynamic" attribute was recently added to the selectOneMenu component.
Just add it like this: <p:selectOneMenu dynamic="true" ... >
https://github.com/primefaces/primefaces/issues/2399
Demo: https://www.primefaces.org/showcase/ui/input/oneMenu.xhtml
You need to have at least Primefaces version 6.0.20, 6.1.2 or 6.2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With