Hi
Thanks to you and Greg for your very helpful advice. I now have two
ways to accomplish my goal without using eval. I can pass in the class
name as part of the tmConfig map or I can use the qx.Class.getByName.
Below I have included my code for my tabPage class and it works like a
charm.
qx.Class.define("dcbase.pgStd",
{
extend : qx.ui.tabview.Page,
construct : function (tmConfig)
{
this.base(arguments);
this.setPaddingTop(0);
this.setLayout(new dcbase.layCanvas())
this.getChildControl("button").addListener("activate",function(e){
if (!this.hasChildren())
{
this.__conPresObj = new tmConfig.dcClass();
// var lcWin =
qx.core.Init.getApplication().__frmDesktop.getActiveWindow().classname;
// var clazz =
qx.Class.getByName(lcWin.substr(0,lcWin.indexOf("."))+".con"+lcWin.substr(lcWin.indexOf(".")+4)+"_"+this.getChildControl("button").getLabel());
// this.__conPresObj = new clazz();
this.add(this.__conPresObj);
}
},this)
if (tmConfig != undefined && tmConfig.set != null)
this.set(tmConfig.set);
}
});
On 23/12/2011 3:34 PM, Derrell Lipman wrote:
> On Fri, Dec 23, 2011 at 13:58, Simon White
> <[email protected]
> <mailto:[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;
>
>
> Simon, it looks like you are trying to instantiate an existing class,
> rather than create a new class as you'd stated. Am I correct?
>
> To instantiate your IcClass class, you should be able to do something
> like this:
>
> var clazz = qx.Class.getByName(IcClass);
> var myIcClassInstance = new clazz();
>
> Note that if there are no references to some of your classes, i.e., the
> only access to them is via getByName(), then the generator will not
> automatically include them in your build. In that case, you should add
> #use entries to one of your Application.js file, for each of those
> classes that the generator can't detect automatically.
>
> Derrell
>
>
>
> ------------------------------------------------------------------------------
> 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
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel