Erro ao renderizar componete pela segunda vez

Pessoal mais uma vez recorro a ajuda de voces, entao teho uns campos que montam dinamicamente de acordo com o numero de imput que o usuario digitar,
ex: o cara digitou 3 eu com ajax renderizo 3 campos imput, bom ate ai esta blz o problema ocorre quando o usuario apaga o valor e digita 2 o sistema nao apaga os inputs gereado anteriormente e concatena com os outros 3 anteriores.

vou postar o codigo pra vcs darem um olhada se puderem de dar uma força…

abaixo metodo que cria os inputs

	public void montaNivelProjeto(){
		
		HtmlOutputLabel label 		= null;
		HtmlInputText htmlInputText = null;
		
		label 			= new HtmlOutputLabel();
		htmlInputText 	= new HtmlInputText();
		htmlInputText.clearInitialState();
		label.clearInitialState();
		try{
			
			//projeto = projetoBusiness.retonaProjetoNivel(projeto);
			int totalNivel = Integer.parseInt(projeto.getQtsnivel().trim());
			if(totalNivel != 0){
				
				for(int i = 0; i<totalNivel; i++){
					label = new HtmlOutputLabel();
					label.setStyle("font-weight:bold");
					label.setValue("Nivel "+arr.size());
					htmlInputText = new HtmlInputText();
					htmlInputText.setId("nivel"+arr.size());
					htmlInputText.setSize(50);
					//htmlInputText.setValue("");
					htmlInputText.setValueExpression("value", createValueExpression("#{projetoController.arr[" + (arr.size()) + "]}", String.class)); 
					arr.add("");
					this.getHtmlPanelGrid().getChildren().add(label);  
					this.getHtmlPanelGrid().getChildren().add(htmlInputText);

				}
				FacesContext.getCurrentInstance().getResponseComplete();
				new Projeto();
			}

		}catch(Exception e){
			e.getMessage();
		}
	}

		<h:outputLabel value="Qts nivel:" id="qtsnivel" title="informe o Nivel" />
						<h:inputText value="#{projetoController.projeto.qtsnivel}" size="20" >
							 <p:ajax event="blur" update="panel"  listener="#{projetoController.montaNivelProjeto()}" />  
						</h:inputText>
						
						<h:panelGrid columns="1" binding="#{projetoController.htmlPanelGrid}" id="htmlPanelGrid" />

fico no aguardo pessoal!!
abç

Eu não lembro de cabeça, mas deve ter algo que apague todos os componentes filhos do PanelGrid, algo como: this.getHtmlPanelGrid().getChildren().clear();
Ai, você poderia fazer isso antes de adicionar os novos componentes, dessa forma, ele sempre vai apagar para depois adicionar.

Você viu essa resposta no seu outro post

http://www.guj.com.br/java/290091-erro-ao-gerar-componente-dinamico

vlw fer.ferreira6 era isso mesmo muito obrigado!!! :thumbup: :thumbup: :thumbup: