193 Lotus blogs updated hourly. Who will post next? Home | Blogs | Search | About 
 
Latest 7 Posts
Questions from the DataTables Webinar
Tue, Oct 18th 2016 10
Upcoming Webinar: XPages and jQuery DataTables
Tue, Oct 4th 2016 9
Adding icon columns to DataTables with FontAwesome
Wed, Sep 14th 2016 13
Demo database from my MWLUG session
Thu, Sep 8th 2016 9
Slides (and thoughts) from MWLUG – XPages & jQuery DataTables
Wed, Aug 24th 2016 11
I’m speaking at MWLUG about…
Wed, Jun 29th 2016 12
XPage loading slow? Check your document datasource
Wed, Dec 16th 2015 10
Top 10
Adding icon columns to DataTables with FontAwesome
Wed, Sep 14th 2016 13
I’m speaking at MWLUG about…
Wed, Jun 29th 2016 12
Slides (and thoughts) from MWLUG – XPages & jQuery DataTables
Wed, Aug 24th 2016 11
XPage loading slow? Check your document datasource
Wed, Dec 16th 2015 10
Questions from the DataTables Webinar
Tue, Oct 18th 2016 10
Boot your alerts in the … with bootAlert
Tue, Feb 10th 2015 9
Demo database from my MWLUG session
Thu, Sep 8th 2016 9
Upcoming Webinar: XPages and jQuery DataTables
Tue, Oct 4th 2016 9
SSJS variables vs. scope variables
Mon, Jul 14th 2014 8
My first OpenNTF project – Dojo Name Picker
Fri, Jul 25th 2014 7


SSJS variables vs. scope variables
Twitter Google+ Facebook LinkedIn Addthis Email Gmail Flipboard Reddit Tumblr WhatsApp StumbleUpon Yammer Evernote Delicious
michaelgsmith    

Recently, I ran into a strange issue that had me scratching my head for longer than I’d care to admit.  I created a server side javascript object that contained a function, something like this:

var myVar = {
	load : function() {
		print ("performing some sort of function");
	}
}

This ssjs object contained a set of functions that were used in conjunction with one another to perform various functions.

In some cases, these functions needed to grab some data from a viewScope variable, so I figured it made perfect sense to have a key name that was consistent with my ssjs object. I had a button that was setting the value like so:

viewScope.myVar = "foo";

Innocent enough, right?

According to the XPages runtime, apparently not, because I ended up with a message like this:

Error calling method 'load()' on an object of type 'String [JavaScript Object]'

OK, so what happens if we change our scope variable from viewScope to sessionScope?

sessionScope.myVar = "foo";

Same result:

Error calling method 'load()' on an object of type 'String [JavaScript Object]'

My assumption is, this has something to do with the way these objects are serialized. If someone has a better explanation, I’d love to hear it.

In the meantime, don’t give scope variable keys the same name as server side javascript variable.




---------------------
http://xpage.me/2014/07/14/ssjs-variables-vs-scope-variables/
Jul 14, 2014
9 hits



Recent Blog Posts
10
Questions from the DataTables Webinar
Tue, Oct 18th 2016 11:58a   Michael Smith
A
9
Upcoming Webinar: XPages and jQuery DataTables
Tue, Oct 4th 2016 8:39a   Michael Smith
A
13
Adding icon columns to DataTables with FontAwesome
Wed, Sep 14th 2016 1:55a   Michael Smith
A
9
Demo database from my MWLUG session
Thu, Sep 8th 2016 7:11a   Michael Smith
A
11
Slides (and thoughts) from MWLUG – XPages & jQuery DataTables
Wed, Aug 24th 2016 9:49a   Michael Smith
A
12
I’m speaking at MWLUG about…
Wed, Jun 29th 2016 8:41a   Michael Smith
A




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