3
votes

Please help. When i run a single XSP.partialRefreshGet in xPages and it is working. But,it is not working while get multiple partial refresh. Anything is wrong on it? Kindly assist and thanks.

<xp:scriptBlock id="scriptBlock1">
    <xp:this.value>
        <![CDATA[
        setInterval(function() {


XSP.partialRefreshGet("#{id:refreshPanel}", {
 onComplete: function() {
     XSP.partialRefreshGet("#{id:refreshPanel2}", {});
    }


} })
            }, 1000)
        ]]>
    </xp:this.value>
</xp:scriptBlock>
2
The Problem is the interval. Remove it, or increase the time.Sven Hasselbach
Hi, the reason to use setInterval method is require continue calling the function to refresh in order to always update the latest information. Hence, i can't remove this method. I have tried to increase the time and it is not working.user3426448

2 Answers

11
votes

When doing a partial refresh, a lock is set in the XSP object which stops all partialRefreshes until the current running refresh is completed or specific time is up (20 s by default).

To change this behaviour you can do two things:

  1. change the intervall
  2. allow a resubmition

But in both cases, this is NOT a good choice for your problem with the intervaled refresh, because this would just flood the server with useless requests while the server is still processing a already sent request.

Instead, you should recall your refreshes when your refreshes are completed (or failed). Something like this:

<xp:scriptBlock id="scriptBlock1">
   <xp:this.value>
      <![CDATA[
        function doIt(){
           XSP.partialRefreshGet("#{id:refreshPanel}", {
              onError: "restart()",
              onComplete: function() {
                 XSP.partialRefreshGet("#{id:refreshPanel2}", {
                    onComplete: "restart()",
                    onError: "restart()"
                 });
              }
           });
        }

        function restart(){
           window.setTimeout( "doIt()", 1000 );
        }

        doIt();
    ]]>
</xp:this.value>

P.S. I typed this from my brain w/o checking the code on a computer.

1
votes

XPages enforce, from client side, a 20s delay between partial refresh. The reason can be found in the XSPClientDojo.js, canSubmit() function comments:

This should be called before any page submission, to prevent page re-submission, either accidentally when a user double-clicks on a link, or if the user is impatient compared to the expected time for a page refresh. If the page has recently been submitted, it returns false, and the submission should be abandoned.

To bypass this behavour, you can just call XSP.allowSubmit() between the two partialRefreshGet(). Some this like that:

<xp:scriptBlock id="scriptBlock1">
<xp:this.value>
  <![CDATA[
    setInterval(function() {
      XSP.partialRefreshGet("#{id:refreshPanel}");
      XSP.allowSubmit();
      XSP.partialRefreshGet("#{id:refreshPanel2}");
    }, 1000)
  ]]>
</xp:this.value>
</xp:scriptBlock>