1

I saw on richfaces showcase that the best way to use rich:tabPanel with dynamic tabs is with a4j:repeat, but this doesn't work in my application.

This is my code:

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
    <title>Java EE 6 Starter Application</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />   
</h:head>
<h:body>
    <h:form>
        <div id="topArea">
            <ui:insert name="topArea"/>
        </div>
        <div id="mainArea">
            <ui:insert name="mainArea"/>  
        </div>
        <div id="footerArea">
            <ui:insert name="footerArea"/>
        </div>
    </h:form>
</h:body>
</html>

In topArea, I have this menu:

<rich:panelMenu>
    <rich:panelMenuItem label="Clienti" name="Clienti"  action="#{tabsBean.addTab()}"     render="tabsPanel" />                                     
</rich:panelMenu>

in mainArea, I have this tabPanel:

<rich:tabPanel id="tabsPanel" switchType="client"  activeItem="#{tabsBean.activeTab}" >
    <a4j:repeat  value="#{tabsBean.tabs}" var="tab">
        <rich:tab name="#{tab.name}">
            <f:facet name="header">#{tab.name}</f:facet>
            <h:form>
                <h:outputText value="Enter Name:" />
                <h:inputText id="input" />
                <h:outputText value="Enter you interests:" />
                <h:inputTextarea cols="17" rows="3" />
                <h:outputText value="Choose your favourite color" />
                <h:selectOneMenu>
                    <f:selectItem itemLabel="Red" itemValue="0" />
                    <f:selectItem itemLabel="Black" itemValue="1" />
                    <f:selectItem itemLabel="Green" itemValue="2" />
                    <f:selectItem itemLabel="White" itemValue="3" />
                </h:selectOneMenu>
            </h:form>
        </rich:tab>
    </a4j:repeat>
</rich:tabPanel>

My troubles are:

  • The tabs are not created
  • Why does the showcase use a nested form? Won't nested forms cause trouble?

Thanks

Simon MᶜKenzie
  • 8,344
  • 13
  • 50
  • 77
Skizzo
  • 2,883
  • 8
  • 52
  • 99

1 Answers1

0

Dynamic tabs with a4j:repeat are supported since 4.3.0.Final only, refer here for more details: http://www.bleathem.ca/blog/2013/01/dynamic-panels-with-a4jrepeat.html

For earlier versions c:forEach items="#{tabsBean.tabs}" var="tab" can be used.

Andrey
  • 6,526
  • 3
  • 39
  • 58
  • I tried to use c:forEach items="#{tabsBean.tabs}" var="tab", but in this case i have the following trouble within of the tabs "a4j:commandLink , a4j:commandButton doesn't work at first click but work only after second click" – Skizzo Mar 07 '13 at 11:36