title: Open Primefaces dialog and Process Full JSF Lifecycle
body: <p>I'm doing a <code>&lt;p:commandLink value="#{bundle['registered.home.search.TEXT']}" onclick="webSearchDlg.show();"&gt;&lt;/p:commandLink&gt;</code> in order to show the below dialog.  The p:outputPanel id="searchPnl" always renders after its initially rendered.  It never disappears even though the dialogs <code>closeListener="#{dreamSearch.close}" onCloseUpdate="searchTxtPnl,searchPnl"</code> is executed.  When I open the dialog after closing it, the panelGrid appears and the <code>&lt;p:inputText id="searchText"&gt;</code> displays the previous value that I tried to clear in the below closeListener method.  Any ideas...code below...</p>
  
  <pre><code>&lt;p:dialog header="#{bundle['dreamSearch.HEADER']}"
      widgetVar="webSearchDlg" modal="true" styleClass="dialog dialog2"
      draggable="false" resizable="false" showEffect="fade"
      hideEffect="fade" closeListener="#{dreamSearch.close}" onCloseUpdate="searchTxtPnl,searchPnl"&gt;
      &lt;div class="dialog-top-reg"&gt;&lt;/div&gt;
      &lt;div class="dialog-middle-reg"&gt;
          &lt;div class="close-button"&gt;
              &lt;h:form&gt;
                  &lt;p:commandButton onclick="webSearchDlg.hide()" /&gt;
              &lt;/h:form&gt;
          &lt;/div&gt;
          &lt;h:form class="dialog-content dialog-content2"
              binding="#{dreamSearch.dreamSearchFrm}"&gt;
              &lt;h1 class="dream-search"&gt;
                  &lt;h:outputText value="#{bundle['dreamSearch.HEADER']}" /&gt;
              &lt;/h1&gt;
              &lt;p class="dream-search"&gt;
                  &lt;h:outputText value="#{bundle['dreamSearch.SUBHEADER']}" /&gt;
              &lt;/p&gt;
              &lt;div class="dream-search-wrap"&gt;
                  &lt;fieldset&gt;
                  &lt;p:outputPanel id="searchTxtPnl"&gt;
                      &lt;p:inputText id="searchText" value="#{dreamSearchBean.searchText}"/&gt;
                  &lt;/p:outputPanel&gt;
                      &lt;p:commandButton styleClass="form-btn1"
                          value="#{bundle['dreamSearch.search.button.TEXT']}" onclick="webImageSearch()"/&gt;
                  &lt;/fieldset&gt;
              &lt;/div&gt;
              &lt;p:remoteCommand name="webImageSearch" process="searchText, @this" actionListener="#{dreamSearch.search}" update="searchPnl"/&gt;
              &lt;p:outputPanel id="searchPnl" styleClass="data-grid-wrap"&gt;
                  &lt;h:outputText value="#{bundle['dreamSearch.imageResults.TEXT']}" rendered="#{dreamSearchBean.shouldRender}"/&gt;
                  &lt;p:dataGrid var="img" value="#{dreamSearchBean.images}" columns="5"
                      rows="10" paginator="true" effect="true"
                      paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                      rowsPerPageTemplate="10,15,20" paginatorPosition="bottom" rendered="#{dreamSearchBean.shouldRender}"&gt;
                      &lt;p:column&gt;
                          &lt;h:panelGrid columns="1" style="width:100%"&gt;
                              &lt;p:graphicImage value="#{img}" width="40" height="50" /&gt;
                          &lt;/h:panelGrid&gt;
                      &lt;/p:column&gt;
                  &lt;/p:dataGrid&gt;
              &lt;/p:outputPanel&gt;
          &lt;/h:form&gt;
      &lt;/div&gt;
      &lt;div class="dialog-bottom-reg"&gt;&lt;/div&gt;
  &lt;/p:dialog&gt;
  
  
  @Named
  @Scope("request")
  public class DreamSearch extends BaseAction {
      @Inject
      DreamService dreamService;
      @Inject
      ImageSearchService flickrSearchImpl;
      @Inject
      private DreamSearchBean dreamSearchBean;
      private UIForm dreamSearchFrm;
  
  
      public void init(){
          if (!FacesUtils.isPostback()) {
              dreamSearchBean.setShouldRender(false);
              dreamSearchBean.setSearchText(null);
          }
      }
  
      public void setDreamSearchFrm(UIForm dreamSearchFrm) {
          this.dreamSearchFrm = dreamSearchFrm;
          init();
      }
  
      public void search(ActionEvent e){
          try {
  
              if(dreamSearchBean.getSearchText() != null &amp;&amp; !dreamSearchBean.getSearchText().isEmpty()){
                  List&lt;String&gt; searchResults = flickrSearchImpl.searchByKeyWord(dreamSearchBean.getSearchText());
                  dreamSearchBean.setImages(searchResults);
                  dreamSearchBean.setShouldRender(true);
              }else{
                  dreamSearchBean.setShouldRender(false);
              }
  
          } catch (Exception e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
          }
  
      }
  
      public void close(CloseEvent e){
          dreamSearchBean.setShouldRender(false);
          dreamSearchBean.setSearchText(null);
      }
  
      public UIForm getDreamSearchFrm() {
          return dreamSearchFrm;
      }
  }
  
      @Named
  @Scope("session")
  public class DreamSearchBean extends BaseSessionBean {
      private List&lt;String&gt; images;
      private String searchText;
      private boolean shouldRender;
  
  
  
      public String getSearchText() {
          return searchText;
      }
  
      public void setSearchText(String searchText) {
          this.searchText = searchText;
      }
  
      public boolean isShouldRender() {
          return shouldRender;
      }
  
      public void setShouldRender(boolean shouldRender) {
          this.shouldRender = shouldRender;
      }
  
      public List&lt;String&gt; getImages() {
          return images;
      }
  
      public void setImages(List&lt;String&gt; images) {
          this.images = images;
      }
  
  }
  </code></pre>