Source vs Build and qx.Class.getByName

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

Source vs Build and qx.Class.getByName

dbrec
Hi all,

I have a problem when generating the build. With source is all OK, but the build not.
The error I receive is "q is not a constructor" in a portion of code where I receivce the name of the class to create the instance (using "qx.Class.getByName"):

				var paneClassObj = qx.Class.getByName(paneClassName);
				paneObj = new paneClassObj();

There is a limitation because the build class names differs from those of the source?
I can change the code by receiving a "mnemonic" string and, using a switch, create the class instance, but if possible I would prefer to let it as it is as (in my opinion) is much "clean".

BR, dbRec
Reply | Threaded
Open this post in threaded view
|

Re: Source vs Build and qx.Class.getByName

Daniel Wagner
Administrator
Hi,

On 23.09.2013 11:28, dbrec wrote:
> Hi all,
>
> I have a problem when generating the build. With source is all OK, but the
> build not.
> The error I receive is "q is not a constructor" in a portion of code where I
> receivce the name of the class to create the instance (using
> "qx.Class.getByName"):
>

Is "q" the value of the string argument passed to getByName when it
throws? And what does the method return? Try setting your browser's dev
tools to "pause on uncaught exceptions" to find out.

>
>
> There is a limitation because the build class names differs from those of
> the source?
> I can change the code by receiving a "mnemonic" string and, using a switch,
> create the class instance, but if possible I would prefer to let it as it is
> as (in my opinion) is much "clean".
>

Class.getByName should work in the build version as well. From your
description, it sounds like the global symbol "q" is overloaded by
something that's not a function.


Regards,
Daniel

> BR, dbRec
>
>
>
> --
> View this message in context: http://qooxdoo.678.n2.nabble.com/Source-vs-Build-and-qx-Class-getByName-tp7584636.html
> Sent from the qooxdoo mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
> 1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
> 2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
> Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13.
> http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>

------------------------------------------------------------------------------
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13.
http://pubads.g.doubleclick.net/gampad/clk?id=58041151&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: Source vs Build and qx.Class.getByName

Richard Sternagel
In reply to this post by dbrec
Hi dbrec,

so here is my assumption:

It seems that somehow during the "source" run the class in question was
included and during "build" it wasn't. The "q is not a constructor"
message (more precisely the "q") is likely coming from the variable
renaming [1].

I'm just guessing but could it be that you have run "./generate source"
changed some code and then run "./generate build"? Because then I am
able to reproduce this:

# source run => everything works:
---
var abc = new ml_23sept.MyClass();
var myClass = qx.Class.getByName("ml_23sept.MyClass");
var object = new myClass();
object.doSomething();
---

vs. afterwards

# build run => "myClass is not a constructor" resp. "q is not ...":
---
// var abc = new ml_23sept.MyClass();  --> line is commented out
var myClass = qx.Class.getByName("ml_23sept.MyClass");
var object = new myClass();
object.doSomething();
---

Because of the commented out line "ml_23sept.MyClass" isn't seen by the
Generator and therefore it won't be included in the generated script
file - and will be missing during runtime.

So in order to force the Generator to always include a certain class you
could for example attach to the enclosing method/class JSDoc comment
something like that [2]:

---
/**
  * ...
  * @use(ml_23sept.MyClass)
  * ...
  */
---

But this should be used with caution because it obviously leads to
bloated script files, which stupidly include all the classes you asked
for, somewhere in your code.

Another option would be to make sure, that the classname/s is/are always
referenced somewhere else in the code and thus the Generator is able to
pick them up, e.g.:

---
var foo = {
   "bar": ml_23sept.MyClass
};
---

Maybe that helps.

Regards
Richard

[1]
http://manual.qooxdoo.org/3.0.1/pages/tool/generator/generator_optimizations.html#variables
[2] http://manual.qooxdoo.org/3.0.1/pages/development/api_jsdoc_ref.html#use

------------------------------------------------------------------------------
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13.
http://pubads.g.doubleclick.net/gampad/clk?id=58041151&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: Source vs Build and qx.Class.getByName

dbrec

The class that call the qx.Class.getByName does not contains any reference to the class to be created (like the case of "var abc = new ml_23sept.MyClass();" commented out): is a child object that, via events, tell which class (by name)  has to be instantiated.

So, this is the reason why is not working as I expected?


Il giorno 23/set/2013, alle ore 17:34, Richard Sternagel <[hidden email]> ha scritto:

> Hi dbrec,
>
> so here is my assumption:
>
> It seems that somehow during the "source" run the class in question was
> included and during "build" it wasn't. The "q is not a constructor"
> message (more precisely the "q") is likely coming from the variable
> renaming [1].
>
> I'm just guessing but could it be that you have run "./generate source"
> changed some code and then run "./generate build"? Because then I am
> able to reproduce this:
>
> # source run => everything works:
> ---
> var abc = new ml_23sept.MyClass();
> var myClass = qx.Class.getByName("ml_23sept.MyClass");
> var object = new myClass();
> object.doSomething();
> ---
>
> vs. afterwards
>
> # build run => "myClass is not a constructor" resp. "q is not ...":
> ---
> // var abc = new ml_23sept.MyClass();  --> line is commented out
> var myClass = qx.Class.getByName("ml_23sept.MyClass");
> var object = new myClass();
> object.doSomething();
> ---
>
> Because of the commented out line "ml_23sept.MyClass" isn't seen by the
> Generator and therefore it won't be included in the generated script
> file - and will be missing during runtime.
>
> So in order to force the Generator to always include a certain class you
> could for example attach to the enclosing method/class JSDoc comment
> something like that [2]:
>
> ---
> /**
>  * ...
>  * @use(ml_23sept.MyClass)
>  * ...
>  */
> ---
>
> But this should be used with caution because it obviously leads to
> bloated script files, which stupidly include all the classes you asked
> for, somewhere in your code.
>
> Another option would be to make sure, that the classname/s is/are always
> referenced somewhere else in the code and thus the Generator is able to
> pick them up, e.g.:
>
> ---
> var foo = {
>   "bar": ml_23sept.MyClass
> };
> ---
>
> Maybe that helps.
>
> Regards
> Richard
>
> [1]
> http://manual.qooxdoo.org/3.0.1/pages/tool/generator/generator_optimizations.html#variables
> [2] http://manual.qooxdoo.org/3.0.1/pages/development/api_jsdoc_ref.html#use
>
> ------------------------------------------------------------------------------
> LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
> 1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
> 2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
> Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13.
> http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&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: Source vs Build and qx.Class.getByName

dbrec
In reply to this post by Richard Sternagel
Re-post because it seems that the last post was not sent to the mailing list:

The class that call the qx.Class.getByName does not contains any reference to the class to be created (like the case of "var abc = new ml_23sept.MyClass();" commented out): is a child object that, via events, tell which class (by name)  has to be instantiated.

So, this is the reason why is not working as I expected?
Reply | Threaded
Open this post in threaded view
|

Re: Source vs Build and qx.Class.getByName

Thomas Herchenroeder
If there is nowhere in your app a reference to the class you want to
retrieve with .getByName you have to resort to the @use(<classname>) JSDoc
hint Richard wrote about earlier. (You would not need this for the source
version if that was created by a 'source-all' job, as it then included all
classes anyway).

T.

> Re-post because it seems that the last post was not sent to the mailing
> list:
>
> The class that call the qx.Class.getByName does not contains any reference
> to the class to be created (like the case of "var abc = new
> ml_23sept.MyClass();" commented out): is a child object that, via events,
> tell which class (by name)  has to be instantiated.
>
> So, this is the reason why is not working as I expected?
>
>
>
> --
> View this message in context:
> http://qooxdoo.678.n2.nabble.com/Source-vs-Build-and-qx-Class-getByName-tp7584636p7584656.html
> Sent from the qooxdoo mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
> from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>
>



------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel