1
votes

I have a typeahead enabled on an inputText field which triggers an onChange event. This works fine unless the page has not been refreshed for a period of time (in testing, it stops working after 1 hour but may be less). Refreshing the page completely fixes the issue.

The code for the inputText field is as follows;

<xp:inputText id="quickSelectEntry" style="width:170px;">
    <xp:this.dojoAttributes>
        <xp:dojoAttribute name="placeHolder" value="Enter name">
        </xp:dojoAttribute>
    </xp:this.dojoAttributes>
    <xp:typeAhead mode="none" minChars="2" ignoreCase="true"
        var="searchValue" valueMarkup="true">
        <xp:this.valueList><![CDATA[#{javascript:return         nameTypeAhead(searchValue)}]]></xp:this.valueList>
                </xp:typeAhead>

                <xp:eventHandler event="onchange" submit="true"
                    refreshMode="norefresh">
                    <xp:this.action>
                        <xp:actionGroup>
                            <xp:executeScript>
                                <xp:this.script><![CDATA[#{javascript:var searchVal:string = getComponent("quickSelectEntry").getValue();
if (searchVal.substr(0,1).equals("?")) {
    context.redirectToPage("xCheckSecurityGroup.xsp?group=" + searchVal.substr(1));
    return false;
} else {
    var doc:NotesDocument = quickLookupView.getDocumentByKey(searchVal, true);
    if (null != doc) {
        viewScope.lookupKey = doc.getUniversalID();
        viewScope.lookupForm = doc.getItemValueString("form");
        return true;
    } else {
        viewScope.lookupKey = ""
        viewScope.lookupForm = ""
        return false;
    }
}
]]></xp:this.script>
                            </xp:executeScript>
                            <xp:actionGroup>
                                <xp:this.condition><![CDATA[#{javascript:viewScope.lookupKey != ""}]]></xp:this.condition>

                                <xp:openPage target="openDocument"
                                    documentId="#{javascript:return viewScope.lookupKey}">
                                    <xp:this.name><![CDATA[#{javascript:return "x" + viewScope.lookupForm + ".xsp" }]]></xp:this.name>
                                </xp:openPage>
                            </xp:actionGroup>
        </xp:actionGroup>
    </xp:this.action>
</xp:eventHandler>

So far I've tried doing a timed partial refresh of the containing panel with no joy, I've set the typeahead mode from none to full. No difference.

Aside from refreshing the page every 10 minutes, is there anything else that couple be causing the problem. FYI The actual typeahead is working correctly consistently, its just the onchange event that stops firing.

4

4 Answers

2
votes

What seems to happen is that the server web session is intact but the XPages session is lost.

Add the following to the bottom of your XPage and what it will do is refresh the DIV preiodically based on your setting (in milliseconds) (300000 = 300 seconds = 5 minutes) - the longest I have had a successful test is 3.5 hours.

You need to set a value at least one minute less than the session timeout length set in the application properties for your database.

<xp:div id="keepSessionAlive"></xp:div>
<xp:scriptBlock id="scriptBlock1">
    <xp:this.value>
    <![CDATA[   
        XSP.addOnLoad(function(){
            setInterval(function(){
                XSP.partialRefreshPost("#{id:keepSessionAlive}", {});   
            }, 300000)
        })]]>
    </xp:this.value>
</xp:scriptBlock>

Do not set a short refresh time as this will needlessly waste bandwidth and also bloat IE's RAM usage which is not well managed by the browser.

Understand that this is a SECURITY ISSUE at the same time - by basically keeping an idle computer's session alive you leave it open to hijack without the user's knowledge - that is the part of the point of a timeout

1
votes

The issue is that the XSP session times out (according to your server settings). See this answer for recommendations on keeping the session alive: How do I refresh page automatically when partial refresh doesn't work?

1
votes

I have seen this too. I ended up putting in a meta refresh tag to reload the page every 30 minutes. It was the only thing that seems to work.

Howard

0
votes

May want to check the Application Properties(go to Xpages tab). There you can set the Application and the session timeouts for the database. If these are blank I think they will default to server which is typically 30 minutes.

V/R,

Kev