BootsFaces selectMultiMenu not rendering with ajax

393 Views Asked by At

i am using a selectMultiMenu from bootsFaces, the initial values are showed perfectly, but after rendered, with the new values the combo doesnt open, if I check the source code in my browser it shows that the bean loeaded the values correctly. It only happens with this bootsFaces's element, the rest of my project with jsf render with no problems with ajax. Any clue? Thanks!

            <h:form id="form-Principal">
            <h:panelGroup id="panel-Principal" layout="block" >
                <div class="col-md-12">                                 
                    <div class="col-md-1">
                        <label for="servicio" class="control-label">Servicio:</label>
                    </div>
                    <div class="col-md-2">
                        <h:selectOneMenu disabled="#{empty testops.ambiente}" id="servicio" class="combobox form-control" value="#{testops.servicio}" >
                            <f:selectItem itemValue="" itemLabel="Seleccione..."/>
                            <f:selectItems value="#{testops.listServicios}" />
                            <f:ajax event="change" listener="#{testops.obtenerOperaciones}" render="cboperacion" execute="@this"></f:ajax>
                        </h:selectOneMenu>
                        <h:message for="servicio" class="error"/>
                    </div>
                    <div class="col-md-1">
                        <label for="operacion" class="control-label">Operación:</label>
                    </div>
                    <div class="col-md-2">
                        <b:selectMultiMenu id="cboperacion" value="#{testops.operacion}" nonSelectedText="Seleccione...">
                             <f:selectItems value="#{testops.operaciones}"/>
                        </b:selectMultiMenu>
                    </div>
                    <div class="col-md-1">
                    </div>
                    <div class="col-md-1">
                        <f:ajax render=":salida form-Principal:panel-Principal" execute="@form" onevent="loading">
                            <h:commandLink class="btn btn-danger boton_rojo pull-right" value="Ejecutar" action="#{testops.ejecutarOperaciones()}"></h:commandLink>
                        </f:ajax>
                    </div>
                </div>                      
            </h:panelGroup>
        </h:form>enter code here

Onload: enter image description here

After rendering, it has diffent values, but combo is not display. enter image description here

1

There are 1 best solutions below

13
On

I've tried to reproduce your bug without success. Or rather: the code works as intended. The <b:selectMultMenu> is updated with the new values.

[meta] I know this isn't an answer (yet)... I just chose the answer because it's the only way to include source code. [/meta]

So I suggest you

  • copy me example code below into your project and see if it works
  • or you send me a "reproducer", i.e. a tiny but complete project showing the problem. For instance, you could upload a Maven project to GitHub. Please reduce the reproduces as much as possible. For instance, I need to be able to run it without configuring a database.

Here's the sourcecode I used to reproduce your bug:

  1. As a basis, I used our showcase.
  2. I copied your JSF code snippet into the empty.xhtml.
  3. I created a JSF bean as follows:

    package de.beyondjava.jsf.sample.carshop;                                                                                                                                                                       
    
    import java.util.ArrayList;                                                                                                                                                                                     
    import java.util.List;                                                                                                                                                                                          
    
    import javax.faces.bean.ManagedBean;                                                                                                                                                                            
    import javax.faces.bean.SessionScoped;                                                                                                                                                                          
    
    @ManagedBean                                                                                                                                                                                                    
    @SessionScoped                                                                                                                                                                                                  
    public class Testops {                                                                                                                                                                                          
      private String ambiente = "que";                                                                                                                                                                              
    
      private List<String> listServicios = new ArrayList<>();                                                                                                                                                       
    
      private String operacion;                                                                                                                                                                                     
    
      private List<String> operaciones = new ArrayList<>();                                                                                                                                                         
    
      private String servicio;                                                                                                                                                                                      
    
      {                                                                                                                                                                                                             
        listServicios.add("Servicio 1");                                                                                                                                                                            
        listServicios.add("Servicio 2");                                                                                                                                                                            
        shuffleOperaciones();                                                                                                                                                                                       
      }                                                                                                                                                                                                             
    
      public void ejecutarOperaciones(Object o) {                                                                                                                                                                   
    
      }                                                                                                                                                                                                             
    
      public String getAmbiente() {                                                                                                                                                                                 
        return ambiente;                                                                                                                                                                                            
      }                                                                                                                                                                                                             
    
      public List<String> getListServicios() {                                                                                                                                                                      
        return listServicios;                                                                                                                                                                                       
      }                                                                                                                                                                                                             
    
      public String getOperacion() {                                                                                                                                                                                
        return operacion;                                                                                                                                                                                           
      }                                                                                                                                                                                                             
      public List<String> getOperaciones() {                                                                                                                                                                        
        return operaciones;                                                                                                                                                                                         
      }                                                                                                                                                                                                             
    
      public String getServicio() {                                                                                                                                                                                 
        return servicio;                                                                                                                                                                                            
      }                                                                                                                                                                                                             
    
      public void obtenerOperaciones(Object o) {                                                                                                                                                                    
        shuffleOperaciones();                                                                                                                                                                                       
      }                                                                                                                                                                                                             
    
      public void setAmbiente(String ambiente) {                                                                                                                                                                    
        this.ambiente = ambiente;                                                                                                                                                                                   
      }                                                                                                                                                                                                             
    
      public void setListServicios(List<String> listServicios) {                                                                                                                                                    
        this.listServicios = listServicios;                                                                                                                                                                         
      }                                                                                                                                                                                                             
    
    
      public void setOperacion(String operacion) {                                                                                                                                                                  
        this.operacion = operacion;                                                                                                                                                                                 
      }                                                                                                                                                                                                             
    
      public void setOperaciones(List<String> operaciones) {                                                                                                                                                        
        this.operaciones = operaciones;                                                                                                                                                                             
      }                                                                                                                                                                                                             
    
      public void setServicio(String servicio) {                                                                                                                                                                    
        this.servicio = servicio;                                                                                                                                                                                   
      }                                                                                                                                                                                                             
    
      private void shuffleOperaciones() {                                                                                                                                                                           
        operaciones = new ArrayList<>();                                                                                                                                                                            
        for (int i = 0; i < 4; i++) {                                                                                                                                                                               
          operaciones.add("opción " + Math.ceil(Math.random()*1000));                                                                                                                                               
        }                                                                                                                                                                                                           
      }                                                                                                                                                                                                             
    
    }                                                                                                                                                                                                               
    

When I chose one of the options of the first combobox, the <b:selectMultiMenu> is updated with the new (random) values.