tags:

views:

50

answers:

0

Let say that I want to create a variable set of <rich:tab> elements within a <rich:tabPanel> component. So I tried to do that way:

<rich:tabPanel switchType="client" ...>
    <ui:repeat value="#{myBean.myTabs}" var="tab">
        <rich:tab name="#{tab.name}" label="#{tab.label}"/>
    </ui:repeat>
</rich:tabPanel>

But it didn't work, as no tab is rendered. I also got the following message in the logs:

j_id174: tab panel has no enabled or rendered tabs!

This problem seems to be encountered by others people, for example here.

So as suggested by the previous thread, I replaced my <ui:repeat> by a <c:forEach> but the problem still occurs.


I have a way to solve this problem using the binding attribute of my <rich:tabPanel> component:

<rich:tabPanel switchType="client" binding="#{tabNavigationBean.tabPanel}"
</rich:tabPanel>

and then in my Java bean:

private HtmlTabPanel tabPanel; // + getter and setter

public void setTabPanel(HtmlTabPanel tabPanel) {
    this.tabPanel = tabPanel;
    if (tabPanel != null) {
        createTabs();
    }
}

private void createTabs() {
    Application application = FacesContext.getCurrentInstance().getApplication();
    HtmlTab newTab = null;
    for (DedicatedPageTab dpt : getDedicatedPageTabs()) {
        newTab = (HtmlTab) application.createComponent(HtmlTab.COMPONENT_TYPE);
        newTab.setLabel(dpt.getLabel());
        newTab.setName(dpt.getName());
        tabPanel.getChildren().add(newTab);
    }
}

This code is working.

However, my question is to know if I can solve my problem without using the binding attribute (i.e. a 100% pure XHTML solution)?