Greetings,
I'm having trouble seeing the base class method if I've overriden it...I am not sure what I'm doing wrong. I've tried to study how the Atlas framework is using it, but nothing is working. Here's my code:
Type.registerNamespace("Juicy.Collections");
Juicy.Collections.ArrayList = function() {
var _items = new Array();
this.get_item = function(i) { return _items; }
this.get_length = function() { return _items.length; }
this.add = function(item) { _items.add(item); }
this.clear = function() { _items.clear(); }
this.dispose = function() { for (var i = 0; i < _items.length; i++) { _items.dispose(); _items = null; } _items.clear(); }
}
Type.registerClass("Juicy.Collections.ArrayList", null, Web.IDisposable);
Type.registerNamespace("Juicy.UI");
Juicy.UI.TabPageCollection = function(owner) {
Juicy.UI.TabPageCollection.initializeBase(this);
var _owner = owner;
this.add = function(tabPage) { Juicy.UI.TabPageCollection.callBaseMethod(this, "add", tabPage); } // The callBaseMethod always evaluates to null.
Juicy.UI.TabPageCollection.registerBaseMethod(this, "add"); }
Type.registerClass("Juicy.UI.TabPageCollection", Juicy.Collections.ArrayList);
// Code to test the above. The get_length() works fine, but the add does not increment properly.
var tabPages = new Juicy.UI.TabPageCollection();
tabPages.add("foo");
alert(tabPages.get_length());
I want the "add" method in TabPageCollection to do some work, and then call the inherited add. But the callBaseMethod does not resolve.
Any ideas anyone? This is driving me nuts here.
Thanks,
William
Just as an idea, wouldn't it be more intuitive for the derived class to have syntax/method indicating that it is overriding the base? I can't off the top of my head think of how this could be done, but it took me awhile to figure out how the current manner works. Perhaps Type.overrideMethod(this, methodName, someFunctionReference).
Thanks,
William
You need to register the base method in the ArrayList class.
Juicy.Collections.ArrayList.registerBaseMethod(this, 'add');
Then your callBaseMethod should start resolving. However, you need to make one more small tweak - the arguments to the base method are passed as an array of arguments. So you would have:
Juicy.UI.TabPageCollection.callBaseMethod(this, 'add', [tabPage]);
No comments:
Post a Comment