[Laszlo-user] suggested way to check for class type in Wafflecone?

P T Withington ptw at openlaszlo.org
Thu Aug 30 08:20:10 PDT 2007


On 2007-08-30, at 10:01 EDT, Elliot Winard wrote:

> I have some window management code that iterates through an array  
> of different windows & switches on the exact window type.
>
> It used to work with code like this -
>           var w=getNextWindow();
>
>            // classname can be composewindow, mailwindow,  
> contactswindow
>            if(w.classname == "composewindow")  
> {                              return w;
>            }
>
> This stopped working because w.classname is now Object.  
> w.constructor.classname is, however, 'composewindow'
>
> What's the right way to do this?  Should obj.classname be the same  
> as obj.constructor.classname?
> I want to make sure this works when & if OpenLaszlo is updated.

I think what you really want to do is say:

   if (w instanceof lz.composewindow) {

The fact that there is a classname property on instances is an  
accident of Javascript inheritance.


More information about the Laszlo-user mailing list