191 Lotus blogs updated hourly. Who will post next? Home | Blogs | Search | About 
 
Latest 7 Posts
XPages Tip: Adding a Bootstrap Class to All Labels via the Theme (Redux)
Wed, Jul 20th 2016 3
XPages Tip: Overriding, Concatenating, and Conditionally Adding Control Properties via a Theme
Wed, Jul 20th 2016 5
XPages Tip: Displaying Bootstrap Applications Properly on Mobile Devices
Tue, May 31st 2016 4
Efficiently Keeping an XPages Session Alive with JSON RPC
Wed, May 25th 2016 3
Browser Session Lifespan – Idle Session Timeout vs LTPA Token Expiration
Tue, May 24th 2016 5
XPages Tip: Passing an Array to a Custom Control Property
Tue, Apr 12th 2016 2
XPages Tip: Beware Server-Side code in Multiple onClientLoad Events
Thu, Apr 7th 2016 4
Top 10
Passing Parameters to SSJS from a Client-side partialRefreshGet()
Mon, Jul 14th 2014 10
Computing Custom Date Format Patterns Throughout an Application
Mon, Aug 18th 2014 10
I want to hear what YOU have to say
Mon, Feb 3rd 2014 7
Dojo Data Grid – Part 36: Conditionally Preventing Cell Editing
Tue, Feb 4th 2014 7
Dojo in XPages – 2: String Manipulation
Fri, Feb 7th 2014 7
XPages Tip: Disabling Required Validation in a Dojo Filtering Select
Fri, Aug 1st 2014 7
Gridx in XPages – 12: Adding Event Handlers and Opening a Document
Wed, Dec 3rd 2014 7
Gridx in XPages – 13: Customizing Cell Content
Fri, Dec 5th 2014 7
Gridx in XPages – 18: Formatting Date and Currency Columns
Thu, Dec 18th 2014 7
Dojo in XPages – 23: Using a Lightbox to Display Image Attachments
Thu, May 15th 2014 6


Passing Parameters to SSJS from a Client-side partialRefreshGet()
Twitter Google+ Facebook LinkedIn Addthis Email Gmail Flipboard Reddit Tumblr WhatsApp StumbleUpon Yammer Evernote Delicious
Brad Balassaitis    

partialRefreshGet() is a handy method of the client-side XSP object that can be used to trigger a partial refresh from client-side JavaScript. In this post, I’ll show how you can pass parameters for SSJS to read during the refresh, which allows you to send information to the server-side code without submitting a less efficient POST request.

This is an interesting tip that I picked up from the Mastering XPages book. I’ve used partialRefreshGet() numerous times, but I wasn’t familiar with the params property previously.

Here’s an example of a normal partialRefreshGet() call:

XSP.partialRefreshGet("#{id:myComputedText}", {});

The first parameter is the target for the partial refresh. This is client-side JavaScript, so it needs to use the #{id: } syntax to compute the client-side ID of the refresh target.

The second parameter is an object that have up to 4 properties: onStart, onError, onComplete, and params. Here’s an example of the structure when using all of the options (although none are required):

XSP.partialRefreshGet("#{id:myComputedText}",
 {
    params: paramObject,
    onStart: startHandler,
    onError: errorHandler,
    onComplete: completeHandler

 });

The params Property and the param Object

The params property takes an object with parameters to send with the AJAX call. The Mastering XPages book says that the params property “gets expanded, encoded, and appended to the GET request URI that is invoked by the underlying AJAX handler.”

This gives you an easy way to pass information from client-side JS to SSJS and then access it via the param object in SSJS, which provides access to all URL parameters.

The SSJS that’s intended to read the parameters passed by a partialRefreshGet much be within the specified refresh target in order to read the parameters during the refresh.

Simple Example

If I have a computedText component with this value:

if (param.containsKey('parameter1')) {
  return param.parameter1 + ' ' + param.parameter2;
}

It will not return anything when the page first loads.

If I add a button with this client-side JavaScript…

XSP.partialRefreshGet("#{id:computedField2}", 
  {
    params:{"parameter1":"1", "parameter2":"2"}
  });

… it will display 12 after I click the button, because it is the refresh target and it can read URL parameters sent during the refresh.

This is a very efficient way to send data to a server-side script.

Note: If you pass a parameter that already exists in the URL, it does not overwrite the URL parameter value — it turns the value into a string separated by a comma and a space between the values.




---------------------
http://xcellerant.net/2014/07/14/passing-parameters-to-ssjs-from-a-client-side-partialrefreshget/
Jul 14, 2014
11 hits



Recent Blog Posts
3
XPages Tip: Adding a Bootstrap Class to All Labels via the Theme (Redux)
Wed, Jul 20th 2016 7:08a   Brad Balassaitis
A
5
XPages Tip: Overriding, Concatenating, and Conditionally Adding Control Properties via a Theme
Wed, Jul 20th 2016 7:07a   Brad Balassaitis
A
4
XPages Tip: Displaying Bootstrap Applications Properly on Mobile Devices
Tue, May 31st 2016 7:07a   Brad Balassaitis
A
3
Efficiently Keeping an XPages Session Alive with JSON RPC
Wed, May 25th 2016 7:07a   Brad Balassaitis
A
5
Browser Session Lifespan – Idle Session Timeout vs LTPA Token Expiration
Tue, May 24th 2016 10:15a   Brad Balassaitis
I recently spent some time investigating a client’s reports of unexpected behavior with the duration of browser sessions while testing an application on a test server. From time to time, they were required to login even while actively using an application. In this post, I’ll highlight the difference between an idle session timeout and an […]
2
XPages Tip: Passing an Array to a Custom Control Property
Tue, Apr 12th 2016 6:06a   Brad Balassaitis
A
4
XPages Tip: Beware Server-Side code in Multiple onClientLoad Events
Thu, Apr 7th 2016 6:06a   Brad Balassaitis
A
2
getFragment() Doesn’t
Thu, Mar 24th 2016 7:07a   Brad Balassaitis
A
5
Transferring a Bitbucket Repository
Tue, Mar 22nd 2016 7:07a   Brad Balassaitis
A
3
Handling Errors in an XPages RPC Method
Wed, Feb 17th 2016 7:07a   Brad Balassaitis
A




Created and Maintained by Yancy Lent - About - Planet Lotus Blog - Advertising - Mobile Edition