Does anybody know how to add a button for adding new tabs that is positioned near the last created tab? If it is not clear what I am about, just look at tabs in your browser and the button to add new tab;-) that’s exactly what I want to manage.
I’m using MyFaces+PrimeFaces.
You can use
<p:tabView>to show a dynamic tabset based on some collection of beans. You can present the “Add” tab as the last tab of the tabset. You can if necessary even style it differently. You can use<p:ajax event="tabChange">to hook a tab change listener wherein you can check if the “Add” tab has been opened and then add the new tab.E.g.
with
The
Tabclass is in this example just a plain javabean with propertiestitleandcontent. Theoncompletein<p:ajax>is necessary because the tab content would otherwise disappear after adding the new tab (which look much like a PF bug, after all; I was using 3.3 by the way).