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.
Update 20. jan 2013: added the call of the hijack function via XSP.addOnLoad().
In a nutshell:
1.) place a script like this at the very top of your page:
var f = function(){
// 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]);
};
}
});
}
XSP.addOnLoad(f);
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 + '.' );
} );