You can either call XPages2Eclipse API functions in server side JavaScript (SSJS) or Java code that is executed during the backend processing of an XPage. This includes the page load events (e.g. beforeRenderResponse and afterRenderResponse) as well as event code that is triggered by UI events like the click of a button. While code in page load events should in general not be running for a long duration (because it would slow down page reload/rendering), it is fine to have UI event code running for a several seconds.
There is however a timeout value defined in the XPages client side runtime environment, that prevents event code from running too long (the default limit is about 6 seconds).
If a piece of code exceeds this duration, the browser displays a timeout alert message to indicate that a Dojo Ajax call did not return a result within the allowed period of time.
To increase the timeout value, simply add the following script block to the source code of an XPage:
<xp:scriptBlock id="setLatencyBlock">
<xp:this.value><![CDATA[XSP.addOnLoad(function() {
//increase Ajax request timeout to 600 seconds
XSP.submitLatency = 600 * 1000;
});]]></xp:this.value>
</xp:scriptBlock>