About a year ago, I had read about a requirement to build a Visualforce Page that had repeating tabs in it. It was figured out that just throw a <apex:repeat> in the page and be done. Not so fast. You’d think it would be easy but it was actually impossible at the time. The code started out like this:
BUT, I needed the tabs to be dynamic.
I needed the information on the Visualforce Page to be loaded using code in an Apex Controller. Here’s what I tried:
Should work right? Nope! you can’t put a tab inside a “repeater”. I ended up solving this issue with some jQuery but something easy turned into something a bit difficult. At the time, I was anticipating the release of Dynamic Visualforce Components. It was announced but then pulled from the General Availability of the Summer ’11 release.
Thankfully, Dynamic Visualforce Components are now available. Here’s how I solved the example above:
The Visualforce Code becomes just one line:
Here’s the Apex to create a tabPanel dynamically:
The code above makes the following dynamic tabPanel: