Hey,
this sounds in deed like something not easy to do. I can only imagine a dirty
solution where your code just takes a couple of arguments and passing them in.
But if your class has more arguments than you specified, the code will sure not
work.
var obj = new classFn(obj,myArr[0], obj,myArr[1], obj,myArr[2], obj,myArr[3],
obj,myArr[4], obj,myArr[5], obj,myArr[6], obj,myArr[7], obj,myArr[8],
obj,myArr[9]);
This works for 10 arguments which should be more than enough for reasonable
classes. As I said, it is a hack but at least its working for 95% of the
classes.
Best,
Martin
Am 20.09.2010 um 09:57 schrieb benco:
>
> Hi,
>
> I'm currently working on a widget factory that use definition maps as
> config.
>
> As these config maps must be created before my app launches and qx
> initializes, I use strings and array following this example:
>
> {class:"some qx className", args:[ contructor args]}
>
> The problem is I don't know how to call the constructor properly after
> finding the class by its string name.
>
> When working with functions for instance, it is possible to use the apply
> method of the function object to pass arguments as arrays :
> my_fun.apply(target_obj, args);
>
> However, it seems impossible in the case of new objects creation.
>
> The only thing I'm able to do is to initilalize a new object first, then
> call its constructor method once again with the array args (even though it's
> a very special case - this workaround won't work in many cases):
>
> var obj = new classFn();
> obj.constructor.apply(obj,myArr);
>
> Any Ideas or solutions ?
>
> Many thanks in advance for your help,
>
> Best,
>
> BenoƮt.
>
> --
> View this message in context:
> http://qooxdoo.678.n2.nabble.com/pure-js-how-to-create-a-new-object-by-passing-args-as-array-tp5549420p5549420.html
> Sent from the qooxdoo mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing.
> http://p.sf.net/sfu/novell-sfdev2dev
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel