|
#1
|
|||
|
|||
|
I have an array of widgets containing DynamicForms and ListGrids.
I do a for( var widget in widgetsArray ) and my first "widget" is the field "class" with a value of "Array". I pass this to DynamicForm.isA() and it returns TRUE. It's a string, not a form. ---- While this is still true, my usage was wrong. widget is always a string. Now I'm calling DynamicForm.isA(widgetsArray[widget]) and the isA function returns false for the string "Array". I guess it's returning true for the string "class". Last edited by tgochenour; 13th Feb 2007 at 12:22.. |
|
#2
|
|||
|
|||
|
isc.DynamicForm.isA("Class") with uppercase "Class" is true and should be true, since DynamicForm extends the base class "Class".
But your original problem is that you should not be doing for..in iteration on Arrays; for..in iteration should be only be used with Objects This is because many frameworks add properties and methods to the global Array object that you will hit if you use for..in iteration. Instead, use classic iteration: Code:
for (var i = 0; i < widgetsArray.length; i++) {
var widget = widgetsArray[i];
}
|
|
#3
|
|||
|
|||
|
Right. Thing about Javascript is that an Array and an Object are the same thing. My usage is with an Object taking the form of a HashMap and instantiated with "widgetArray = []". I don't have a numerical array to use the classic iterator on. I have a HashMap where the field names are keys and the field values are the references.
That's why I'm using "for widget in widgetArray". Anyway, DynamicForm.isA("Class") returns TRUE because a form extends Class, even though the string "Class" isn't a DynamicForm? OK. My usage was wrong anyway. Now that I'm using widgetArray[widget] the isA function skips over the Class="Array" attribute just fine. |
|
#4
|
|||
|
|||
|
In JavaScript, all Arrays are Objects but not all Objects are Arrays. When you want something comparable to a Java HashMap, use "widgetMap = {}" (note curly braces), which creates an Object rather than an Array. With an Object, for..in iteration will reveal only the properties you set.
isc.DynamicForm.isA() takes a className, and is an API oriented toward introspection of the class hierarchy. You may be confusing it with isc.isA.DynamicForm(), which is used for detecting DynamicForm instances. |
|
#5
|
|||
|
|||
|
isc.isA.DynamicForm() is not present in the documentation at http://www.smartclient.com/docs/5.5....ml#object..isA
This is why I'm using the isc.DynamicForm.isA() variety. |
|
#6
|
|||
|
|||
|
From that doc:
Quote:
|
|
#7
|
|||
|
|||
|
I wasn't reading the overview. I was looking at the Class APIs.
My bad. |