1
votes

I think this is a bug in the Tab Container...

Opening a new tab using Java or the Server Side JavaScript createTab method when the new tab contains a panel that is set to be an iframe pointing to another XPage in the same database will always cause the XPage to get reloaded after loading about five or six tabs (in Chrome, IE does the same but it takes more tabs...)

If the tab contains an iframe that points to another database that holds the XPage it works fine.

The SSJS code is: getComponent("djTabContainer1").createTab({title:"New tab"});;

The Java code is

public static boolean createTab(UIDojoTabContainer tabContainer) {

    try {
        if (tabContainer == null) {
            tabContainer = (UIDojoTabContainer) Utils.findComponent("TabContainer");
            if (tabContainer == null) {
                return false;
            }
        }

        String tabTitle = null;
        String url = null;
        String unid = null;
        UIDojoTabPane newTab = null;

        // get default number from current project preferences
        tabTitle = "My Tabpage";
        url = Utils.GetXpageURL("tabpage.xsp");

        // create a new Tab
        newTab = new UIDojoTabPane();
        newTab.setTitle(tabTitle);
        newTab.setTabUniqueKey(new Random().toString());

        newTab.setClosable(true);
        newTab.setId("TabContainer_" + unid);
        newTab.setStyleClass("myTabContainer");

        Utils.WriteToConsole("setting style class on " + newTab.getTitle());
        // newTab.setStyle("height:auto;width:auto; overflow-y: auto;border: 0px;");

        // create new Panel
        UIPanelEx newPanel = new UIPanelEx();
        newPanel.setId("IFrame" + unid);
        newPanel.setStyleClass("iframeClass");
        // make an iFrame of this panel with our URL as src
        newPanel.setTagName("iframe");
        Attr property = new Attr();
        property.setName("src");
        property.setValue(url);
        newPanel.addAttr(property);

        // add Panel to our new Tab
        newTab.getChildren().add(newPanel);

        // add the new tab to our tab container
        tabContainer.getChildren().add(newTab);
        tabContainer.setSelectedTab(unid);
        return true;
    } catch (Exception ex) {
        Utils.WriteToConsole("Unable to add a new Tab Page to the Tab Container (com.tlcc.Main.createTab)", ex);
        return false;
    }

}

The XPage that is referenced in the src property of the iframe is very basic...

<?xml version="1.0" encoding="UTF-8"?>
 <xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:button
    value="Label"
    id="button1">
</xp:button>
<xp:inputText id="inputText1"></xp:inputText></xp:view>

When the XPage reloads it has no more tabs (except the first tab that was created in the XPage at the start) and is not responsive.

Howard

2

2 Answers

4
votes

It could be a server page persistence/component tree limit problem. If you use the default server page persistence, the server only stores 4 pages in memory (per user).

When you create new tabs on the page that loads another XPage, the server is filling up the server page persistence queue and when you hit the 5th tab, the current page is no longer part of the server page persistence (the component tree is no longer in memory) leading to a reload of the current page.

You can increase the number of pages stored (and also move the disk persistence instead of memory persistence). You can also set viewState to "nostate" on the XPage that you load in the iframe (at least to test out my theory).

See Toby Samples blog post on state and this answer on a similar state issue: https://stackoverflow.com/a/31431917/785061

0
votes

So, to finalize this... the setting for viewstate=nostate allows more tabs but then does not keep the components in memory. So, it works well for readonly XPages but not when the document on the XPage is in edit mode. The setting Maximum Pages on disk in the Xsp properties on the persistence tab will allow more tabs with iframes that have XPages but still will crash at some point.

Net is, don't use multiple iframes that pull in XPages from the same nsf...