Update dialog component

Asked

Viewed 211 times

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 registration or editing a record. I also own a dataTable where I have a button to edit that record x. What I need is that when I press the edit button, the dialog is opened and the records loaded, this is also working. What happens is that the title should appear Updating and not Registering as occurs in a new registration. In my header condition I referenced the objeto == null. My method of editing 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 kind of mess the whole screen, someone can help ?

1 answer

0

take a test, replace the == for eq.

I put the dialog id in the button update but kind of mess the whole screen, someone can help ?

What you usually do is add one h:form within the dialog, and in the dialog.show() apply an update to the form id, not the dialog itself. Something else, without the form will not scroll the Submit of your save button.

Browser other questions tagged

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