id problem already exists in view

0

Hello everyone. I am having an .xhtml file that is giving an id error already encountered in the preview. The error itself is

GRAVE: JSF1007: Duplicate component id frmSearch: id found in preview.

I searched the internet for this error but the answers I found are relatively vague and I could not use them to solve my problem.

I am posting the xhtl page file that is giving problem. I will also post the code of another page that is using the same id (frmSearch) and is working.

To strengthen, the page that is giving error is the SearchProperty.xhtml page. The file for the UserSearch.xhtml page is for comparison only.

SearchProperty.xhtml

<ui:define name="titulo">Pesquisar Propriedades</ui:define>

<ui:define name="corpo">
    <h:form id="frmPesquisa">
    <p:messages showDetail="false" showSummary="true" autoUpdate="true" />

    <h1>Pesquisa de propriedades</h1>

    <p:toolbar style="margin-top: 20px">
        <p:toolbarGroup>
            <p:commandButton value="Pesquisar" action="#{pesquisaPropriedadeBean.pesquisar}" update="@form" />
            <p:selectOneRadio id="id" value="#{pesquisaPropriedadeBean.filtro.status}" >
                <f:selectItem itemLabel="Ativo" itemValue="Ativo" />
                <f:selectItem itemLabel="Inativo" itemValue="Inativo" />
            </p:selectOneRadio>
        </p:toolbarGroup>
        <p:toolbarGroup align ="right">
            <p:button value="Novo" outcome="/propriedade/CadastroPropriedade"/>
        </p:toolbarGroup>
    </p:toolbar>

    <p:panelGrid columns="2" id="painel" style="width: 100%; margin-top: 20px" columnClasses="rotulo, campo">
        <p:outputLabel value="id" for="id"/>
        <p:inputText id="id" size="60" maxlength="80"
        value="#{pesquisaPropriedadeBean.filtro.propriedadeId}"/>
    </p:panelGrid>

    <p:dataTable id="propriedadesTable"
            value="#{pesquisaPropriedadeBean.propriedadesFiltradas}" var="propriedade"
            style="margin-top: 20px" emptyMessage="Nenhuma propriedade encontrada."
            rows="20" paginator="true" paginatorAlwaysVisible="false"
            paginatorPosition="bottom">

    <p:column headerText="Id" style="text-align: center; width: 100px">
            <h:outputText value="#{propriedade.id}" />
    </p:column>

    <p:column headerText="Nome" style="text-align: center; width: 100px">
            <h:outputText value="#{propriedade.nome}" />
    </p:column>

    <p:column headerText="Proprietário" style="text-align: center; width: 100px">
            <h:outputText value="#{propriedade.usuario}" />
    </p:column>

    <p:column headerText="Área" style="text-align: center; width: 100px">
            <h:outputText value="#{propriedade.area}" />
    </p:column>

    <p:column headerText="matrícula" style="text-align: center; width: 100px">
            <h:outputText value="#{propriedade.matricula}" />
    </p:column>

    <p:column headerText="Estado" style="text-align: center; width: 100px">
            <h:outputText value="#{propriedade.estado}" />
    </p:column>

    <p:column headerText="Cidade" style="text-align: center; width: 100px">
            <h:outputText value="#{propriedade.cidade}" />
    </p:column>

    <p:column headerText="Endereço" style="text-align: center; width: 100px">
            <h:outputText value="#{propriedade.endereco}" />
    </p:column>

    <p:column headerText="Status" style="text-align: center; width: 100px">
            <h:outputText value="#{propriedade.status}" />
    </p:column>

    <p:column headerText="Operações" style="width: 100px; text-align: center">
    <c:set var ="status" scope = "session"/>
            <p:button outcome = "/propriedade/CadastroPropriedade" icon="ui-icon-pencil" title="Editar" disabled ="#{pesquisaPropriedadeBean.inativo}">
                <f:param name="propriedade" value="#{propriedade.id}" />
            </p:button>
            <p:commandButton icon="ui-icon-bloquear" title="Alterar status do cadastro" oncomplete="PF('confirmacaoExclusao').show()" process="@this" update="frmPesquisa:confirmacaoExclusaoDialog">
                <f:setPropertyActionListener value="#{propriedade}" target="#{pesquisaPropriedadeBean.propriedadeSelecionada}"/>    
            </p:commandButton>
    </p:column>


    </p:dataTable>

        <p:confirmDialog header="Alterar status do cadastro"
            message="Tem certeza que deseja alterar o status do cadastro do usuário #{pesquisaUsuarioBean.usuarioSelecionado.nome}?"
            widgetVar="confirmacaoExclusao" id="confirmacaoExclusaoDialog">
            <p:button value="Não"
                onclick="PF('confirmacaoExclusao').hide(); return false;" />
            <p:commandButton value="Sim"
                oncomplete="PF('confirmacaoExclusao').hide();" action="#{pesquisaUsuarioBean.excluir}" process="@this" update="frmPesquisa:propriedadesTable"/>
        </p:confirmDialog>
</h:form>
</ui:define>

User Search.xhtml

<ui:define name="titulo">Pesquisar Usuarios</ui:define>

<ui:define name="corpo">
    <h:form id="frmPesquisa">
    <p:messages showDetail="false" showSummary="true" autoUpdate="true" />

    <h1>Pesquisa de usuários</h1>

    <p:toolbar style="margin-top: 20px">
        <p:toolbarGroup>
            <p:commandButton value="Pesquisar" action="#{pesquisaUsuarioBean.pesquisar}" update="@form" />
            <p:selectOneRadio id="id" value="#{pesquisaUsuarioBean.filtro.status}" >
                <f:selectItem itemLabel="Ativo" itemValue="Ativo" />
                <f:selectItem itemLabel="Inativo" itemValue="Inativo" />
            </p:selectOneRadio>
        </p:toolbarGroup>
        <p:toolbarGroup align ="right">
            <p:button value="Novo" outcome="/usuario/CadastroUsuario"/>
        </p:toolbarGroup>
    </p:toolbar>

    <p:panelGrid columns="2" id="painel" style="width: 100%; margin-top: 20px" columnClasses="rotulo, campo">
        <p:outputLabel value="Nome" for="nome"/>
        <p:inputText id="nome" size="60" maxlength="80"
        value="#{pesquisaUsuarioBean.filtro.nome}"/>
    </p:panelGrid>

    <p:dataTable id="usuariosTable"
            value="#{pesquisaUsuarioBean.usuariosFiltrados}" var="usuario"
            style="margin-top: 20px" emptyMessage="Nenhum usuario encontrado."
            rows="20" paginator="true" paginatorAlwaysVisible="false"
            paginatorPosition="bottom">

    <p:column headerText="Id" style="text-align: center; width: 100px">
            <h:outputText value="#{usuario.id}" />
    </p:column>

    <p:column headerText="Nome" style="text-align: center; width: 100px">
            <h:outputText value="#{usuario.nome}" />
    </p:column>

    <p:column headerText="RG" style="text-align: center; width: 100px">
            <h:outputText value="#{usuario.rg}" />
    </p:column>

    <p:column headerText="CPF" style="text-align: center; width: 100px">
            <h:outputText value="#{usuario.cpf}" />
    </p:column>

    <p:column headerText="Email" style="text-align: center; width: 100px">
            <h:outputText value="#{usuario.email}" />
    </p:column>

    <p:column headerText="Telefone" style="text-align: center; width: 100px">
            <h:outputText value="#{usuario.telefone}" />
    </p:column>

    <p:column headerText="Celular" style="text-align: center; width: 100px">
            <h:outputText value="#{usuario.celular}" />
    </p:column>

    <p:column headerText="Endereço" style="text-align: center; width: 100px">
            <h:outputText value="#{usuario.endereco}" />
    </p:column>

    <p:column headerText="Estado" style="text-align: center; width: 100px">
            <h:outputText value="#{usuario.estado}" />
    </p:column>

    <p:column headerText="Cidade" style="text-align: center; width: 100px">
            <h:outputText value="#{usuario.cidade}" />
    </p:column>

    <p:column headerText="CEP" style="text-align: center; width: 100px">
            <h:outputText value="#{usuario.cep}" />
    </p:column>

    <p:column headerText="Status" style="text-align: center; width: 100px">
            <h:outputText value="#{usuario.status}" />
    </p:column>

    <p:column headerText="Operações" style="width: 100px; text-align: center">
    <c:set var ="status" scope = "session"/>
            <p:button outcome = "/usuario/CadastroUsuario" icon="ui-icon-pencil" title="Editar" disabled ="#{pesquisaUsuarioBean.inativo}">
                <f:param name="usuario" value="#{usuario.id}" />
            </p:button>
            <p:commandButton icon="ui-icon-bloquear" title="Alterar status do cadastro" oncomplete="PF('confirmacaoExclusao').show()" process="@this" update="frmPesquisa:confirmacaoExclusaoDialog">
                <f:setPropertyActionListener value="#{usuario}" target="#{pesquisaUsuarioBean.usuarioSelecionado}"/>    
            </p:commandButton>
    </p:column>


    </p:dataTable>

        <p:confirmDialog header="Alterar status do cadastro"
            message="Tem certeza que deseja alterar o status do cadastro do usuário #{pesquisaUsuarioBean.usuarioSelecionado.nome}?"
            widgetVar="confirmacaoExclusao" id="confirmacaoExclusaoDialog">
            <p:button value="Não"
                onclick="PF('confirmacaoExclusao').hide(); return false;" />
            <p:commandButton value="Sim"
                oncomplete="PF('confirmacaoExclusao').hide();" action="#{pesquisaUsuarioBean.excluir}" process="@this" update="frmPesquisa:usuariosTable"/>
        </p:confirmDialog>
</h:form>
</ui:define>

Thanks in advance for any suggestions, opinions or advice.

    
asked by anonymous 31.08.2016 / 02:23

2 answers

1

JSF does not allow you to have identical id's, so what you need to do is change the one of the pages you've posted. I recommend you detail more the id, something like e ....

    
31.08.2016 / 02:33
0

Within the same form you are using twice same id="id". And this can not. Note from the other form that you mentioned that works, you do not have twice the same.

Below the snippets with the duplicate ID.

<p:toolbar style="margin-top: 20px">
        <p:toolbarGroup>
            <p:commandButton value="Pesquisar" action="#{pesquisaPropriedadeBean.pesquisar}" update="@form" />
            <p:selectOneRadio id="id" value="#{pesquisaPropriedadeBean.filtro.status}" >
                <f:selectItem itemLabel="Ativo" itemValue="Ativo" />
                <f:selectItem itemLabel="Inativo" itemValue="Inativo" />
            </p:selectOneRadio>
        </p:toolbarGroup>
        <p:toolbarGroup align ="right">
            <p:button value="Novo" outcome="/propriedade/CadastroPropriedade"/>
        </p:toolbarGroup>
    </p:toolbar>

    <p:panelGrid columns="2" id="painel" style="width: 100%; margin-top: 20px" columnClasses="rotulo, campo">
        <p:outputLabel value="id" for="id"/>
        <p:inputText id="id" size="60" maxlength="80"
        value="#{pesquisaPropriedadeBean.filtro.propriedadeId}"/>
    </p:panelGrid>
    
09.09.2016 / 15:39