Hide column at time of edit

1

I have a registration screen with some attributes, which at the time of editing I do not want to load the password, because I just want to change the name and the email, that is, I want to hide the password column only in editing. p>

NOTE: All CRUDs are working.

CustomerCount.xhtml:

<p:fieldset legend="Clientes">
    <h:panelGrid columns="2">
        <p:outputLabel value="Nome: " for="nome" />
        <p:inputText id="nome" value="#{cadastroClientesBean.cliente.nome}" />

        <p:outputLabel value="E-mail: " for="email" />
        <p:inputText id="email" value="#{cadastroClientesBean.cliente.email}"/>

        <p:outputLabel value="Senha: " for="senha" />
        <p:password id="senha" value="# {cadastroClientesBean.cliente.senha}" 
          required="true" requiredMessage="Senha obrigatória" />

        <p:outputLabel />
        <p:commandButton value="Salvar" action="# {cadastroClientesBean.gravar}"
            icon="ui-icon-disk" update="@form" />
    </h:panelGrid>
</p:fieldset>

CustomerContent.xhtml:

<p:dataTable value="#{consultaClientesBean.clientes}" var="cliente">
    <p:column headerText="Nome">
        <h:outputText value="#{cliente.nome}" />
    </p:column>

    <p:column headerText="E-mail">
        <h:outputText value="#{cliente.email}" />                       
    </p:column>

    <p:column headerText="Ações" width="100" style="text-align:  center">
        <p:button icon="ui-icon-pencil" title="Editar" outcome="/admin/CadastroClientes">
            <f:param name="id" value="#{cliente.id}" />
        </p:button>

        <p:commandButton icon="ui-icon-trash" title="Excluir"
            process="@this" update="@form"
            action="#{consultaClientesBean.excluir}">
            <f:setPropertyActionListener value="#{cliente}" target="#{consultaClientesBean.clienteSelecionado}" />
        </p:commandButton>
    </p:column>
</p:dataTable>

NOTE: All CRUDs are working.

    
asked by anonymous 03.11.2015 / 14:01

1 answer

0

Normally in editing id will not be null, since it was created in the database and everything else.

If this is true, you can use something like this:

<h:panelGroup rendered="#{cadastroClientesBean.cliente.id eq null}">
    <p:outputLabel value="Senha: " for="senha" />
    <p:password id="senha" value="#{cadastroClientesBean.cliente.senha}" 
                  required="true" requiredMessage="Senha obrigatória" />
</h:panelGroup>

If you have a more specific rule you can do something in the controller, or even in XHTML, if it is in context.

    
03.11.2015 / 16:15