Search
Categories
Tags
Latest Comments

Entries in Partial Updates (3)

Monday
Jun282010

Quick Tip: Passing a Value from the client to the Server using XSP.PartialRefreshGet

I make extensive use of the XSP object's partialRefreshGet and partialRefreshPost functions to invoke interactions with the Domino XSP server. It's generally accepted that a Get is faster than a Post because there is no data updating to do, no data to collect etc.

But sometimess, I need to send a single transient value up to the server to influence the returning results. You can do this on a get through the combination of a params object in the options object sent to the partialRefreshGet, and then using context.getSubmittedValue() in your Server Side JavaScript.

To do this, you call XSP.partialRefreshGet() just like has been illustrated before, but you add a new object to your options object, called params. You'll want to add a name/value pair to the params object with the name $$xspsubmitvalue, and the value of your choice.

Fully coded, it would look like something like this:

(client side javascript code)

var refreshId=dojo.query('[id$="serverSideIdYouWantToRefresh"]')[0];
var mySubmitValue='whatYouWantToSendHere';

XSP.partialRefreshGet(refreshId, {
     params: {
          '$$xspsubmitvalue': mySubmitValue
     },
     onStart: function () {
           alert('starting');
     },
     onComplete: function () {
           alert('boo-yah!');
     },
     onError: function () {
           alert('aww shucks cletus, it done don't worked');
     }
});

 

Then, in your SSJS, you can retrieve your value, like this:

var mySubmittedVal = context.getSubmittedValue();

 

Happy Coding!

Wednesday
Sep092009

Client-Side Events for Partial Updates: onStart, onComplete, onError

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.

Sunday
Jul122009

Demonstration Video of the Partial Update Feature in XPages

Teresa Monahan of IBM has a video on the Domino Designer Wiki which demonstrates how the XPages partial update feature works.

More >