How to update a selectonemenu depending on other one selected value?

前端 未结 4 1976
刺人心
刺人心 2021-01-06 10:06

I\'ve been having a trouble trying to make my selectOneMenu content, depend on the value selected on the other. The content from the first one comes from a tabl

4条回答
  •  佛祖请我去吃肉
    2021-01-06 10:42

    1. value="municipio" in means that the value in that dropdown will never change as you've effectively hardcoded the value on that field to always be municipio (and even that will fail conversion). The value attribute should be bound to a backing bean variable as in

          
            
      
      

      and in your backing bean, have

         Municipio municipio;
        //getter and setter
      
    2. Remove the parameter event from . It should be

      
      
    3. Remove valueChangeListener="#{beanInscripcion.buscarMunicipios(event)}". It's unnecessary because you already have a event defined

    4. You will eventually run into problems submitting that form because you haven't created a JSF Converter for that Municipio custom type. It's mandatory if you're using anything other than String types in your select components. See a short intro to converters/converting here

提交回复
热议问题