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