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 5
Upcoming Webinar: XPages and jQuery DataTables
Tue, Oct 4th 2016 3
Adding icon columns to DataTables with FontAwesome
Wed, Sep 14th 2016 4
Demo database from my MWLUG session
Thu, Sep 8th 2016 2
Slides (and thoughts) from MWLUG – XPages & jQuery DataTables
Wed, Aug 24th 2016 8
I’m speaking at MWLUG about…
Wed, Jun 29th 2016 5
XPage loading slow? Check your document datasource
Wed, Dec 16th 2015 5
Top 10
My first OpenNTF project – Dojo Name Picker
Fri, Jul 25th 2014 8
My first #MWLUG … what was I waiting for?
Sun, Aug 23rd 2015 8
Slides (and thoughts) from MWLUG – XPages & jQuery DataTables
Wed, Aug 24th 2016 8
Modernizing A Notes App With XPages (MANA-X) Part 1 – Introduction
Wed, Sep 3rd 2014 6
XPage loading slow? Check your document datasource
Wed, Dec 16th 2015 5
I’m speaking at MWLUG about…
Wed, Jun 29th 2016 5
Questions from the DataTables Webinar
Tue, Oct 18th 2016 5
XPages tip: Using jQuery class selectors with hidden inputs
Mon, Aug 18th 2014 4
Adding icon columns to DataTables with FontAwesome
Wed, Sep 14th 2016 4
SSJS variables vs. scope variables
Mon, Jul 14th 2014 3


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
4 hits



Recent Blog Posts
5
Questions from the DataTables Webinar
Tue, Oct 18th 2016 11:58a   Michael Smith
A
3
Upcoming Webinar: XPages and jQuery DataTables
Tue, Oct 4th 2016 8:39a   Michael Smith
A
4
Adding icon columns to DataTables with FontAwesome
Wed, Sep 14th 2016 1:55a   Michael Smith
A
2
Demo database from my MWLUG session
Thu, Sep 8th 2016 7:11a   Michael Smith
A
8
Slides (and thoughts) from MWLUG – XPages & jQuery DataTables
Wed, Aug 24th 2016 9:49a   Michael Smith
A
5
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