Repeated ID with facelets

Asked

Viewed 184 times

1

The problem is that in a project I use facelets is telling me that there is a component with the repeated ID. Although I scanned the code behind the repeated ID, I couldn’t find it, so I believe the error is related to incorrect use of facelets. I would like to know from you how I can solve. Follow the codes below:

Template code:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

    <h:head>
        <f:facet name="first">
            <meta charset="UTF-8" />
            <meta name="viewport" content="width=device-width, initial-scale=1" />
        </f:facet>

        <title>AudSped</title>

        <h:outputStylesheet library="bluegestao" name="styles/custom.css" />
        <h:outputStylesheet library="bluegestao" name="styles/layout.css" />
        <h:outputStylesheet library="bluegestao" name="styles/components.css" />

        <h:outputScript target="body" library="primefaces" name="jquery/jquery.js" />
        <h:outputScript target="body" library="bluegestao" name="javascripts/app.js" />
    </h:head>

    <h:body>

        <header class="aw-topbar">
            <h:graphicImage library="bluegestao" name="images/logo.png" />

            <a href="#" class="aw-toggle  js-toggle"><i class="fa  fa-bars"></i></a>
        </header>

        <aside class="aw-sidebar  js-sidebar">

            <nav class="aw-menu">
                <h:form>
                    <p:panelMenu style="width:205px">
                        <p:submenu label="Principal" expanded="true">
                            <!--links-->
                        </p:submenu>
                        <p:submenu label="Registros da EFD" >
                            <p:submenu label="Bloco 0">
                                <p:menuitem value="Registro 0000" outcome="/faces/blocosfiscais/ManutencaoRegistros.xhtml?nomeRegistro=Reg0000" includeViewParams="true"/>
                                <!--links-->
                            </p:submenu>
                            <p:submenu label="Bloco 1">
                                <!--links-->
                            </p:submenu>
                            <p:submenu label="Bloco 9">
                                <!--links-->
                            <p:submenu label="Bloco C">
                                <!--links-->
                            </p:submenu>
                            <p:submenu label="Bloco D">
                                <!--links-->
                            </p:submenu>
                            <p:submenu label="Bloco E">
                                <!--links-->
                            </p:submenu>
                            <p:submenu label="Bloco G">
                                <!--links-->
                            </p:submenu>
                            <p:submenu label="Bloco H">
                                <!--links-->
                            </p:submenu>
                            <p:submenu label="Bloco K">
                                <!--links-->
                            </p:submenu>
                        </p:submenu>
                        <p:separator />
                        <p:submenu label="Navigations" >
                            <p:submenu label="Links" icon="ui-icon-extlink">
                                <p:submenu label="PrimeFaces" icon="ui-icon-heart">
                                    <p:menuitem value="Home" url="http://www.primefaces.org" icon="ui-icon-home" />
                                    <p:menuitem value="Docs" url="http://www.primefaces.org/documentation" icon="ui-icon-document" />
                                    <p:menuitem value="Download" url="http://www.primefaces.org/downloads" icon="ui-icon-arrowthick-1-s" />
                                    <p:menuitem value="Support" url="http://www.primefaces.org/support" icon="ui-icon-wrench" />
                                </p:submenu>
                            </p:submenu>
                            <p:menuitem value="Mobile" icon="ui-icon-signal" />
                        </p:submenu>
                    </p:panelMenu>
                </h:form>
            </nav>

        </aside>

        <section class="aw-content  js-content">
            <p:growl id="growl" sticky="true"/>
            <ui:insert id="conteudo" name="content" />
        </section>

    </h:body>

</html>

The Record Keeping Page:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html>

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/WEB-INF/templates/Layout.xhtml">

    <ui:define name="content"> 
        <h:form>

             <h1 class="aw-page-title">Manutenção de Registros</h1>
             <br/>
            <p:toolbar>
                <p:toolbarGroup align="left">
                    <p:commandButton value="Adicionar" icon="fa fa-plus" action="#{manutencaoRegistrosBean.adicionar}"/>
                    <p:commandButton value="Editar" icon="fa fa-pencil" action="#{manutencaoRegistrosBean.editar}"/>
                </p:toolbarGroup>
                <p:toolbarGroup align="right">
                    <p:commandButton value="Deletar" icon="fa fa-trash" action="#{manutencaoRegistrosBean.deletar}" style="background-color: #FF0000; border-color: #FF0000"/>
                </p:toolbarGroup>
            </p:toolbar>
        </h:form>
        <ui:include src="#{manutencaoRegistrosBean.bloco}/#{manutencaoRegistrosBean.registro}/List.xhtml"/>
    </ui:define>

</ui:composition>

Page code called:

<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/WEB-INF/templates/Layout.xhtml">

        <h1 class="aw-page-title">Registro 0000</h1>

        <h:form id="Reg0000ListForm">
            <p:panel header="#{bundle.ListReg0000Title}">
                <p:dataTable id="datalist" value="#{reg0000Controller.items}" var="item"
                             selectionMode="single" selection="#{reg0000Controller.selected}"
                             paginator="true"
                             rowKey="#{item.id}"
                             rows="30"
                             rowsPerPageTemplate="10,20,30,40,50"
                             reflow="true"
                             tableStyle="table-layout: auto">
                    <p:ajax event="rowSelect"   update="createButton viewButton editButton deleteButton"/>
                    <p:ajax event="rowUnselect" update="createButton viewButton editButton deleteButton"/>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListReg0000Title_id}"/>
                        </f:facet>
                        <h:outputText value="#{item.id}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListReg0000Title_idPai}"/>
                        </f:facet>
                        <h:outputText value="#{item.idPai}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListReg0000Title_linha}"/>
                        </f:facet>
                        <h:outputText value="#{item.linha}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListReg0000Title_hash}"/>
                        </f:facet>
                        <h:outputText value="#{item.hash}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListReg0000Title_reg}"/>
                        </f:facet>
                        <h:outputText value="#{item.reg}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListReg0000Title_codVer}"/>
                        </f:facet>
                        <h:outputText value="#{item.codVer}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListReg0000Title_codFin}"/>
                        </f:facet>
                        <h:outputText value="#{item.codFin}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListReg0000Title_dtIni}"/>
                        </f:facet>
                        <h:outputText value="#{item.dtIni}">
                            <f:convertDateTime pattern="dd/MM/yyyy" />
                        </h:outputText>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListReg0000Title_dtFin}"/>
                        </f:facet>
                        <h:outputText value="#{item.dtFin}">
                            <f:convertDateTime pattern="dd/MM/yyyy" />
                        </h:outputText>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListReg0000Title_nome}"/>
                        </f:facet>
                        <h:outputText value="#{item.nome}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListReg0000Title_cnpj}"/>
                        </f:facet>
                        <h:outputText value="#{item.cnpj}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListReg0000Title_cpf}"/>
                        </f:facet>
                        <h:outputText value="#{item.cpf}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListReg0000Title_uf}"/>
                        </f:facet>
                        <h:outputText value="#{item.uf}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListReg0000Title_ie}"/>
                        </f:facet>
                        <h:outputText value="#{item.ie}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListReg0000Title_codMun}"/>
                        </f:facet>
                        <h:outputText value="#{item.codMun}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListReg0000Title_im}"/>
                        </f:facet>
                        <h:outputText value="#{item.im}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListReg0000Title_suframa}"/>
                        </f:facet>
                        <h:outputText value="#{item.suframa}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListReg0000Title_indPerfil}"/>
                        </f:facet>
                        <h:outputText value="#{item.indPerfil}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListReg0000Title_indAtiv}"/>
                        </f:facet>
                        <h:outputText value="#{item.indAtiv}"/>
                    </p:column>
                    <f:facet name="footer">
                        <p:commandButton id="createButton" icon="ui-icon-plus"   value="#{bundle.Create}" actionListener="#{reg0000Controller.prepareCreate}" update=":Reg0000CreateForm" oncomplete="PF('Reg0000CreateDialog').show()"/>
                        <p:commandButton id="viewButton"   icon="ui-icon-search" value="#{bundle.View}" update=":Reg0000ViewForm" oncomplete="PF('Reg0000ViewDialog').show()" disabled="#{empty reg0000Controller.selected}"/>
                        <p:commandButton id="editButton"   icon="ui-icon-pencil" value="#{bundle.Edit}" update=":Reg0000EditForm" oncomplete="PF('Reg0000EditDialog').show()" disabled="#{empty reg0000Controller.selected}"/>
                        <p:commandButton id="deleteButton" icon="ui-icon-trash"  value="#{bundle.Delete}" actionListener="#{reg0000Controller.destroy}" update=":growl,datalist" disabled="#{empty reg0000Controller.selected}"/>
                    </f:facet>
                </p:dataTable>
            </p:panel>
        </h:form>
        <ui:include src="Create.xhtml"/>
        <ui:include src="Edit.xhtml"/>
        <ui:include src="View.xhtml"/>

</ui:composition>

The error happens when I require the record keeping page which should include the other (List.xhtml) but shows me the following error:

08:48:59,560 FATAL [javax.enterprise.resource.webcontainer.jsf.context] (default task-52) JSF1073: java.lang.IllegalStateException obtido durante o processamento de RENDER_RESPONSE 6: UIComponent-ClientId=, Message=A ID de componente growl já foi encontrada na visualização.
08:48:59,560 FATAL [javax.enterprise.resource.webcontainer.jsf.context] (default task-52) A ID de componente growl já foi encontrada na visualização.: java.lang.IllegalStateException: A ID de componente growl já foi encontrada na visualização.

1 answer

0


First, your growl must be inside a <h:form>

Suggestion is that you put one growl specific to each page

You are repeating the Growl component in your template:

<section class="aw-content  js-content">
   <p:growl id="growl" sticky="true"/> 
   <!-- Esse elemento está sendo repetido tem todos templates -->
</section>

That means you’re repeating the growl on all your pages that use the template.

When placing a page inside another one that already contains the template, you should not call the template on ui:composition of that sub-page, only on the main page.

Browser other questions tagged

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