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 8955413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:32:58+00:00 2026-06-15T14:32:58+00:00

Background: XPage with tabbed table (from container controls) and multiple data sources, one for

  • 0

Background: XPage with tabbed table (from container controls) and multiple data sources, one for each tab. I was having issues with the save button creating duplicates if the users refreshes the page. To fix this I implemented this solution created by Tommy Valand. http://dontpanic82.blogspot.com/2010/06/xpages-avoid-saving-duplicate-documents.html

The issue is that when the user is on the second tab and saves the document using a full refresh (I have to have this due to attachments). The function works great except…

The problem: The redirect always takes the user to the first tab. This is a problem obviously for every tab except for the first.

I would like to know a way to direct the URL directly to the second tab. I have tried modifing Tommy’s code to include a hash tag, but I haven’t been able to get this to work. I am not even sure that the hash tags work with xpages. Thanks in advance for help with this issue.

 function redirectToCurrentDocument( switchMode:boolean, tab){
  try {
    if( typeof currentDocument === 'undefined' || viewScope.stopRedirect ){ return;       }
    // Gets the name of the XPage. E.g. /Person.xsp
    var page = view.getPageName();

    // Finds extra parameters, strips away XPages parameters/trims leading &
    var parameters = context.getUrl().getQueryString().substring(1);
    var extraParameters = parameters.replace( 
     /([&\?^]*_[a-z0-9=]+[&]{0,1})|(action=\w{4}Document[\&]{0,1})|(documentId=[\w]{32}[\&]{0,1})/ig, '').replace( /\&$/, '' );

    // Gets the unid of the current document
    //var unid = currentDocument.getDocument().getUniversalID();
    //var unid = document1.getDocument().getUniversalID();  //changed this line to make work with multiple data sources - SJZ
    var unid = document1.getDocument().getNoteID();  //also changed to use NoteID since it gave runtime errors for new documents - SJZ

    // Sets/changes the action according according to the mode the document is in
    var isEditable = currentDocument.isEditable();
    if( switchMode ){ isEditable = !isEditable; } // false -> true / true -> false

    var action = ( isEditable ) ? 'editDocument' : 'openDocument';

    // Open the current document via a get request
    var redirectUrl = page + '?documentId=' + unid + '&action=' + action;

    if( extraParameters ){ redirectUrl += '&' + extraParameters; }

    print("tab=" + tab)
    if(tab == "Invoices") { redirectUrl += '#tabPanel1'; }
    if(tab == "Credits") { redirectUrl += '#view:_id1:tabPanel2:editPanelCredits'; }
     print(redirectUrl);
    context.redirectToPage( redirectUrl );
  } catch(e){ /* Exception logging */ }
}
  • 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-15T14:33:00+00:00Added an answer on June 15, 2026 at 2:33 pm

    You cannot use a #HashTag because the Server never receives this information from the browser.

    Just modify yor tabbedPanel to open the selected tab by an URL parameter “tab”:

    <xp:tabbedPanel id="tabbedPanel1">
        <xp:this.selectedTab>
            <![CDATA[#{javascript:
                var p = context.getUrlParameter("tab");
                if(  p === "" )
                    p = "Invoices";
    
                return p
            }]]>
        </xp:this.selectedTab>
        <xp:tabPanel label="New Tab" id="Invoices">
            TAB1 Invoices
        </xp:tabPanel>
        <xp:tabPanel label="New Tab2" id="Credits">
            TAB2 Credits
        </xp:tabPanel>
    </xp:tabbedPanel>
    

    Now you can control it by opening your XPage with http://example.com/db.nsf/Tab.xsp?tab=Credits.

    The SSJS code above now can easily modified to this:

    ...
    print("tab=" + tab)
    redirectUrl += '&tab=' + tab;
    print(redirectUrl);
    ....
    

    The regex has to be modified this way:

    var extraParameters = parameters.replace( 
     /([&\?^]*_[a-z0-9=]+[&]{0,1})|(tab=\w{0,}[\&]{0,1})|(action=\w{4}Document[\&]{0,1})|(documentId=[\w]{32}[\&]{0,1})/ig, '').replace( /\&$/, '' );
    

    to remove the tab parameter from the URL.

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

Sidebar

Related Questions

Background: Xpage with multiple data sources. Each row of tabbed table contains an edit
Background: I've wrote a small library that is able to create asp.net controls from
Background: We're building an application that allows our customers to supply data in a
Background I am working with a monad built of a stack of transformers one
Background: Using unix, codeigniter from localhost. I'd like to run a controllers via a
Background - I want to extract specific columns from a csv file. The csv
Background I've got an NSOutlineView that shows TrainingGroup entities. Each TrainingGroup represents a folder
Background To replace invalid zip codes. Sample Data Consider the following data set: Typo
Background: I have viewed this question as well as this one - sadly, to
Background: I have a table with 5 million address entries which I'd like to

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.