+ Start a Discussion

Dynamic Tab Creation

Hi All,
i want  to create dynamic tab in visualforce. Under each tab i should have data table and apex:inputFile. The tab, datat table should have custom style.
how to achieve this? 

<apex:dynamicComponent componentValue="{!myTabs}"/>


public Component.Apex.TabPanel getMyTabs()
//create parent panel
Component.Apex.TabPanel myTabPanel = new Component.Apex.TabPanel();
for (integer i=0;i<3;i++) //just a sample, this could easily be a SOQL loop
Component.Apex.Tab myTab = new Component.Apex.Tab();
myTab.Label = 'Tab ' + string.valueOf(i+1);
 //add child tabs to the parent myTabPanel.childComponents.add(myTab);
return myTabPanel;

I will suggest you to use simply <apex:repeat> in VF and then generate tabs inside it. So your syntax will look something like below:
<apex:tabPanel switchType="client" selectedTab="name2" id="theTabPanel">
    <apex:repeat value{!lAccounts} var="acc">
         <apex:tab label="One" name="{!acc.Name}" id="{!acc.Id}">
             content for tab one
So for every Account in list it will generate a Tab.

PS: if this answers your question then hit Like and mark it as solution!

apex:tab will not work with apex:repeat.. we have tried