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 ?