Some of you may have noticed that if you use the onKeyUp event on an xpage and do a partial refresh of a view or repeat, if you type at a quick pace it stops updating after about two characters, thus giving you an incorrect filter.

At first i thought this was an Xpages issue, but after some google searches noticed it was an ajax issue. I found some code and modified it it to work in the viewpicklist custom control that i wrote.  Here is what i am now using for the view picklist control.

First i added an output script to the control. This delays the refresh until a user has stopped typing for 1/2 second.

 

<xp:scriptBlock id="scriptBlock1">
		<xp:this.value><![CDATA[${javascript:"var count = 0; function doMyRefresh()" +
"{   count = count+1;   setTimeout('doMyRefreshGo('+count+')',500);}; " +


"function doMyRefreshGo(currCount)" +
"{ if(currCount == count){ count = 0;" +

'XSP.partialRefreshPost("#{id:' +compositeData.dialogID + "table"+ '}", {' +
 '   onComplete: function() {'+
  '  }' +
'});' +

  
'}}'}]]></xp:this.value>
	</xp:scriptBlock>

 

 

Then i changed the onKeyUp event to call doMyRefresh() in csjs, with no update or any SSJS.

Now to do this where you dont have to compute the refresh id like in the viewpicklist custom control, its a little easier.

<xp:scriptBlock id="scriptBlock2">
		<xp:this.value><![CDATA[var count = 0; function doMyRefresh()
{count = count+1;   setTimeout('doMyRefreshGo('+count+')',500);};

function doMyRefreshGo(currCount)
{if(currCount == count){ count = 0;
XSP.partialRefreshPost('#{id:yourid}', {
onComplete: function() {
}
});
}};]]></xp:this.value>
	</xp:scriptBlock>