Dialog Framework does not open

0

I'm trying to open a ManagedBean dialog. I have a SelectOneMenu and depending on what the user selects, I call a method that is in charge of opening the correct Dialog.

This is my xhtml

<p:column headerText="Mecânica" style="text-align: center">
                                    <p:selectOneMenu id="selecionada"
                                        value="#{bancoPerguntasMBean.mecanicaSelecionada}"
                                        rendered="#{document.type == 'Pergunta'}">
                                        <f:ajax
                                            listener="#{bancoPerguntasMBean.abreDialogMecanicas()}" />
                                        <f:selectItem itemLabel="Selecione a mecânica" />
                                        <f:selectItems id="mecanica"
                                            value="#{bancoPerguntasMBean.mecanicas}" var="mecanica"
                                            itemValue="#{mecanica.nome}" itemLabel="#{mecanica.nome}" />
                                    </p:selectOneMenu>
                                </p:column>

And this is my MB method. I have already debugged and the option selected by the user correctly arrives at the method. I researched some forums and a lot of people had this problem. But until now I have not found the solution

public void abreDialogMecanicas() {

    Map<String, Object> opcoes = new HashMap<>();       

    opcoes.put("modal", true);
    opcoes.put("width", 640);
    opcoes.put("height", 340);
    opcoes.put("contentWidth", "100%");
    opcoes.put("contentHeight", "100%");

    try {

        if (this.mecanicaSelecionada.trim().equals("QUIZ")) {

            opcoes.put("header", "Cadastrar Mecânica Pergunta QUIZ");
            PrimeFaces.current().dialog().openDynamic("bancoPerguntasMecanicaQuiz", opcoes, null);
            //RequestContext.getCurrentInstance().openDialog("bancoPerguntasMecanicaQuiz", opcoes, null);                                               

        } else if (this.mecanicaSelecionada.trim().equals("VERDADEIRO FALSO")) {

            opcoes.put("header", "Cadastrar Mecânica Pergunta VF");
            PrimeFaces.current().dialog().openDynamic("bancoPerguntasMecanicaVerdadeiroFalso", opcoes, null);
            RequestContext.getCurrentInstance().openDialog("bancoPerguntasMecanicaVerdadeiroFalso", opcoes, null);              

        } else if (this.mecanicaSelecionada.trim().equals("DESCRITIVA")) {

            opcoes.put("header", "Cadastrar Mecânica Pergunta DESCRITIVA");
            RequestContext.getCurrentInstance().openDialog("bancoPerguntasMecanicaDescritiva", opcoes, null);               

        } else if (this.mecanicaSelecionada.trim().equals("ASSOCIACAO")) {

            opcoes.put("header", "Cadastrar Mecânica Pergunta ASSOCIACAO");
            RequestContext.getCurrentInstance().openDialog("bancoPerguntasMecanicaAssociacao", opcoes, null);               

        } else {

            opcoes.put("header", "Cadastrar Mecânica Pergunta ARRASTA SOLTA");
            RequestContext.getCurrentInstance().openDialog("bancoPerguntasMecanicaArrastaSolta", opcoes, null);             

        }
    } catch (

    Exception e) {
        System.out.println("Error abreDialogMecanicas: " + e.getMessage());
    }

}

I have tried both ways, both with

PrimeFaces.current().dialog().openDynamic("bancoPerguntasMecanicaQuiz", opcoes, null);

As for RequestContext itself

RequestContext.getCurrentInstance().openDialog("bancoPerguntasMecanicaVerdadeiroFalso", opcoes, null);          
    
asked by anonymous 26.04.2018 / 01:08

0 answers