I'm using a Primefaces tabView with the dynamic and cache attributes set to true - each tab is thus loaded the first time it's displayed and then cached so it does need to be reloaded. Is there a way to manually force a reload of an already cached tab so that the next time it is displayed it's content is fetched again from the server and not from the cache?
So if I have something like
<p:tabView id="MyTabViewId" widgetVar="_MyTabViewId" dynamic="true" cache="true">
...
</p:tabView>
I could write some javascript simillar to the following
PF('_MyTabViewId').invalidate(0);
PF('_MyTabViewId').select(0);
and the first tab would be loaded from the server no matter if it's in the cache or not.
Yes you can simply add this script to your page...
if (PrimeFaces.widget.TabView) {
PrimeFaces.widget.TabView.prototype.reloadTab = function(index) {
var reloadPanel = this.panelContainer.children().eq(index);
reloadPanel.data('loaded', false);
this.select(index);
}
}
That adds a reloadPanel method to the widget so you can then do this PF('_MyTabViewId').reloadPanel(0);
Issue: https://github.com/primefaces/primefaces/issues/8007
PR: https://github.com/primefaces/primefaces/pull/8008
Will be included in PrimeFaces 11.0.0