Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9149331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:27:45+00:00 2026-06-17T11:27:45+00:00

How to implement a simple add/remove dynamic <rich:tabPanel> ? (I’ve seen people asking this

  • 0

How to implement a simple add/remove dynamic <rich:tabPanel>?

(I’ve seen people asking this around so I thought postin a Q&A of a simple implementation)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:27:46+00:00Added an answer on June 17, 2026 at 11:27 am

    The implementation has 3 custom classes:

    1. Content: contains the values to be displayed in a tab;
    2. ItemTab: contais an UITab object and a Content object;
    3. MyTabs: EJB managed bean that provides access to the tabs and adding/removal methods.

    The code is:

    Content:

    public class Content {
    
        String name;
        String job;
        String dept;
    
        public Content() {
            name = "John Doe";
            job = "None";
            dept = "None";
        }
    
        public String getName() {
            return name;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    
        public String getJob() {
            return job;
        }
    
        public void setJob(String job) {
            this.job = job;
        }
    
        public String getDept() {
            return dept;
        }
    
        public void setDept(String dept) {
            this.dept = dept;
        }
    }
    

    TabItem:

    public class TabItem {
    
        UITab component;
        Content content;
    
        public TabItem() {
            component = new UITab();
            content = new Content();
        }
    
        public UITab getComponent() {
            return component;
        }
    
        public void setComponent(UITab tab) {
            this.component = tab;
        }
    
        public Content getContent() {
            return content;
        }
    
        public void setContent(Content content) {
            this.content = content;
        }
    }
    

    MyTabs:

    import java.io.Serializable;
    import java.util.ArrayList;
    import java.util.List;
    import javax.annotation.PostConstruct;
    import javax.enterprise.context.SessionScoped;
    import javax.inject.Named;
    
    @Named
    @SessionScoped
    public class MyTabs implements Serializable {
    
        private List<TabItem> tabs;
    
        public MyTabs() {
            tabs = new ArrayList<TabItem>();
        }
    
        @PostConstruct
        private void init() {
            createTab();
            createTab();
            createTab();
        }
    
        public void createTab() {
            TabItem tab = new TabItem();
    
            tab.getComponent().setId("Tab" + (tabs.size()+1));
            tab.getComponent().setHeader("Tab " + (tabs.size()+1));
            tab.getContent().setName("John Doe " + (tabs.size()+1));
            tab.getContent().setJob("Salesman " + (tabs.size()+1));
            tab.getContent().setDept("Sales " + (tabs.size()+1));
    
            tabs.add(tab);
        }
    
        public void removeTab(TabItem tab) {
            tabs.remove(tab);
        }
    
        public List<TabItem> getTabs() {
            return tabs;
        }
    
        public void setTabs(List<TabItem> tabs) {
            this.tabs = tabs;
        }
    }
    

    tabview.xhtml:

    <h:commandLink value="Add Tab" 
                       actionListener="#{myTabs.createTab()}"/>
    <rich:tabPanel switchType="client">
        <c:forEach items="#{myTabs.tabs}" var="tab">
            <rich:tab value="#{tab.component}">
                <f:facet name="header">
                    <h:outputLabel value="#{tab.component.header}"/>
                    <h:commandLink value="  X" actionListener="#{myTabs.removeTab(tab)}"/>
                </f:facet>
    
                <h:panelGrid columns="2">
                    <h:outputLabel value="Name: "/>
                    <h:outputLabel value="#{tab.content.name}"/>
                    <h:outputLabel value="Dept: "/>
                    <h:outputLabel value="#{tab.content.dept}"/>
                    <h:outputLabel value="Job: "/>
                    <h:outputLabel value="#{tab.content.job}"/>
                </h:panelGrid>
            </rich:tab>
        </c:forEach>            
    </rich:tabPanel>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to implement a simple Add-In for InfoPath 2010 Filler/Editor mode, which
CSS3 allows developers to implement simple graphics without using images. For example this envelope
I'm trying to implement simple Event Bus I started like this: public class RegistrationData
The Home sample in the android sdk doesn't implement the Add item, which bring
I want to implement simple LINQ-to-SQL-like functionality in my .net application. For example i
I have to implement simple ray tracing algorithm, but I can not figure out
What is the best way to implement simple pagination? Here is the code im
I've been trying to implement simple low level keyhook using JNI and all went
I'm getting acquanted with Core Animation and trying to implement simple movement along a
I want to implement a simple script to do some boring housekeeping on my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.