I'm experiencing some trouble adding dynamically tabs that contains a chart to a tabview, using the "DataModel" feature.
The charts are added fine, but disappear once switching to another tab.
Here's the offending .xhtml:
Code: Select all
<h:panelGroup id="east-tabview-container">
<p:tabView id="east-tabview" scrollable="true" prependId="false"
value="#{bean.tabs}" var="tab"
rendered="#{not empty bean.tabs}">
<p:tab title="#{tab.title}">
<p:chart type="line" model="#{tab.model}" />
</p:tab>
</p:tabView>
</h:panelGroup>
Code: Select all
@Named
@ViewScoped
public class Bean implements Serializable {
private List<TabItem> tabs = new ArrayList<TabItem>();
// + GETTER / SETTER
public class TabItem implements Serializable {
public String title;
public ChartModel model;
// + GETTER / SETTER
}
}
Code: Select all
tabs.add(new TabItem(title, model));
Code: Select all
RequestContext.getCurrentInstance().update("east-tabview-container");
If I add something like (or bind activeIndex attribute, no matter):
Code: Select all
TabView tabView = (TabView) ComponentUtils.findComponent("east-tabview");
tabView.setActiveIndex(tabs.size() - 1);
I've tried with all possible combinations of "dynamic" and "cache" attributes, which just change the behavior of the disappearings... that unfortunately still occur
Am I doing something wrong ? I've browsed many topics of this forum related to tabview and charts, but can't find any hint (except maybe dynamic and cache atributes, but they won't help).
Any help will be greatly appreciated after so many hours of pulling out my hair
Thanks in advance