How to clean a p: form messages by Bean?

2

I have the following situation: 1. I have an xhtml with <p:tabView> with id="tab"; 2. In this tabView I have 3 tabs and each one with its forms and <p:messages> with their respective id;

What is the problem? In tab 1 I have the main record, in the others are children of this record and I 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'm using the "renderer" attribute.

When I enter the record in the main tab and the ID is generated, I update the tabView (id = tab) and in the return of the method I inform the user that the record was saved.

The problem! When I update the tab so that the tabs are displayed, the <p:messages> of each is also updated with the main tab message.

How do I clean a component through the id through the Bean?

All help is welcome!

Bean Fragment

        // 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 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>
    
asked by anonymous 07.11.2015 / 23:03

0 answers