Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you want to show dialog when a specific tab is changed, you can inform a js function about, the tab selected control that it is 2 or not by adding a callback parameter via ajax response:</p> <pre><code>public void tabChangeListener(TabChangeEvent event) { if ( event.getTab().getId().equalsIgnoreCase("tab2") ) { RequestContext.getCurrentInstance().addCallbackParam("index", 2); } } </code></pre> <p>And use:</p> <pre><code> &lt;p:ajax event="tabChange" listener="#{bean.tabChangeListener}" oncomplete="showOrNot(xhr,status,args)"&gt;&lt;/p:ajax&gt; </code></pre> <p>This will call the js function and it's going to control that the changed tab is 2 or not:</p> <pre><code>function showOrNot(xhr,status,args) { if(args.index==2) { statusDialog.show(); } } </code></pre> <p>Or different approach is defining a value and using <code>visible</code> property of the <code>p:dialog</code>:</p> <pre><code>public void tabChangeListener(TabChangeEvent event) { if ( event.getTab().getId().equalsIgnoreCase("tab2") ) { this.condition=true; } } </code></pre> <p>And <code>&lt;p:dialog visible="#{bean.condition}"/&gt;</code>. And maybe you need to focus on your first approach and you can give an ID to <code>p:dialog</code> and update it via <code>p:remoteCommand</code>:</p> <pre><code>&lt;p:remoteCommand actionListener="#{bean.refreshData}" update="someTab2ElementID dialog" name="refresh" global="true" onstart="statusDialog.show()" oncomplete="statusDialog.hide()"/&gt; </code></pre> <p>Don't forget to give the exact client ID of the dialog in the update property of <code>p:remoteCommand</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload