Well, I have a delete button and when this button is clicked the item is removed from collection and the form should be clean.
So, this is my button:
<h:panelGroup layout="block" id="divTeste">
<div class="btn-group" role="group" aria-label="..."
style="margin-bottom: 10px">
<h:commandLink actionListener="#{cursoMB.deletarTeste()}"
styleClass="btn btn-default">
<f:ajax execute="@this" render="divTeste, divTestes" />
<i class="fa fa-trash fa-fw"></i>
</h:commandLink>
</div>
<div class="form-group">
<label>Descrição</label>
<h:inputText value="#{cursoMB.teste.descricao}"
disabled="#{cursoMB.teste == null}" styleClass="form-control" />
</div>
</h:panelGroup>
THis is the action in ManagedBean:
public void deletarTeste(){
if (teste != null){
bean.getTestes().remove(teste);
teste = null;
addInfoMessage("Teste deletado com sucesso");
}else{
addErrorMessage("Selecione um teste antes de deletar");
}
}
The XHTML uses the variable teste
, when I call deletarTeste()
method this variable is updated to NULL, and I hope that "form-group" be clean, but nothing happens.
IMportant Note:
If I use just 1 id
to render, like this:
<f:ajax execute="@this" render="divTeste" />
Instead of:
<f:ajax execute="@this" render="divTeste, divTestes" />
Everything works, but I need update the 2 components.