title: How to open overlay menu from oncomplete of p:commandButton with Primefaces?
body: <p>I'm using Primefaces 3.3.1 and have question.</p>
  
  <p>I have p:commandButton inside p:column of p:dataTable. I can show overlay menu when button is clicked with xhtml shown below.</p>
  
  <pre><code>    &lt;p:commandButton id="btnID" icon="ui-icon-circle-triangle-s" style="height: 16px;"&gt;
          &lt;f:setPropertyActionListener value="#{searchItem}" target="#{bean.selectedSearchItem}" /&gt;
      &lt;/p:commandButton&gt;
      &lt;p:slideMenu overlay="true" trigger="btnID" my="left top" at="left bottom"
              model="#{bean.menuModel}"/&gt;
  </code></pre>
  
  <p>In this case, bean.menuModel can return menu data instantly. But I have another case also which pre-procsessing is required to make menu data ready. So I have this one too.</p>
  
  <pre><code>    &lt;p:commandButton ajax="true" id="historyButton" action="#{bean.getHistory()}"
          icon="ui-icon-note" style="height: 16px;"
          onstart="workingDialog.show();"
          oncomplete="workingDialog.hide(); historyMenu.show();"&gt; 
          &lt;f:setPropertyActionListener value="#{searchItem}" target="#{bean.selectedSearchItem}" /&gt;
      &lt;/p:commandButton&gt;
      &lt;p:menu overlay="true" widgetVar="historyMenu" my="left top" at="left bottom"
              model="#{searchBean.menuModel}"/&gt; 
  </code></pre>
  
  <p>What I meant is, when button is clicked, it calls bean.getHistory() which starts loading menu data for that row, and show modal dialog with circling icon. When loading is finished, dialog will go away and overlay menu will be shown. What I can't do is a last part of this scenario. Above code fires exception. </p>
  
  <pre><code>java.lang.NullPointerException
      javax.faces.component.UIComponentBase.findComponent(UIComponentBase.java:561)
      org.primefaces.component.menu.BaseMenuRenderer.encodeOverlayConfig(BaseMenuRenderer.java:138)
      org.primefaces.component.menu.MenuRenderer.encodeScript(MenuRenderer.java:45)
      org.primefaces.component.menu.BaseMenuRenderer.encodeEnd(BaseMenuRenderer.java:39)
      javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1763)
      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
  </code></pre>
  
  <p>Code shown below works fine, without menu related code.</p>
  
  <pre><code>    &lt;p:commandButton ajax="true" id="historyButton" action="#{searchBean.getHistory()}"
          icon="ui-icon-note" style="height: 16px;"
          onstart="workingDialog.show();"
          oncomplete="workingDialog.hide();"&gt; 
          &lt;f:setPropertyActionListener value="#{searchItem}" target="#{bean.selectedSearchItem}" /&gt;
      &lt;/p:commandButton&gt;
  </code></pre>
  
  <p>I guess this is easy question for experts. How can I open overlay menu from oncomplete?</p>
  
  <p>Thanks in advance.</p>