Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xpages : multiple partial refresh not working

Tags:

xpages

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>
like image 214
user3426448 Avatar asked Jul 04 '26 01:07

user3426448


2 Answers

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.

like image 191
Sven Hasselbach Avatar answered Jul 05 '26 14:07

Sven Hasselbach


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>
like image 22
Damien Plumettaz Avatar answered Jul 05 '26 15:07

Damien Plumettaz