Client-Side Events for Partial Updates: onStart, onComplete, onError
Wednesday, September 9, 2009 at 5:38PM Hello All you XPages geeks out there. Today I bring you a bit of good news from the land of 8.5.1!
There are three new CLIENT-SIDE events you can hook into when you do a partial update.
onStart - gets called just before the XSP handler submits the AJAX call to get and process the partial update
onComplete - gets called after the partial update is completed and has been processed, and the DOM updated
onError - gets called if an error happens during the xhrGet or xhrPost process (equiv to the error parameter of dojo's xhrGet/xhrPost) - IF YOU DEFINE onError YOU OVERRIDE THE DEFAULT ERROR MESSAGE. Which is a good thing because you can give your users better context to the problem, etc.
What can you do with these? Well, for example:
- if you have a Partial Update that is going to take a long time, with onStart, you can set the default 'timeout parameter' for a partial update (XSP.submitLatency = 10000 // 10 Seconds (default is 6)), and warn your user that its going to take a bit longer than expected, etc.
- For the long partial update, with onComplete you can notify your user the update is complete, or If you use dojo's drag and drop functionality, you could use the onComplete to re-setup your drag and drop sources or targets. Or you could have the element start "invisible" and use the onComplete to fade in the element using dojo.fadeIn() for some extra "flair"
Ok, 'nuff examples, where do you set these up? Well, in your event handler that triggers the partial update of course! For example, if you have a button, and that button triggers a partial update, expand the button in the outline, and you'll see a Node for Event handler. Click that node, and in the All Properties, under 'events' you'll find the three events!
Happy Coding!
Oh, and BTW: IBM Lotus Notes/Domino and Lotus Notes Traveler 8.5.1 is prerelease code and there are no guarantees from IBM that the functionality presented or discussed will be in the final shipping product.
Partial Updates,
XSP,
events in
Development,
Tips and Tricks 