Update dialog component

1

I have the following dialog :

<p:dialog header="#{encomendaController.objeto.id == null ? msg['cadastrando'] : msg['atualizando']} Encomenda" widgetVar="cadastroEdicao"
        minHeight="80" id="dialog">
        <h:panelGrid id="cadastro" columns="3">
            <p:outputLabel value="Código" for="codigo" />
            <p:inputText id="codigo" value="#{encomendaController.objeto.codigo}" required="true" />
            <p:message for="codigo" />
            <p:outputLabel value="Descrição" for="descricao" />
            <p:inputText id="descricao" value="#{encomendaController.objeto.descricao}" />
            <p:message for="descricao" />
            <p:outputLabel value="Loja/Origem" for="loja" />
            <p:selectOneMenu id="loja" value="#{encomendaController.objeto.loja}">
                <f:selectItem itemLabel="" itemValue="" />
                <f:selectItems value="#{enumHelper.obterLojas()}" var="bean" itemLabel="#{bean}" itemValue="#{bean}" />
            </p:selectOneMenu>
            <p:message for="loja" />
            <p:commandButton value="Salvar" action="#{encomendaController.salvar}"
                update="cadastro,:listaEncomendas:messages,:listaEncomendas:viewFull:resultadoPendentes" oncomplete="PF('cadastroEdicao').hide();" />
        </h:panelGrid>
    </p:dialog>

So far so good, because it is a form for registering or editing a record. I also have a dataTable where I have a button to edit that record x. What I need is that by pressing the edit button, open the dialog and the loaded records, this is also working. What happens is that the title should appear updating and not registering as it does in a new domain. In my header condition I have referenced objeto == null . My edit method is simple:

public void editar(Long id) throws Exception {
        setObjeto(service.find(id));
    }


<p:commandButton icon="ui-icon-pencil" action="#{encomendaController.editar(bean.id)}"
                    update=":listaEncomendas:viewFull:cadastroEdicaoForm:cadastro,resultadoPendentes" process="@this" onclick="PF('cadastroEdicao').show();" />

I put the dialog id in the button update but it kind of messes up the whole screen, can anyone help?

    
asked by anonymous 29.03.2017 / 18:10

1 answer

0

test, replace == with eq .

  

I put the dialog id in the button update but it kind of messes up the whole screen, can anyone help?

What is usually done is to add a h:form inside the dialog, and in the dialog.show() call, apply an update to the form id, not the dialog itself. Another thing, without the form will not scroll the submit of your save button.

    
30.03.2017 / 01:54