2
I have the following situation:
1. I have a xhtml with <p:tabView>
with id="tab";
2. In this tabview I have 3 tabs and each one with its photons and <p:messages>
with their respective id;
What’s the matter? In tab 1 I have the main record, the others are children of this record and need to display only when a code is generated. So far so good, I have an attribute in the Boolean bean that checks if the ID is different from "0" and in the tabs I am using the attribute "Renderer".
When I enter the record in the main tab and the ID is generated, I update the tabview (id = tab) and on the return of the method inform the user that the record has been saved.
The problem!
When I update the tab so that the tabs are displayed, the <p:messages>
each one is also updated with the message from the main tab.
There’s a way I can clear a component by id through the bean?
All help will be welcome!
Fragment of the Bean
// define mensagem de sucesso
messages.info("Atividade salva com sucesso!");
// atualiza componentes na view
RequestContext.getCurrentInstance().reset(":frmAtividade:tab:frmEnvolvidos:msg-envolvidos");
RequestContext.getCurrentInstance().update(Arrays.asList("frmAtividade:tab:aba1:msg-principal","frmAtividade:pnl-cabecalho",
"frmAtividade:painel-responsavel","frmAtividade:tab"));
Fragments of the xhtml
<p:tab title="Envolvidos" id="aba-envolvidos" rendered="#{cadastroAtividadeBean.abaEnvolvidos}" disabled="#{!cadastroAtividadeBean.abasAtivas}">
<h:form id="frmEnvolvidos" >
<p:messages id="msg-envolvidos" />
<p:toolbar id="toolbar-principal">
<f:facet name="left">
<p:commandLink value="Cancelar" title="Cancelar"
action="#{cadastroAtividadeBean.cancelar()}"
styleClass="btn btn-dark"
immediate="true">
</p:commandLink>
</f:facet>
</p:toolbar>
Have you tried using
RequestContext.getCurrentInstance().reset("idDoComponente");
?– Weslley Tavares
Weslley I did the implementation and it didn’t work. See I reset after updating the other components. There is precedence in these calls?
– Marcelo Gomes
You can post your code?
– Weslley Tavares
I supplemented the question with bean fragments and xhtml
– Marcelo Gomes
Reset at the end of your method.
– Weslley Tavares
I put and yet the message continues to be displayed.
– Marcelo Gomes