Skip to main content link. Accesskey S

The useful resource for IBM Lotus Domino XPages development

Submit Search


Home > Server JavaScript > Work with events and partial or full refresh
xpageswiki.com
is maintained by 
Julian Buss.
You can hire me.

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.

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 + '.' );
} );


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


Created by Bernd Hort on Nov 13, 2012 11:38:29 AM

In 8.5.3 XSP.partialRefreshPost(id); will throw an error. If you don't need any options just pass an empty object: XSP.partialRefreshPost(id, {});


Created by Steve in NYC on Dec 13, 2012 6:45:15 PM

This is almost a year and a half after two of you asked for examples, but I haven't found any working examples out there yet. To be clear, it is to call multiple partial refreshes in SSJS, NOT CSJS! Has anyone had it resolved yet?

Thanks!


Created by Alex Elliott on Dec 21, 2012 1:46:32 AM

This article is titled 'Work with events and partial or full refresh' but only covers partial refresh events. Full refresh events don't seem to be covered at all.


Add Comment

Name:
Comments:
How to take your XPages App to the iPhone, iPad, Android: use Domino To Go!
Do you look for an XPages Workflow solution? Take YouAtNotes Workflow.