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

  • Home
  • SEARCH
  • 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 9126821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:08:10+00:00 2026-06-17T07:08:10+00:00

I would like to be able to link to individual tabs in a PrimeFaces’

  • 0

I would like to be able to link to individual tabs in a PrimeFaces’ “tabView”. In other words, if my page “test.jsf” has a tabView with a tab entitled “Example”, I want to be able to click a link to “Test.jsf#Example” and have the “Example” tab loaded automatically. How can I do this?

  • 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-17T07:08:12+00:00Added an answer on June 17, 2026 at 7:08 am

    This can be done with a wee bit of JavaScript (using jQuery). I hope I have commented the following code well-enough that it can be understood.

    <script type="text/javascript">
    //    What this does: when the page is loaded with a URL fragment (i.e, the #abc in example.com/index.html#abc),
    //    load the tab (by "clicking" on the link) that has the same text value as the fragment.
    //    Example: if you go to test.jsf#Example, the tab called "Example" will be clicked and loaded.
    //    This allows individual tabs to be linked to, and puts what tab you were on in the history.
        navigateToTab = function () {
            if (window.location.hash) {
                jQuery('ul.ui-tabs-nav li a').each(function (i, el) {
                    if (jQuery(el).text() === window.location.hash.replace('#', '')) {
                        jQuery(el).click();
                        return;
                    }
                })
            }
        };
    
        jQuery().ready(navigateToTab);
        jQuery(window).bind('hashchange', navigateToTab);
    
    //    This makes it so that if you click a tab, it sets the URL fragment to be the tab's title. See above.
    //    E.g. if you click on the tab called "Example", then it sets the onclick attribute of the tab's "a" tag
    //    to be "#Example"
        setupTabFragmentLinks = function () {
            jQuery('ul.ui-tabs-nav li a').each(function (i, el) {
                el.onclick = function() {window.location = '#' + jQuery(el).text()};
            })
        };
        jQuery().ready(setupTabFragmentLinks);
    </script>
    

    All you have to do is insert that JavaScript in the page that has the tabs. Then you can get a link to a tab with the usual <a href='test.jsf#Example>Click here!</a>. An added bonus is that the tab you were on becomes part of the browser history; i.e., if you navigate away from the page that has the tabs, then press the “back” button, you are brought back to the tab you were on.

    Note: if the tabView changes (e.g. you add or remove tabs), you will need to call setupTabFragmentLinks again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a site and would like to be able to click a link
I would like to be able to map (or link) one logical folder or
i would like to be able to click a link and have a form
Would like to be able to set colors of headings and such, different font
I would like to be able to output the name of a variable, along
I would like to be able to print in the logs a message for
I would like to be able to show a personal message to abusers of
I would like to be able to create a variable that holds an instance
I would like to be able to go: sed s/^\(\w+\)$/leftside\1rightside/ and have the group
I would like to be able to define a function which accepts an argument

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.