global variables in qooxdoo


Declare the variables in your Application class:

qx.Class.define("custom.Application",
{
extend : qx.application.Standalone,

members :
{
/** My global variable */
bGlobal : true

main : function()
{
// access to global variable from within this class using "this"
this.bGlobal = false;
}
}
}

Then you can access that main application class using qx.core.Init.getApplication() so in some other class, you can read the global like this:

qx.Class.define("custom.SomeArbitraryClass",
{
extend : qx.core.Object,

construct : function()
{
/** Access the global variable */
if (qx.core.Init.getApplication().bGlobal)
{
alert("The global is TRUE");
}
}

You could also have made that global be a property of the Application class:
qx.Class.define("custom.Application",
{
extend : qx.application.Standalone,

properties :
{
/** My global variable */
global : true
...

in which case you'd reference it from the other class using the property's getter:

qx.core.Init.getApplicaiton().getGlobal()

Hope that helps.

Derrell

Advertisements

Published by

paragasu

Different. In a good way

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s