0

I have a dropdown where I am using Ajax component to execute an action, depending on the selection of the dropdown, now that I work properly, what I need is to run the event but with the dropdown value already selected. I have my code as well:

<p:selectOneMenu value="#{regRolMB.rol.sistema.cdCodigo}">
    <f:selectItem itemLabel="-- SELECCIONE --" itemValue="" />
    <f:selectItems value="#{regRolMB.listHorario}" var="hor" itemValue="#{hor.cdCodigo}" itemLabel="#{hor.nbNombre}" />                                 
    <p:ajax listener="#{regRolMB.changeHorario}" process="@this" update="dataTableHorario" />                                   
</p:selectOneMenu>

And in the controller like this:

private List<DetHorario> detHorario;

@PostConstruct
    public void init() {
        try{        
            detHorario = new ArrayList<DetHorarioBean>();
        }catch(Exception e){
            e.printStackTrace();
        }       
    }

    private void ListadoDetHorarios(Long rolCodHorario){
        detHorario = detHorarioService.buscarDetHorarioPorRolHorario(rolCodHorario);        
    }

    public void changeHorario(AjaxBehaviorEvent vce){   
       Long idRolCodHorario= (Long) ((UIOutput) vce.getSource()).getValue();      
       ListadoDetHorarios(idRolCodHorario);
    }

I consulted as I can run that event changeHorario in the @PostConstruct

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Please, dropdownlist != combobox. A combobox is a textbox+dropdown in one, i.e. an editable dropdownlist. – BalusC Oct 03 '13 at 20:07
  • No apology, the question focuses on the component – user2844190 Oct 03 '13 at 20:33
  • what version of jsf are you using? If you use JSF2+ you can define your method like `public void changeHorario(){...}` and use `rol.sistema.cdCodigo` with the new value updated. Why do you want to run **changeHorario** in the PostConstruct? To set the initial values of the list? BTW.. you have "detHorario" in your init method (which is your list) but you use "listHorario" in you page. – danRod Oct 03 '13 at 22:03

0 Answers0