Hide <p:messages> by clicking on embedded Submit button
<p>I need to close my messages dialog without using the built in close button. An embedded "CLOSE" button within the message needs to fire of a method in the backing bean, and when finished, the message box should close.</p>

<p>My code calls the actionListener, but I am unable to clear the message box on submission. In my last attempt, I tried to do it from the Backing Bean, but the box refuses to go away.</p>

<p>Below is sample test code.</p>

<pre><code>    &lt;h:form id="form1"&gt;
        &lt;h:panelGroup id="myPanel" layout="block" class="scap-block"
            rendered="#{not chartView.acknowledged}"&gt;
            &lt;p:messages id="banner" showSummary="true" showDetail="false"
                autoUpdate="true" closable="true" escape="false"&gt;
            &lt;/p:messages&gt;
            &lt;p:commandButton widgetVar="acceptContinue"
                style-class="align right" value="Close" type="ajax"
                actionListener="#{chartView.close}" render="myPanel" /&gt;
        &lt;/h:panelGroup&gt;
    &lt;/h:form&gt;
    &lt;f:event type="preRenderView" listener="#{chartView.init}" /&gt;
    &lt;/h:body&gt;
</code></pre>

<p>Bean:</p>

<pre><code>@ManagedBean(name = "chartView")
@ViewScoped
public class ChartView implements Serializable {

private boolean acknowledged = false;

public void init() {

    log.debug("preRender init() method");

    String detail = "PrimeFaces Rocks."
            +"&lt;button aria-disabled='false'  id='form1:j_idt5' name='form1:j_idt5' "
            + "class='ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only' "
            + "onclick='PrimeFaces.ab({s:&amp;quot;form1:j_idt5&amp;quot;});return false;' type='ajax'&gt;"
            + "&lt;span class='ui-button-text ui-c'&gt;Close&lt;/span&gt;&lt;/button&gt;";

    FacesContext.getCurrentInstance().addMessage("banner",
            new FacesMessage(FacesMessage.SEVERITY_ERROR, detail, "Some details"));
}


public void close() {
    System.err.println("Acknowledged");
    log.debug("###Close called###");
    setAcknowledged(true);
    RequestContext context = RequestContext.getCurrentInstance();
    context.update(":form1:myParent");
    }
</code></pre>

<p><a href="https://i.stack.imgur.com/afn0Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/afn0Q.png" alt="Screenshot of page"></a></p>