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?