5

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?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Mathew Rock
  • 989
  • 2
  • 14
  • 32
  • can you define `doesn't work` - any errors, unexpected behaviour? – dognose Sep 16 '15 at 17:55
  • why not just use the p:autocomplete with a dropdown function (http://www.primefaces.org/showcase/ui/input/autoComplete.xhtml)? I think it would accomplish the lazy loading need. – Fritz Sep 17 '15 at 01:27
  • I thought to use p:autocomplete if I can´t to do lazy p:selectOneMenu – Mathew Rock Sep 17 '15 at 06:03
  • 1
    yes. I think that will be your best option since based on the primefaces user guide there is no 'dynamic' attribute for the . – Fritz Sep 18 '15 at 05:24

1 Answers1

2

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

Max
  • 1,107
  • 12
  • 24