3
I created a page with a datatable
and to register something I display the form
on a p:dialog
of Primefaces works perfectly, but when I create the layout of Primefaces to put my page inside the layout and start a new registration type the information and saved, the object arrives empty in my bean, and nor goes through the validation of beanValidator also.
Remembering that the page works ok, but when I put it inside this layout of Primefaces gives this problem.
```
<!--<ui:define name="metadata"></ui:define>-->
<ui:define name="title">Cadastro de Grupo de Empresas</ui:define>
<ui:define name="content" id="content">
<f:metadata>
<f:viewAction action="#{grupoEmpresasBean.consultar}"/>
</f:metadata>
<h:form id="form-lista">
<p:messages id="messages-geral" closable="true"/>
<p:toolbar id="toolbar" style="margin-top:5px;">
<f:facet name="left">
<p:commandButton value="Incluir" icon="ui-icon-document" title="Incluir"
action="#{grupoEmpresasBean.prepararInclusaoEdicao}"
process="@this" update="grupoEmpresa-dialogo"
oncomplete ="PF('cadastroGrupoEmpresa').show()">
<p:resetInput target="grupoEmpresa-dialogo"></p:resetInput>
</p:commandButton>
<span class="ui-separator">
<span class="ui-icon ui-icon-grip-dotted-vertical" title="Incluir" />
</span>
<p:commandButton value="Editar" icon="ui-icon-pencil" title="Editar"
disabled="#{grupoEmpresasBean.grupoEmpresaSelecionada == null}"
process="@this" update="grupoEmpresa-dialogo"
oncomplete ="PF('cadastroGrupoEmpresa').show()">
<p:resetInput target="grupoEmpresa-dialogo"></p:resetInput>
<f:setPropertyActionListener
value="#{grupoEmpresasBean.grupoEmpresaSelecionada}"
target="#{grupoEmpresasBean.grupoEmpresasInclusaoEdicao}">
</f:setPropertyActionListener>
</p:commandButton>
<p:commandButton value="Excluir" icon="ui-icon-trash" title="Excluir"
action="#{grupoEmpresasBean.excluirGrupoEmpresas}"
process="@this" update="listaGrupo messages-geral toolbar"
disabled="#{grupoEmpresasBean.grupoEmpresaSelecionada == null}" />
</f:facet>
</p:toolbar>
<p:dataTable value="#{grupoEmpresasBean.todosGruposEmpresas}" var="grupo" emptyMessage="Nehum Grupo Cadastrado!!!"
id="listaGrupo" rows="10" paginator="true" paginatorPosition="bottom" style="margin-top:5px;"
selection="#{grupoEmpresasBean.grupoEmpresaSelecionada}" selectionMode="single" rowKey="#{grupo.id}" >
<p:ajax event="rowSelect" update=":mainForm:form-lista:toolbar"/>
<p:ajax event="rowUnselect" update=":mainForm:form-lista:toolbar"/>
<p:ajax event="page" update=":mainForm:form-lista:toolbar" listener="#{grupoEmpresasBean.desabilitaToolbar}" />
<f:facet name="header">Grupos</f:facet>
<p:column headerText="Id" rendered="false" sortBy="#{grupo.id}">
<f:facet name="header">
<h:outputText styleClass="datatable-header" value="Id" style="float:left;"/>
</f:facet>
<h:outputText styleClass="datatable-row" value="#{grupo.id}"/>
</p:column>
<p:column sortBy="#{grupo.nomeGrupoEmpresa}">
<f:facet name="header">
<h:outputText styleClass="datatable-header" value="Grupo" style="float:left;"/>
</f:facet>
<h:outputText styleClass="datatable-row" value="#{grupo.nomeGrupoEmpresa}" style="float:left;"/>
</p:column>
<p:column width="20%" sortBy="#{grupo.cnpj}">
<f:facet name="header">
<h:outputText styleClass="datatable-header" value="CNPJ" style="float:left;"/>
</f:facet>
<h:outputText styleClass="datatable-row" value="#{grupo.cnpj}" style="float:left;"/>
</p:column>
<p:column width="20%" sortBy="#{grupo.nomeProprietario}">
<f:facet name="header">
<h:outputText styleClass="datatable-header" value="Proprietário" style="float:left;"/>
</f:facet>
<h:outputText styleClass="datatable-row" value="#{grupo.nomeProprietario}"/>
</p:column>
</p:dataTable>
<p:dialog header="Incluir Grupo" widgetVar="cadastroGrupoEmpresa" id="grupoEmpresa-dialogo" appendTo="@(body)"
resizable="false" modal="true" closeOnEscape="true" >
<p:messages id="grupoEmpresa-dialogo-messages" />
<p:defaultCommand target="cmdSalvarCadastroGrupoEmpresa" scope="grupoEmpresa-dialogo"/>
<h:panelGrid columns="2" id="painel-grupoEmpresa">
<p:outputLabel styleClass="form-label" for="nome-grupo">Nome do Grupo</p:outputLabel>
<p:inputText styleClass="form-text" id="nome-grupo" size="60" maxlength="100" value="#{grupoEmpresasBean.grupoEmpresasInclusaoEdicao.nomeGrupoEmpresa}" />
<p:outputLabel styleClass="form-label" value="CNPJ" for="cnpj"/>
<p:inputMask mask="99.999.999/9999-99" id="cnpj" size="18" maxlength="18" value="#{grupoEmpresasBean.grupoEmpresasInclusaoEdicao.cnpj}" />
<p:outputLabel styleClass="form-label" value="Proprietário" for="proprietario"/>
<p:inputText id="proprietario" size="60" maxlength="100" value="#{grupoEmpresasBean.grupoEmpresasInclusaoEdicao.nomeProprietario}" />
<h:outputLabel/>
<p:commandButton value="Salvar" id="cmdSalvarCadastroGrupoEmpresa"
action="#{grupoEmpresasBean.salvarGrupoEmpresas}"
process="grupoEmpresa-dialogo"
oncomplete="if (!args.validationFailed) PF('cadastroGrupoEmpresa').hide()"
update="grupoEmpresa-dialogo-messages painel-grupoEmpresa listaGrupo toolbar">
</p:commandButton>
</h:panelGrid>
</p:dialog>
</h:form>
</ui:define>
```
Someone’s been through this trouble?
I’ve been through this problem. A question: You mean that it works outside the Dialog? It would be good to put the code too, instead of the screenshot.
– Fellipe Soares
so Felipe it works perfect outside the Unit layout of the first faces, I first created the page and made it work was all ok, so I created a template as you see in the image above, then add my page inside my template, then Jah does not work rs, if I call the page out of the template works perfect
– Ivo Barcelos
It was exactly my case... Check if the
p:dialog
is inside ah:form
– Fellipe Soares
this yes, I sent the page code
– Ivo Barcelos
I just saw it. Try creating a
h:form
within thisp:dialog
. I needed to isolate some Forms in my project.– Fellipe Soares
I put the h:form inside the dialog but nothing Brow
– Ivo Barcelos
Felipe I think I found the problem friend, the problem is in appendTo="@(body)" I had to put this property in the dialog because without this property it hangs the dialog too, understood
– Ivo Barcelos
Good, man. Test, see if it works, and then put the solution in answer.
– Fellipe Soares
@Ivobarcelos managed to solve?
– Wellington Avelino
@Wellingtonavelino opa got yes bro
– Ivo Barcelos
Put the solution to help other users @Ivobarcelos
– Wellington Avelino