title: Primefaces dialog is rendering twice
body: <p>I've created an ui:component to use like a popup, so I can create a lot of popups using the standard of this template.
  The component is just a popup with two buttons (cancel and submit) and a content that can be overriden, like you can see here:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:c="http://java.sun.com/jsp/jstl/core"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:p="http://primefaces.prime.com.tr/ui"&gt;
  &lt;ui:component&gt;
  &lt;p:dialog widgetVar="#{idPopup}" id="#{idPopup}" modal="#{popup.modal}"
      draggable="#{popup.modal}"
      rendered="#{popup.visivel}" visible="#{popup.visivel}"
      closeOnEscape="false" closable="false" header="#{titulo}"
      resizable="false" styleClass="autoWidthDialog" showEffect="fade"
      hideEffect="fade"&gt;
      &lt;h:panelGroup style="width:100%"&gt;
          &lt;p:focus /&gt;
          &lt;ui:insert name="conteudo"&gt;Nenhum conteúdo definido!&lt;/ui:insert&gt;
          &lt;h:panelGrid id="#{idPopup}PainelMensagens" style="width:100%"&gt;
              &lt;p:messages /&gt;
          &lt;/h:panelGrid&gt;
          &lt;ui:insert name="barraDeBotoes"&gt;
              &lt;h:panelGroup layout="block" style="width:100%"&gt;
                  &lt;p:commandButton value="CANCELAR" immediate="true" update="@form"
                      style="float:right" action="#{controladorPopup.fechar}"
                      onclick="#{idPopup}.hide();" /&gt;
                  &lt;p:commandButton value="OK" style="float:right"
                      update="@form formAlerta"
                      action="#{controladorPopup.submit}"
                      process="@form" /&gt;
              &lt;/h:panelGroup&gt;
          &lt;/ui:insert&gt;
      &lt;/h:panelGroup&gt;
  &lt;/p:dialog&gt;
  &lt;/ui:component&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The problem happen when I try to submit the form without filling the required fields. The correct behavior is just show again the popup with messages, but the dialog is rendered twice, one with the messages and one without the messages.
  You can see this behavior here:</p>
  
  <p><img src="https://i.stack.imgur.com/DCgjW.png" alt="twice rendering"></p>
  
  <p>this is one use of this template:</p>
  
  <pre><code>&lt;ui:composition template="../templates/popupSubmit.xhtml"&gt;
  &lt;ui:param name="titulo" value="Buscar pessoa" /&gt;
  &lt;ui:param name="popup" value="#{modeloPopupBuscaPessoa}" /&gt;
  &lt;ui:param name="controladorPopup"
      value="#{controladorPopupBuscaPessoa}" /&gt;
  &lt;ui:define name="conteudo"&gt;
      &lt;h:panelGroup&gt;
          &lt;h:panelGrid columns="2"&gt;
              &lt;h:outputLabel value="Tipo de cadastro:" style="float:none" /&gt;
              &lt;h:selectOneMenu value="#{controladorSugestaoPessoa.tipoCadastro}"
                  immediate="true"&gt;
                  &lt;f:selectItems value="#{carregadorTipoCadastro.itens}" /&gt;
                  &lt;f:ajax event="change" immediate="true" /&gt;
              &lt;/h:selectOneMenu&gt;
          &lt;/h:panelGrid&gt;
          &lt;h:outputText value="Buscar por:" /&gt;
          &lt;h:selectOneRadio value="#{controladorSugestaoPessoa.tipoBusca}"
              immediate="true"&gt;
              &lt;f:selectItems value="#{carregadorTipoBuscaPessoa.itens}" /&gt;
              &lt;f:ajax event="change" immediate="true" /&gt;
          &lt;/h:selectOneRadio&gt;
          &lt;p:autoComplete value="#{modeloPopupBuscaPessoa.itemSelecionado}"
              forceSelection="true" maxResults="10" queryDelay="500" 
              completeMethod="#{controladorSugestaoPessoa.atualizarSugestoes}"
              var="pessoa" itemLabel="#{pessoa.label}" itemValue="#{pessoa}"
              converter="#{conversorSelectItem}" /&gt;
      &lt;/h:panelGroup&gt;
  &lt;/ui:define&gt;
  &lt;/ui:composition&gt;
  </code></pre>
  
  <p>And these are some use:</p>
  
  <pre><code>&lt;h:form id="cadastroPessoa"&gt;
      &lt;ui:include
          src="resources/components/popups/modulo_cadastro/popupNovoCadastroPessoa.xhtml"&gt;
          &lt;ui:param name="idPopup" value="popupNovoCadastroPessoa" /&gt;
      &lt;/ui:include&gt;
      &lt;ui:include
          src="resources/components/popups/modulo_cadastro/popupCadastroPessoa.xhtml"&gt;
          &lt;ui:param name="idPopup" value="popupEdicaoCadastroPessoa" /&gt;
      &lt;/ui:include&gt;
      &lt;ui:include
          src="resources/components/popups/modulo_cadastro/popupBuscaPessoa.xhtml"&gt;
          &lt;ui:param name="idPopup" value="popupBuscaCadastroPessoa" /&gt;
      &lt;/ui:include&gt;
  &lt;/h:form&gt;
  
  &lt;h:form id="cadastroProduto"&gt;
      &lt;ui:include
          src="resources/components/popups/modulo_cadastro/popupCadastroProduto.xhtml"&gt;
          &lt;ui:param name="idPopup" value="popupNovoCadastroProduto" /&gt;
      &lt;/ui:include&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>Could someone tell me why this is happening??</p>