Empty bean with Primefaces

Asked

Viewed 399 times

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.

inserir a descrição da imagem aqui inserir a descrição da imagem aqui inserir a descrição da imagem aqui

```

<!--<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.

  • 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

  • It was exactly my case... Check if the p:dialog is inside a h:form

  • this yes, I sent the page code

  • I just saw it. Try creating a h:form within this p:dialog. I needed to isolate some Forms in my project.

  • I put the h:form inside the dialog but nothing Brow

  • 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

  • Good, man. Test, see if it works, and then put the solution in answer.

  • @Ivobarcelos managed to solve?

  • @Wellingtonavelino opa got yes bro

  • Put the solution to help other users @Ivobarcelos

Show 6 more comments
No answers

Browser other questions tagged

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