Attempting to split Application.js

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Attempting to split Application.js

Peter Caffin
Hi guys.

I'm using Qooxdoo 3.0.1, and trying to split my Application.js. It's not
working, and I'm probably doing (or not doing) something obvious.

In source\class\padded_online\Application.js, if I use:

var hm_5 = new qx.ui.menu.Button("Test"); fileMenu.add(hm_5);
hm_5.addListener("execute", padded_online.Dialogs.testFunction, this);

I get the error:

002126 Assertion error! Failed to add event listener for type 'execute'
to the target 'qx.ui.menu.Button': Invalid callback function: Expected
value to be typeof function but found 'undefined'!

If instead, I abandon the listener and try to call it directly:

padded_online.Dialogs.testFunction();

I get the error:

Uncaught TypeError: Object function ()
       {
         var clazz = wrapper;
[...]

My Dialog.js is below. It seems to be parsed by "generate.py source" okay.

All suggestions warmly welcomed.

Thanks.

====source\class\padded_online\Dialog.js====

qx.Class.define("padded_online.Dialogs",
{
   extend: padded_online.Application,
   construct: function()
   {

   },
   members :
   {
     testFunction: function()
     {
       alert("Test!");
       return;
     }
   }
});


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Attempting to split Application.js

thron7
Is it Dialog.js or Dialogs.js? Are you sure 'generate.py source'
doesn't emit any warnings?

T.

On Tue, Feb 18, 2014 at 4:55 PM, Peter Caffin <[hidden email]> wrote:

> Hi guys.
>
> I'm using Qooxdoo 3.0.1, and trying to split my Application.js. It's not
> working, and I'm probably doing (or not doing) something obvious.
>
> In source\class\padded_online\Application.js, if I use:
>
> var hm_5 = new qx.ui.menu.Button("Test"); fileMenu.add(hm_5);
> hm_5.addListener("execute", padded_online.Dialogs.testFunction, this);
>
> I get the error:
>
> 002126 Assertion error! Failed to add event listener for type 'execute'
> to the target 'qx.ui.menu.Button': Invalid callback function: Expected
> value to be typeof function but found 'undefined'!
>
> If instead, I abandon the listener and try to call it directly:
>
> padded_online.Dialogs.testFunction();
>
> I get the error:
>
> Uncaught TypeError: Object function ()
>        {
>          var clazz = wrapper;
> [...]
>
> My Dialog.js is below. It seems to be parsed by "generate.py source" okay.
>
> All suggestions warmly welcomed.
>
> Thanks.
>
> ====source\class\padded_online\Dialog.js====
>
> qx.Class.define("padded_online.Dialogs",
> {
>    extend: padded_online.Application,
>    construct: function()
>    {
>
>    },
>    members :
>    {
>      testFunction: function()
>      {
>        alert("Test!");
>        return;
>      }
>    }
> });
>
>
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
> http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Attempting to split Application.js

Peter Caffin
On Sun, 23 Feb 2014, thron7 wrote:
> Is it Dialog.js or Dialogs.js?

Dialogs.js

Does the filename actually make a difference?

> Are you sure 'generate.py source' doesn't emit any warnings?

It does list this one warning, but I didn't think it was relevant to
the topic.

  - Warning: padded_online.Dialogs (19, 7): Deprecated global symbol
used: 'alert'

It does show the file and function have been read, I guess :)

------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Attempting to split Application.js

Richard Sternagel
Hi Peter,

> Does the filename actually make a difference?

Yes it does. Keep it always in sync with the class name.

But this wasn't your initial issue - it's an OO misunderstanding
(or you just forgot "new" :D).

Either do it like this:

.---
| ...
| button1.addListener("execute", padded_online.Dialogs.TESTFUNC, this);
| ...

.---
| qx.Class.define("padded_online.Dialogs",
| {
|    extend: padded_online.Application,
|    construct: function()
|    {
|
|    },
|    members :
|    {
|      testFunction: function()
|      {
|        alert("Test member func!");
|        return;
|      }
|    },
|
|    statics :
|    {
|      TESTFUNC: function()
|      {
|        alert("Test static func!");
|      }
|    }
| });
|

Hint: "return;" makes no sense. In JavaScript functions without return
statements are returning undefined by default, which you are doing
explicitly.

or like that:

.---
| ...
| var dialogs = new padded_online.Dialogs();
| button1.addListener("execute", dialogs.testFunction, this);
| ...

Regards
Richard

------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Attempting to split Application.js

thron7
On Mon, Feb 24, 2014 at 11:40 AM, Richard Sternagel
<[hidden email]> wrote:

> Hi Peter,
>
>> Does the filename actually make a difference?
>
> Yes it does. Keep it always in sync with the class name.
>
> But this wasn't your initial issue - it's an OO misunderstanding
> (or you just forgot "new" :D).
>
> Either do it like this:
> ...

To put it in other words:

You cannot call an instance method (from the "member" section) as a
static method on the class itself. Either make it a static method, or
create an instance of the class first.

(But you might want to consider opening a bug for a better error
message in such a case ;-).

T.

------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Attempting to split Application.js

Peter Caffin
In reply to this post by Richard Sternagel
Hi guys.

Thank you both for your assistance :)

Richard Sternagel wrote:
> But this wasn't your initial issue - it's an OO misunderstanding
> (or you just forgot "new" :D).

Thanks for that excellent explanation. Definitely a Javascript OO
misunderstanding, I think :)

thron7 wrote:
> To put it in other words:
>
> You cannot call an instance method (from the "member" section) as a
> static method on the class itself. Either make it a static method, or
> create an instance of the class first.
>
> (But you might want to consider opening a bug for a better error
> message in such a case .

I'll wait a little before I do. Hard to say from here whether it's not
quite clearly worded or if it's just my inexperience with Javascript :)

Thanks.

------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel