Skip to main content link. Accesskey S

The useful resource for IBM Lotus Domino XPages development

Submit Search

Available in the Appstore!All the content of xpageswiki.com for iPhone or iPad for offline access.

Home > Server JavaScript > Work with events and partial or full refresh

Work with events and partial or full refresh

ShowTable of Contents

Run a partial update from client javascript


 
You can use the following function to trigger a partial update from client javascript

 
XSP.partialRefreshPost(id);

 
"id" is the runtime ID of the control, that means you have to get it with "#{id:nameOfControl}".

If you don't need to be any field changes to be considered by the update, then you can use

 
XSP.partialRefreshGet(id);


which does a "HTTP GET" and produces slightly less network traffic.

You can even submit a parameter which you can then use in server side JavaScript:

var myParameter = "some string";
XSP.partialRefreshGet(id, {
      		params: {
            '$$xspsubmitvalue': myParameter
      		},onComplete: function () {
      			// do something when the partial update is finished
     		}
        });


and in SSJS you can use the parameter with:

context.getSubmittedValue()

Run multiple partial updates


Found by Tim Tripcony.

In the Domino Designer UI you can only set one ID as target for a partial update.
But together with the XSP.partialRefreshPost() or XSP.partialRefreshGet() functions you can chain multiple updates like this:

XSP.partialRefreshGet(id1, {
  onComplete: function() {
    XSP.partialRefreshGet(id2, {
      onComplete: function() { XSP.partialRefreshGet(id3); }
    } 
 }
}


the second parameter for the XSP.partialRefreshXXX can be a javascript object which defines functions for:

- onStart (executed before the partial update starts)
- onComplete (executed after the partial update)
- onError (executed when there was an error during the update)
 
So, you can do something like this:

XSP.partialRefreshGet(id, |
  onStart: function() { doSomething; },
  onComplete: function() { doSomething; },
  onError: function() { doSomething; }
}



Hijack partial refresh events in client javascript


Tommy Valand found a cool method to execute custom javascript on partial refresh events.

In a nutshell:

1.) place a script like this at the very top of your page:

function hijackAndPublishPartialRefresh(){
// Hijack the partial refresh
XSP._inheritedPartialRefresh = XSP._partialRefresh;
XSP._partialRefresh = function( method, form, refreshId, options ){ 
// Publish init
dojo.publish( 'partialrefresh-init', [ method, form, refreshId, options ]);
this._inheritedPartialRefresh( method, form, refreshId, options );
}

// Publish start, complete and error states 
dojo.subscribe( 'partialrefresh-init', function( method, form, 
refreshId, options ){
if( options ){
options.onStart = function(){
dojo.publish( 'partialrefresh-start', [method, form, refreshId, options]);
};

options.onComplete = function(){
dojo.publish( 'partialrefresh-complete', 
[method, form, refreshId, options]);
};
options.onError = function(){
dojo.publish( 'partialrefresh-error', [ method, form, refreshId, options]);
};
}
});
}


2.) use it like this:

dojo.subscribe( 'partialrefresh-init', null, function( method, form, refreshId ){
alert('Partial refresh for ' + refreshId + ' initiated.' );
} );

dojo.subscribe( 'partialrefresh-start', null, function( method, form, refreshId ){
alert('Partial refresh for ' + refreshId + ' started.' );
} );

dojo.subscribe( 'partialrefresh-complete', null, function( method, form, refreshId ){
alert('Partial refresh for ' + refreshId + ' complete.' );
} );

dojo.subscribe( 'partialrefresh-error', null, function( method, form, refreshId ){
alert('An error occured during partial refresh of ' + refreshId + '.' );
} );


Created by Dwain A Wuerfel on Jun 28, 2011 1:05:54 AM

email: dwain.wuerfel@harlandclarke.com

This is great information and would be even more helpful to developers like myself that are new to xPages, SSJS, CSJS, etc. to have an example of how you would implement this in the xpage source code or the xpage itself


Created by Milind Apte on Jul 26, 2011 4:50:28 PM

Is there any working example for this? I tired implementing it but failed.

thnaks

-Milind


Add Comment

Name:
Comments:
Use  searchlotus.com  for news in the Web related to Lotus Notes and Domino,
and to search those sites.
Check  youatnotes.com  for great Lotus Notes, Domino and XPages software.
Did this information help you?
Please honor our efforts and flattr this!