Give update of a component that is in another form

2

Hello

Guys, I've done a dialog that inserts fields into a list. This list fills the values of a selectOneMenu, which is in another form:

<h:form id="idFormDadosTeatro"> 
            <p:panel id="painelTeatro" header="Dados da Teatro"
                style="margin-bottom:20px">
                <h:panelGrid id="painelGridTeatro" columns="2" cellpadding="10">

                        <p:selectOneMenu id="idmotivoDaPecaTeatro"
                            value="#{TeatroBean.idPerfil}" filter="true" required="true"
                            style="width: 226px;margin:5px;"
                            requiredMessage="Campo Motivo da Peça de Teatro é obrigatório"
                            widgetVar="motivo">
                            <f:selectItem itemLabel="Selecione" itemValue=""></f:selectItem>
                            <f:selectItems value="#{TeatroBean.listaDePerfisSelectItem}"></f:selectItems>

                        </p:selectOneMenu>

                        <p:outputLabel value="" style="color: #FF0000"></p:outputLabel>
                        <p:commandLink value="Cadastrar novo motivo de Teatro"
                            onclick="dialogcadastro.show();" />

                </h:panelGrid>
            </p:panel>

            <h:form>
                <p:dialog id="iddialogcadastro"
                    header="Cadastro de Motivo de Teatro" widgetVar="dialogcadastro"
                    resizable="false" appendTo="@form">
                    <h:panelGrid columns="2" cellpadding="5">

                        <h:outputLabel for="nome" value="Nome:" />
                        <p:inputText value="#{TeatroBean.nomeNovoPerfil}" id="nome"
                            required="true" label="nome" immediate="true" />

                        <p:commandButton id="cadastrousuario" value="Cadastrar"
                            actionListener="#{TeatroBean.salvarMotivoTeatro}"
                            oncomplete="PF('dialogcadastro').hide();" process="@form">
                            update=":idFormDadosTeatro:painelTeatro:painelGridTeatro:idmotivoDaPecaTeatro"
                        </p:commandButton>

                    </h:panelGrid>
                </p:dialog>
            </h:form>
        </h:form>

I tried to update this selectOneMenu, but the message appears:

Cannot find component with expression "painelTeatro:painelGridTeatro:idmotivoDaPecaTeatro" referenced from "formGeral:idFormDadosVisita:j_idt76:cadastrousuario".

How could I update the list of this selectOneMenu without the user having to give F5 on the page? Thank you!

    
asked by anonymous 24.05.2016 / 20:15

1 answer

1

Solved! It was just to add "formGeral" in the update of the "Register" button of the dialog:

<h:form>
            <p:dialog id="iddialogcadastro"
                header="Cadastro de Motivo de Teatro" widgetVar="dialogcadastro"
                resizable="false" appendTo="@form">
                <h:panelGrid columns="2" cellpadding="5">

                    <h:outputLabel for="nome" value="Nome:" />
                    <p:inputText value="#{TeatroBean.nomeNovoPerfil}" id="nome"
                        required="true" label="nome" immediate="true" />

                    <p:commandButton id="cadastrousuario" value="Cadastrar"
                        actionListener="#{TeatroBean.salvarMotivoTeatro}"
                        oncomplete="PF('dialogcadastro').hide();" process="@form">
                        update=":formGeral:idFormDadosTeatro:idmotivoDaPecaTeatro"
                    </p:commandButton>

                </h:panelGrid>
            </p:dialog>
        </h:form>
    
30.05.2016 / 14:12