Hi
I can make the eval technique work but I cannot make the map technique 
work because it always gives an error about string type.

var lcWin = 
qx.core.Init.getApplication().__frmDesktop.getActiveWindow().classname;
                 var lcClass =
var map = {
     'somekey' : 
lcWin.substr(0,lcWin.indexOf("."))+".con"+lcWin.substr(lcWin.indexOf(".")+4)+"_"+this.getLabel(),
     'otherkey' : dcbase.otherTypeOfButton
  };

Simon

On 23/12/2011 2:04 PM, Greg Hellings wrote:
> You can do this a number of ways depending on your need.
>
> With an associative array/map object:
> var map = {
>    'somekey' : dcbase.myCustomerButton,
>    'otherkey' : dcbase.otherTypeOfButton
> };
>
> var val = 'somekey';
> var lcClass = new (map[val])();
>
> Or you could do it with a call to eval:
>
> var classToCreate = 'dcbase.myCustomerButton';
> var lcClass = eval('new ' + classToCreate + '()');
>
> Or you could do it, similar to the first technique, but with a factory
> method (probably attached statically to a parent class of all the
> objects you might create in this instance).
>
> --Greg
>
> On Fri, Dec 23, 2011 at 12:58 PM, Simon White
> <[email protected]>  wrote:
>> Hi
>>
>> I would like to be able to create a new class by building the class name
>> at runtime as opposed to hard coding the class in code.  Can this be done?
>>
>> For example instead of
>>
>> var lo = new dcbase.myCustomerButton();
>>
>> I would like to do the following:
>>
>> var lcClass = myWindow.Classname.substr(1,8)+"_con"+myButton.getLabel()
>>
>> var = new lcClass;
>>
>> Thanks,
>> Simon
>>
>>
>> ------------------------------------------------------------------------------
>> Write once. Port to many.
>> Get the SDK and tools to simplify cross-platform app development. Create
>> new or port existing apps to sell to consumers worldwide. Explore the
>> Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
>> http://p.sf.net/sfu/intel-appdev
>> _______________________________________________
>> qooxdoo-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
> ------------------------------------------------------------------------------
> Write once. Port to many.
> Get the SDK and tools to simplify cross-platform app development. Create
> new or port existing apps to sell to consumers worldwide. Explore the
> Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
> http://p.sf.net/sfu/intel-appdev



------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to