Error in update selectOneRadio

Asked

Viewed 294 times

0

I am trying to update the value field and percentage 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" he is updated however erases what I had selected in student.

the code of that 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>
  • Someone to help me??

  • what is the dialog id? the form is outside or inside it?

  • formDlgSolicitacao is the Dialog id and it is inside the dialog

  • can post the structure of your dialog?

  • has yes... it is a bit giant but I put kk

  • Is already posted.

  • tries to put an id on this p:dialog and give an update starting with it, I’m back 5 minutes

  • Man he still continues the same way.... he does not erase values however does not change the field that has a mask of percentage to value.

  • tries to put an id on <h:panelGrid> that remains the <pe:inputNumber> after the one update="formDlgSolicitacao:pnlGrid:idPercentual"

  • Are you trying to show/hide the inputNumber when changing the selectOneMenu?

  • That’s exactly what it is. For people to enter the school scholarship discount in percentage or value.

  • Techies that put id on Panelgrid I had already tested nothing was changed.

Show 7 more comments

2 answers

0


If a component is not rendered on the page, no matter how much its attribute rendered change the value to true, you won’t be able to draw it just by doing the update using your ID. You must 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> place the ID of the new panel: update=":formDlgSolicitacao:painel"

  • Even doing so does not change the field to insert.

  • Is actionListener being called? It’s very difficult to understand your goal. You also put a lot of code in the question...

  • Yes, he comes in, he performs everything normal... The percent field comes by default... when I select value on the radio it should upgrade to the monetary value field I put there... but it just doesn’t change the field, doesn’t update.

  • So in your public void habilitarFiltrosValor() should not set the value of #{solicitacaoBolsasBacking.bolsaEstudo.valor} ?. Because I haven’t seen this assignment anywhere. Something like this.bolsaEstudo.valor = this.opcaovalor;

  • This amount will be inserted by hand, at the time when the student will perform the enrollment and apply for scholarship.

0

It seems to me that your problem is in this condition

rendered="#{solicitacaoBolsasBacking.habilitaFiltroValor}"

or to be more accurate 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 attribute rendered of the component used in the dialog.

  • When I add the rendered condition="#{requestBolsasBacking.habilitaFiltroValor}" it will render when habilitaFiltroValue is "true". O rendered="#{requestBolsasBacking.habilitaFiltroValor}" will only be rendered when it is true so there is no need to put more conditions there. Right??

  • @Marcosraialvesdacunha, sorry. I hadn’t noticed. You have an attribute called habilitaFiltroValor and a method called habilitarFiltrosValor. Rendered is taking into account the enabled Boolean attribute Value. So rendered logic is correct.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.