A ID de componente já foi encontrada na visualização

12 respostas
R

Bom dia,
Estou recebendo essa mensagem de erro:

[java.lang.IllegalStateException: A ID de componente frmConsultaContratos:resultContratos:j_idt80 já foi encontrada na visualização.

No caso em questão, possuo uma tela para criar um novo registro, e outra para edição. Caso eu chame a tela de edição primeiro, e depois eu venha chamar a tela de criação, o erro é gerado.
create.xhtml

<ui:composition template="/pages/templates/template.xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

	<ui:define name="content">
		<p:panel header="#{bundle.header_cadastro_matricula}">
			<h:form id="form">
				<p:panelGrid columns="2">
					<ui:include src="form.xhtml" />
				</p:panelGrid>
				<br/>
				&lt;p:panelGrid columns="2"&gt;
					&lt;p:commandButton id="btnSalvar" action="#{matriculaBean.save}" value="#{bundle.btnSalvar}" ajax="false" icon="save"/&gt; 
					&lt;p:commandButton id="btnVoltar" action="#{matriculaBean.list}" value="#{bundle.btnCancelar}" ajax="false" immediate="true" icon="cancel"/&gt;
				&lt;/p:panelGrid&gt; 
			&lt;/h:form&gt;
		&lt;/p:panel&gt;
		&lt;ui:include src="consultaContrato.xhtml"/&gt;
	&lt;/ui:define&gt;
&lt;/ui:composition&gt;

edit.xhtml

&lt;ui:composition template="/pages/templates/template.xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"&gt;

	&lt;ui:define name="content"&gt;
		&lt;p:panel header="#{bundle.header_edicao_matricula}"&gt;
			&lt;h:form id="form"&gt;
				&lt;p:panelGrid columns="2"&gt;
					&lt;ui:include src="form.xhtml" /&gt;
				&lt;/p:panelGrid&gt;
				<br/>
				&lt;p:panelGrid columns="2"&gt;
					&lt;p:commandButton id="btnAtualizar" action="#{matriculaBean.update}" value="#{bundle.btnAtualizar}" ajax="false" icon="update"/&gt; 
					&lt;p:commandButton id="btnVoltar" action="#{matriculaBean.list}" value="#{bundle.btnCancelar}" ajax="false" immediate="true" icon="cancel"/&gt;
				&lt;/p:panelGrid&gt;
			&lt;/h:form&gt;
		&lt;/p:panel&gt;
		&lt;ui:include src="consultaContrato.xhtml"/&gt;
	&lt;/ui:define&gt;
&lt;/ui:composition&gt;

O componente que ele reclama é esse:
consultaContrato.xhtml

&lt;ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:comp="http://java.sun.com/jsf/composite/componentes"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"&gt;

	&lt;p:dialog widgetVar="consultaContrato" header="#{bundle.consultarContratos}" height="500" width="400"&gt;
	    &lt;h:form id="frmConsultaContratos"&gt;

			&lt;p:panel header="#{bundle.header_search_contrato}" &gt;
		        &lt;h:outputText value="#{bundle.tipoBusca}" /&gt;
		        &lt;p:selectOneRadio id="tipoBuscaContrato" value="#{matriculaBean.tipoBuscaContrato}"&gt;
		        	&lt;f:selectItem itemValue="todos" itemLabel="Todos"/&gt; 
		            &lt;f:selectItem itemValue="id" itemLabel="Código"/&gt;
		            &lt;f:selectItem itemValue="cpf" itemLabel="CPF"/&gt;
		        &lt;/p:selectOneRadio&gt;
				&lt;p:outputLabel for="searchContrato" value="#{bundle.search}" /&gt;&lt;p:spacer/&gt;
				&lt;p:inputText id="searchContrato" value="#{matriculaBean.thermSearchContrato}" /&gt;&lt;p:spacer/&gt;
				&lt;p:commandButton id="btnSearchContrato" value="#{bundle.btnSearch}" update="resultContratos" icon="search"/&gt;
			&lt;/p:panel&gt;

		    &lt;p:dataTable
		    	id="resultContratos"
		    	var="row" 
		    	value="#{matriculaBean.listContratos}"
		    	binding="#{matriculaBean.dataTableContratos}"
		        paginator="true" 
		        paginatorPosition="bottom"
		        rowsPerPageTemplate="5,10" &gt;
		        &lt;p:column&gt;  
		            &lt;f:facet name="header"&gt;  
		                &lt;h:outputText value="#{bundle.codigo}" /&gt;  
		            &lt;/f:facet&gt;  
		            &lt;h:outputText value="#{row.id}" /&gt;  
		        &lt;/p:column&gt;
		        &lt;p:column&gt;  
		            &lt;f:facet name="header"&gt;  
		                &lt;h:outputText value="#{bundle.cpf}" /&gt;  
		            &lt;/f:facet&gt;  
		            &lt;h:outputText value="#{row.cpf}" /&gt;  
		        &lt;/p:column&gt;
		         &lt;p:column style="width:32px"&gt;  
		            &lt;p:commandButton id="btnSelecionarContrato" value="selecionar" update=":form" icon="add"&gt;  
		                &lt;f:setPropertyActionListener value="#{row}" target="#{matriculaBean.matricula.contrato}" /&gt; 
		            &lt;/p:commandButton&gt;  
		        &lt;/p:column&gt;
		    &lt;/p:dataTable&gt;
	    &lt;/h:form&gt;   
	&lt;/p:dialog&gt;
&lt;/ui:composition&gt;

Desde já agradeço.

12 Respostas

D

Essa é facil… existem 2 ou mais componentes com o mesmo id, troca o id que funciona ok?

L

Cara coloque o form.xhtml no post também, fica mais tranquilo pra te ajudar. Já adiantando você deve estar repetindo o id de um componente em algum lugar da sua view ou a árvore de componentes não foi recriada.

R

Segue o form.xhtml

&lt;?xml version='1.0' encoding='ISO-8859-1' ?&gt;

&lt;ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"&gt;

	&lt;p:outputLabel for="buscaContrato"  value="#{bundle.buscaContrato}" /&gt;
	&lt;p:commandButton id="buscaContrato" value="#{bundle.btnSearch}" onclick="consultaContrato.show();" type="button" icon="search"/&gt; 

	&lt;p:outputLabel for="contrato" value="#{bundle.contrato}" /&gt;
	&lt;p:selectOneMenu id="contrato" value="#{matriculaBean.matricula.contrato.id}" requiredMessage="#{bundle.contrato_required}" required="true" style="width:300px;"&gt;
		&lt;f:selectItem itemValue="" itemLabel="Selecione" /&gt;
		&lt;f:selectItems value="#{matriculaBean.contratos}" /&gt;
	&lt;/p:selectOneMenu&gt;

	&lt;p:outputLabel for="aluno" value="#{bundle.aluno}" /&gt;
	&lt;p:selectOneMenu id="aluno" value="#{matriculaBean.matricula.aluno.id}" requiredMessage="#{bundle.aluno_required}" required="true" style="width:300px;"&gt;
		&lt;f:selectItem itemValue="" itemLabel="Selecione" /&gt;
		&lt;f:selectItems value="#{matriculaBean.alunos}" /&gt;
	&lt;/p:selectOneMenu&gt;

	&lt;p:outputLabel for="turma" value="#{bundle.turma}" /&gt;
	&lt;p:selectOneMenu id="turma" value="#{matriculaBean.matricula.turma.id}" requiredMessage="#{bundle.turma_required}" required="true" style="width:300px;"&gt;
		&lt;f:selectItem itemValue="" itemLabel="Selecione" /&gt;
		&lt;f:selectItems value="#{matriculaBean.turmas}" /&gt;
	&lt;/p:selectOneMenu&gt;
	
	&lt;p:outputLabel for="dataMatricula"  value="#{bundle.dataMatricula}" /&gt;
 	&lt;p:calendar id="dataMatricula" value="#{matriculaBean.matricula.dataMatricula}" pattern="dd/MM/yyyy" showButtonPanel="true" navigator="true" requiredMessage="#{bundle.dataMatricula_required}" required="true" style="width:70px;"&gt;
	    &lt;f:convertDateTime pattern="dd/MM/yyyy" locale="pt_br" timeZone="America/Sao_Paulo" /&gt;
	&lt;/p:calendar&gt;

	&lt;p:outputLabel for="isencaoTaxa" value="#{bundle.isencaoTaxa}" /&gt;
	&lt;p:selectOneMenu id="isencaoTaxa" value="#{matriculaBean.matricula.isencaoTaxa}" requiredMessage="#{bundle.isencaoTaxa_required}" required="true" style="width:100px;"&gt;
		&lt;f:selectItem itemValue="" itemLabel="Selecione" /&gt;
		&lt;f:selectItem itemValue="I" itemLabel="Isento" /&gt;
		&lt;f:selectItem itemValue="N" itemLabel="Não Isento" /&gt;
		&lt;p:ajax update="valorTaxa"&gt;&lt;/p:ajax&gt;
		&lt;p:ajax update="recebimentoTaxa"&gt;&lt;/p:ajax&gt;
	&lt;/p:selectOneMenu&gt;
	
	&lt;p:outputLabel for="valorTaxa" value="#{bundle.valorTaxa}" /&gt;
	&lt;p:inputText id="valorTaxa" value="#{matriculaBean.matricula.valorTaxa}" requiredMessage="#{bundle.valorTaxa_required}" required="#{matriculaBean.valorTaxaRequerida}" styleClass="dinheiro" &gt;
		&lt;f:convertNumber type="currency" pattern="#0.00"/&gt;
	&lt;/p:inputText&gt;
	
	&lt;p:outputLabel for="recebimentoTaxa" value="#{bundle.recebimentoTaxa}" /&gt;
	&lt;p:selectOneMenu id="recebimentoTaxa" value="#{matriculaBean.matricula.recebimentoTaxa}" requiredMessage="#{bundle.recebimentoTaxa_required}" required="#{matriculaBean.valorTaxaRequerida}" style="width:100px;"&gt;
		&lt;f:selectItem itemValue="N" itemLabel="Selecione" /&gt;
		&lt;f:selectItem itemValue="R" itemLabel="Recebido" /&gt;
		&lt;f:selectItem itemValue="N" itemLabel="Não Recebido" /&gt;
		&lt;p:ajax update="dataRecebimento"&gt;&lt;/p:ajax&gt;
	&lt;/p:selectOneMenu&gt;

	&lt;p:outputLabel for="dataRecebimento"  value="#{bundle.dataRecebimento}" /&gt;
 	&lt;p:calendar id="dataRecebimento" value="#{matriculaBean.matricula.dataRecebimento}" pattern="dd/MM/yyyy" showButtonPanel="true" navigator="true" requiredMessage="#{bundle.dataRecebimento_required}" required="#{matriculaBean.dataRecebimentoTaxaRequerida}" style="width:70px;"&gt;
	    &lt;f:convertDateTime pattern="dd/MM/yyyy" locale="pt_br" timeZone="America/Sao_Paulo" /&gt;
	&lt;/p:calendar&gt;

&lt;/ui:composition&gt;

Obrigado pela ajuda.

D

robinsonbsilva:
Segue o form.xhtml

&lt;?xml version='1.0' encoding='ISO-8859-1' ?&gt;

&lt;ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"&gt;

	&lt;p:outputLabel for="buscaContrato"  value="#{bundle.buscaContrato}" /&gt;
	&lt;p:commandButton id="buscaContrato" value="#{bundle.btnSearch}" onclick="consultaContrato.show();" type="button" icon="search"/&gt; 

	&lt;p:outputLabel for="contrato" value="#{bundle.contrato}" /&gt;
	&lt;p:selectOneMenu id="contrato" value="#{matriculaBean.matricula.contrato.id}" requiredMessage="#{bundle.contrato_required}" required="true" style="width:300px;"&gt;
		&lt;f:selectItem itemValue="" itemLabel="Selecione" /&gt;
		&lt;f:selectItems value="#{matriculaBean.contratos}" /&gt;
	&lt;/p:selectOneMenu&gt;

	&lt;p:outputLabel for="aluno" value="#{bundle.aluno}" /&gt;
	&lt;p:selectOneMenu id="aluno" value="#{matriculaBean.matricula.aluno.id}" requiredMessage="#{bundle.aluno_required}" required="true" style="width:300px;"&gt;
		&lt;f:selectItem itemValue="" itemLabel="Selecione" /&gt;
		&lt;f:selectItems value="#{matriculaBean.alunos}" /&gt;
	&lt;/p:selectOneMenu&gt;

	&lt;p:outputLabel for="turma" value="#{bundle.turma}" /&gt;
	&lt;p:selectOneMenu id="turma" value="#{matriculaBean.matricula.turma.id}" requiredMessage="#{bundle.turma_required}" required="true" style="width:300px;"&gt;
		&lt;f:selectItem itemValue="" itemLabel="Selecione" /&gt;
		&lt;f:selectItems value="#{matriculaBean.turmas}" /&gt;
	&lt;/p:selectOneMenu&gt;
	
	&lt;p:outputLabel for="dataMatricula"  value="#{bundle.dataMatricula}" /&gt;
 	&lt;p:calendar id="dataMatricula" value="#{matriculaBean.matricula.dataMatricula}" pattern="dd/MM/yyyy" showButtonPanel="true" navigator="true" requiredMessage="#{bundle.dataMatricula_required}" required="true" style="width:70px;"&gt;
	    &lt;f:convertDateTime pattern="dd/MM/yyyy" locale="pt_br" timeZone="America/Sao_Paulo" /&gt;
	&lt;/p:calendar&gt;

	&lt;p:outputLabel for="isencaoTaxa" value="#{bundle.isencaoTaxa}" /&gt;
	&lt;p:selectOneMenu id="isencaoTaxa" value="#{matriculaBean.matricula.isencaoTaxa}" requiredMessage="#{bundle.isencaoTaxa_required}" required="true" style="width:100px;"&gt;
		&lt;f:selectItem itemValue="" itemLabel="Selecione" /&gt;
		&lt;f:selectItem itemValue="I" itemLabel="Isento" /&gt;
		&lt;f:selectItem itemValue="N" itemLabel="Não Isento" /&gt;
		&lt;p:ajax update="valorTaxa"&gt;&lt;/p:ajax&gt;
		&lt;p:ajax update="recebimentoTaxa"&gt;&lt;/p:ajax&gt;
	&lt;/p:selectOneMenu&gt;
	
	&lt;p:outputLabel for="valorTaxa" value="#{bundle.valorTaxa}" /&gt;
	&lt;p:inputText id="valorTaxa" value="#{matriculaBean.matricula.valorTaxa}" requiredMessage="#{bundle.valorTaxa_required}" required="#{matriculaBean.valorTaxaRequerida}" styleClass="dinheiro" &gt;
		&lt;f:convertNumber type="currency" pattern="#0.00"/&gt;
	&lt;/p:inputText&gt;
	
	&lt;p:outputLabel for="recebimentoTaxa" value="#{bundle.recebimentoTaxa}" /&gt;
	&lt;p:selectOneMenu id="recebimentoTaxa" value="#{matriculaBean.matricula.recebimentoTaxa}" requiredMessage="#{bundle.recebimentoTaxa_required}" required="#{matriculaBean.valorTaxaRequerida}" style="width:100px;"&gt;
		&lt;f:selectItem itemValue="N" itemLabel="Selecione" /&gt;
		&lt;f:selectItem itemValue="R" itemLabel="Recebido" /&gt;
		&lt;f:selectItem itemValue="N" itemLabel="Não Recebido" /&gt;
		&lt;p:ajax update="dataRecebimento"&gt;&lt;/p:ajax&gt;
	&lt;/p:selectOneMenu&gt;

	&lt;p:outputLabel for="dataRecebimento"  value="#{bundle.dataRecebimento}" /&gt;
 	&lt;p:calendar id="dataRecebimento" value="#{matriculaBean.matricula.dataRecebimento}" pattern="dd/MM/yyyy" showButtonPanel="true" navigator="true" requiredMessage="#{bundle.dataRecebimento_required}" required="#{matriculaBean.dataRecebimentoTaxaRequerida}" style="width:70px;"&gt;
	    &lt;f:convertDateTime pattern="dd/MM/yyyy" locale="pt_br" timeZone="America/Sao_Paulo" /&gt;
	&lt;/p:calendar&gt;

&lt;/ui:composition&gt;

Obrigado pela ajuda.

quando ele disse para vc postar o form… acredito que ele dizia para vc postar, aonde vc esta fazendo o <ui:include/> destes composition…

R

Bom dia, pior que eu não havia entendido desta forma!!

Acima tem todas paginas relacionadas, só não postei o template.xhtml

Valeu pela ajuda.

D

se voce alterar na tela de consultaContrato.xhtml esse trecho …

<p:dataTable id="resultContratos"

para algo do genero

<p:dataTable id="resultadoContratos"

o erro para de ser registrado?

R

Continua dando o erro.

javax.servlet.ServletException: A ID de componente frmConsultaContratos:resultoContratos:j_idt83 j&#65533; foi encontrada na visualiza&#65533;&#65533;o.

Será que tem como eu limpar a arvore de componentes referente a uma tela?

Como esse dialog é chamado tanto pela tela de criação como pela tela de edição, será que quando alterno entre essas telas, esse dialog fica “cacheado” ou algo do tipo??

D

no form frmConsultaContratos coloca prependId=“false” e me diz o que acontece…

então… vc costuma dar o clean no servidor sempre que da stop nele? ou ctrl f5 na tela? pode ser cache… tem algo muito errado só em alterar o nome já deveria funcionar

R

usando o prependId também da o erro.

D

olhei aqui e vi que tanto na tela de create e edit vc faz o include desse form…

se vc remover no edit.xhtml o trecho <ui:include src=“consultaContrato.xhtml”/> ele vai funcionar?

outra coisa que quero saber ambas as telas create.xhtml e edit.xhtml estão na mesma tela? ou sao paginas separadas?

R

Então, removendo de alguma delas funciona normal, só o “dialog” não aparece na “pagina onde removi”.

As páginas são unicas, ou seja, uma para cada operação, a unica coisa em comum entre elas é que ambas usam o “form.xhtml” e tem o include do dialog.

D

e se vc mover o include para o xhtml pai? assim vc poderia chamar em ambas as telas…

o problema é esse… vc ta colocando o mesmo componente 2 vezes na mesma visualização, então vc deve mover esse dialog para um html comum entre eles… ou criar um xhtml intermediario e colocar só ele… isso já resolveria o problema… pois ambas as telas chamaram o mesmo componente de forma sepada, invez de chamar ele apenas uma vez…

o form.xhtml é quem chama o create.xhtml e o edit.xhtml? se for ele coloca o <ui:include src=“consultaContrato.xhtml”/> nele…

Criado 23 de janeiro de 2013
Ultima resposta 24 de jan. de 2013
Respostas 12
Participantes 3