Error in update selectOneRadio

0

I'm trying to update the value and percentage field of the page under development. When I put in ajax the option: update=":formDlgSolicitacao:idPercentual :formDlgSolicitacao:idValor" it does not update the field, when I enter update="@form" it is updated however delete what I had selected in student.

The code for this radio is this:

<p:selectOneRadio value="#{solicitacaoBolsasBacking.opcaoValor}">
                            <f:selectItem itemLabel="Percentual" itemValue="3" />
                            <f:selectItem itemLabel="Valor" itemValue="4" />
                            <p:ajax event="change"
                                listener="#{solicitacaoBolsasBacking.habilitarFiltrosValor()}"
                                update=":formDlgSolicitacao:idPercentual :formDlgSolicitacao:idValor"
                                process="@this" />      
</p:selectOneRadio>
                        <pe:inputNumber id="idPercentual" size="15"
                            value="#{solicitacaoBolsasBacking.bolsaEstudo.valor}"
                            rendered="#{solicitacaoBolsasBacking.habilitaFiltroPercentual}"
                            decimalPlaces="0" symbol="%" symbolPosition="s" />

                        <pe:inputNumber id="idValor" size="15"
                            value="#{solicitacaoBolsasBacking.bolsaEstudo.valor}"
                            rendered="#{solicitacaoBolsasBacking.habilitaFiltroValor}"
                            symbol="R$" />

The method of validating the option is this:

public void habilitarFiltrosValor() {

    if (opcaoValor == 3) {
        habilitaFiltroPercentual = Boolean.TRUE;
        habilitaFiltroValor = Boolean.FALSE;
    }
    if (opcaoValor == 4) {
        habilitaFiltroPercentual = Boolean.FALSE;
        habilitaFiltroValor = Boolean.TRUE;
    }

}

This selectOneRadio is in a Dialog.

Dialog Code

<p:dialog closeOnEscape="true"
            header="Solicitação de Bolsa de Estudo" widgetVar="dlgBolsa"
            footer="SIGAAC - Sistema de Gerenciamento de Atividades Acadêmicas"
            showEffect="clip" hideEffect="clip" width="650" modal="true"
            appendTo="@(body)">
            <h:form id="formDlgSolicitacao">

                <h:panelGrid columns="3">
                    <h:panelGrid>
                        <h:outputText value="Nº Processo" />
                        <p:inputMask size="10"
                            value="#{solicitacaoBolsasBacking.bolsaEstudo.id}"
                            readonly="true" />
                    </h:panelGrid>

                    <h:panelGrid>
                        <h:outputText value="Data/Hora" />
                        <p:inputText id="txtData" readonly="true"
                            value="#{solicitacaoBolsasBacking.data}">
                            <f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT-3" />
                        </p:inputText>
                    </h:panelGrid>

                    <h:panelGrid>
                        <h:outputText value="Status" />
                        <p:inputText id="txtStatus" value="Em digitação" readonly="true" />
                    </h:panelGrid>
                </h:panelGrid>

                <h:panelGrid columns="2">
                    <h:panelGrid>
                        <h:outputText value="ID Curso" />
                        <p:inputMask size="10" id="idDlgCurso" readonly="true"
                            value="#{solicitacaoBolsasBacking.curso.id}" mask="9?99999">
                            <p:ajax
                                update=":formDlgSolicitacao:txtDlgCurso :formDlgSolicitacao:idDlgCurso :growl"
                                process="@this"
                                listener="#{solicitacaoBolsasBacking.carregarCurso()}"
                                event="change" />
                        </p:inputMask>
                    </h:panelGrid>

                    <h:panelGrid>
                        <h:outputText value="Nome do Curso" />
                        <p:inputText size="60" id="txtDlgCurso" readonly="true"
                            value="#{solicitacaoBolsasBacking.curso.nome}" />
                    </h:panelGrid>
                </h:panelGrid>
                <h:panelGrid columns="3">
                    <h:panelGrid columns="1">
                        <h:outputText value="ID Etapa" />
                        <p:inputMask mask="9?99999" id="idEtapa" size="10"
                            value="#{solicitacaoBolsasBacking.idEtapa}">
                            <p:ajax event="change"
                                update=":formDlgSolicitacao:idEtapa :formDlgSolicitacao:txtEtapa"
                                process="@this"
                                listener="#{solicitacaoBolsasBacking.carregarEtapa()}" />
                        </p:inputMask>
                    </h:panelGrid>
                    <h:panelGrid columns="1">
                        <h:outputText value="Descrição Etapa" />
                        <p:inputText size="30" id="txtEtapa" readonly="true"
                            value="#{solicitacaoBolsasBacking.etapa.etapa}  #{solicitacaoBolsasBacking.etapa.ofertaTurma.ofertaCurso.curso.perIntegralizacao.descricao}" />
                    </h:panelGrid>
                    <h:panelGrid>
                        <h:outputText value=" " />
                        <h:outputText value=" " />
                        <h:outputText value=" " />
                        <h:outputText value=" " />
                        <p:commandButton icon="ui-icon-search"
                            onclick="PF('dlgEtapa').show()" update=":formEtapa"
                            process="@this" />
                    </h:panelGrid>
                </h:panelGrid>

                <h:panelGrid columns="3">
                    <h:panelGrid>
                        <p:selectOneRadio value="#{solicitacaoBolsasBacking.opcaoAluno}">
                            <f:selectItem itemLabel="CPF" itemValue="1" />
                            <f:selectItem itemLabel="ID" itemValue="2" />
                            <p:ajax event="change"
                                listener="#{solicitacaoBolsasBacking.habilitarFiltrosAluno()}"
                                update=":formDlgSolicitacao:cpfAluno :formDlgSolicitacao:idAluno"
                                process="@this" />
                        </p:selectOneRadio>

                        <p:inputMask size="15" id="cpfAluno" mask="999.999.999-99"
                            rendered="#{solicitacaoBolsasBacking.habilitarFiltroCpf}"
                            value="#{solicitacaoBolsasBacking.cpfAluno}">
                            <p:ajax
                                update=":formDlgSolicitacao:cpfAluno :formDlgSolicitacao:txtNomeAluno :growl"
                                listener="#{solicitacaoBolsasBacking.carregarAlunoCPF()}"
                                event="change" process="@form" />
                        </p:inputMask>
                        <p:inputMask size="15" id="idAluno" mask="9?99999"
                            rendered="#{solicitacaoBolsasBacking.habilitarFiltroID}"
                            value="#{solicitacaoBolsasBacking.idAluno}">
                            <p:ajax
                                update=":formDlgSolicitacao:idAluno :formDlgSolicitacao:txtNomeAluno :growl"
                                process="@this"
                                listener="#{solicitacaoBolsasBacking.carregarAlunoID()}"
                                event="change" />
                        </p:inputMask>
                    </h:panelGrid>

                    <h:panelGrid>
                        <h:outputText value=" " />
                        <h:outputText value=" " />
                        <h:outputText value=" " />
                        <h:outputText value=" " />
                        <h:outputText value="Nome do Aluno" />
                        <p:inputText size="60" id="txtNomeAluno"
                            value="#{solicitacaoBolsasBacking.alunoCurso.aluno.pessoa.nome}" />
                    </h:panelGrid>
                    <h:panelGrid>
                        <h:outputText value=" " />
                        <h:outputText value=" " />
                        <h:outputText value=" " />
                        <h:outputText value=" " />
                        <h:outputText value=" " />
                        <h:outputText value=" " />
                        <h:outputText value=" " />
                        <h:outputText value=" " />
                        <p:commandButton icon="ui-icon-search"
                            onclick="PF('dlgAluno').show()" update=":formAluno:tblAluno"
                            process="@this" />
                    </h:panelGrid>
                </h:panelGrid>

                <fieldset class="fieldSetBorder">
                    <legend>
                        <strong>Bolsa</strong>
                    </legend>

                    <h:panelGrid columns="3">
                        <h:panelGrid>
                            <h:outputText value="ID Tipo" />
                            <p:inputMask size="10" id="idBolsa" mask="9?99999"
                                style="height:10px" value="#{solicitacaoBolsasBacking.idBolsa}"
                                tabindex="1" readonly="true">
                                <p:ajax
                                    update=":formDlgSolicitacao:idBolsa :formDlgSolicitacao:txtBolsa :growl"
                                    event="change"
                                    listener="#{solicitacaoBolsasBacking.carregarTipoBolsa()}" />

                            </p:inputMask>

                        </h:panelGrid>

                        <h:panelGrid>
                            <h:outputText value="Descrição" />
                            <p:inputText size="60" id="txtBolsa" readonly="true"
                                value="#{solicitacaoBolsasBacking.tipoBolsaEstudo.descricao}" />
                        </h:panelGrid>

                        <h:panelGrid>
                            <h:outputText value=" " />
                            <h:outputText value=" " />
                            <h:outputText value=" " />
                            <h:outputText value=" " />
                            <p:commandButton icon="ui-icon-search"
                                onclick="PF('dlgTipoBolsa').show()" update=":formTipoBolsas"
                                process="@this" />
                        </h:panelGrid>
                    </h:panelGrid>

                    <h:panelGrid columns="3">
                        <h:panelGrid>
                            <h:outputText value="Cobertura" />

                            <p:inputText size="15" id="idCoberturaInicio" readonly="true"
                                value="#{solicitacaoBolsasBacking.tipoBolsaEstudo.faixaIniCobertura}" />
                        </h:panelGrid>

                        <h:panelGrid>
                            <h:outputText value=" " />
                            <h:outputText value=" " />
                            <h:outputText value=" " />
                            <h:outputText value=" " />
                            <h:outputText value="até" />
                        </h:panelGrid>

                        <h:panelGrid>
                            <h:outputText value=" " />
                            <h:outputText value=" " />
                            <h:outputText value=" " />
                            <h:outputText value=" " />
                            <p:inputText size="15" id="idCoberturaFim" readonly="true"
                                value="#{solicitacaoBolsasBacking.tipoBolsaEstudo.faixaFimCobertura}" />
                        </h:panelGrid>
                    </h:panelGrid>
                </fieldset>

                <fieldset class="fieldSetBorder">
                    <legend>
                        <strong>Solicitação</strong>
                    </legend>

                    <h:panelGrid>
                        <p:selectOneRadio value="#{solicitacaoBolsasBacking.opcaoValor}">
                            <f:selectItem itemLabel="Percentual" itemValue="3" />
                            <f:selectItem itemLabel="Valor" itemValue="4" />
                            <p:ajax event="change"
                                listener="#{solicitacaoBolsasBacking.habilitarFiltrosValor()}"
                                update=":formDlgSolicitacao:idPercentual :formDlgSolicitacao:idValor"
                                process="@this" />
                        </p:selectOneRadio>
                        <pe:inputNumber id="idPercentual" size="15"
                            value="#{solicitacaoBolsasBacking.bolsaEstudo.valor}"
                            rendered="#{solicitacaoBolsasBacking.habilitaFiltroPercentual}"
                            decimalPlaces="0" symbol="%" symbolPosition="s" />

                        <pe:inputNumber id="idValor" size="15"
                            value="#{solicitacaoBolsasBacking.bolsaEstudo.valor}"
                            rendered="#{solicitacaoBolsasBacking.habilitaFiltroValor}"
                            symbol="R$" />
                    </h:panelGrid>

                    <h:panelGrid columns="3">
                        <h:panelGrid>
                            <h:outputText value="Período Inicial" />

                            <p:calendar locale="pt"
                                value="#{solicitacaoBolsasBacking.bolsaEstudo.dtInicioVigencia}" />
                        </h:panelGrid>

                        <h:panelGrid>
                            <h:outputText value=" " />
                            <h:outputText value=" " />
                            <h:outputText value=" " />
                            <h:outputText value=" " />
                            <h:outputText value="até" />
                        </h:panelGrid>

                        <h:panelGrid>
                            <h:outputText value="Período Final" />

                            <p:calendar locale="pt"
                                value="#{solicitacaoBolsasBacking.bolsaEstudo.dtFinalVigencia}" />
                        </h:panelGrid>
                    </h:panelGrid>
                </fieldset>
                <fieldset class="fieldSetBorder">
                    <legend>
                        <strong>Incidência</strong>
                    </legend>
                    <h:panelGrid columns="3">
                        <p:inputMask id="idIncidencia" mask="9?99999" size="10"
                            value="#{solicitacaoBolsasBacking.idIncidencia}">

                            <p:ajax event="change"
                                listener="#{solicitacaoBolsasBacking.carregarIncidencia()}"
                                update=":formDlgSolicitacao:idIncidencia :formDlgSolicitacao:txtIncidencia :growl"
                                process="@this" />
                        </p:inputMask>

                        <p:inputText size="60" id="txtIncidencia"
                            value="#{solicitacaoBolsasBacking.incidencia.descricao}" />

                        <p:commandButton icon="ui-icon-search"
                            update=":formIncidencia:tblIncidencia" process="@this"
                            onclick="PF('dlgIncidencia').show()" />
                    </h:panelGrid>
                </fieldset>
                <div align="center">
                    <h:panelGrid columns="2">
                        <p:commandButton value="Gravar"
                            action="#{solicitacaoBolsasBacking.solicitar()}"
                            onclick="PF('dlgBolsa').hide()" icon="ui-icon-disk"
                            process="@this" />

                        <p:commandButton value="Limpar" onclick="PF('dlgBolsa').hide()"
                            icon="ui-icon-trash"
                            action="#{solicitacaoBolsasBacking.limpar()}"
                            update=":formSolicitacao:txtCurso :formSolicitacao:idCurso :formSolicitacao
                            :formSolicitacao:tabView01 :formSolicitacao:txtPerLetivo :formSolicitacao:idPerLetivo"
                            process="@this" />
                    </h:panelGrid>
                </div>
            </h:form>
        </p:dialog>
    
asked by anonymous 02.09.2015 / 16:12

2 answers

0

If a component is not rendered on the page, however much its rendered attribute changes the value to true , you will not be able to draw it by just update using its ID. You should update the 'parent' of this component to achieve this goal.

My suggestion is:

Envelope the inputs in a <p:panel id="painel">

And then, in the update of <p:ajax> of <p:selectOneRadio> put the ID of the new panel: update=":formDlgSolicitacao:painel"

    
03.09.2015 / 15:53
0

It seems to me that your problem is in this condition

rendered="#{solicitacaoBolsasBacking.habilitaFiltroValor}"

or to be more exact in this method

public void habilitarFiltrosValor() {

    if (opcaoValor == 3) {
        habilitaFiltroPercentual = Boolean.TRUE;
        habilitaFiltroValor = Boolean.FALSE;
    }
    if (opcaoValor == 4) {
        habilitaFiltroPercentual = Boolean.FALSE;
        habilitaFiltroValor = Boolean.TRUE;
    }

}

You need to return a Boolean value in the above method so that it is used in the rendered attribute of the component used in the dialog.

    
03.09.2015 / 16:55