I'm trying to mimic Java-style class inheritance and I thought I'd gotten it. However, I'm having an issue that when I create multiple instance of the same Javascript class, all instances are sort of created the same.
Here is the situation.
I have a Javascript class called Screen
:
function Screen(screenName) {
this.current = new DataResultSet(); // this is a java class
this.current.setScreenName(screenName);
}
Screen.prototype.GetScreenName= function() {
return this.current.getScreenName();
}
Screen.prototype.GetFieldValue= function(name) {
return this.current.getValue(name);
}
// some other functions that can be called that utilize the current object.
This is the inherited class:
function screenSub1() {}
screenSub1.prototype=new Screen("screenSub1");
screenSub1.prototype.GetID = function() { return GetFieldValue("ID"); }
// some other functions that can be called, specific to this class
Now, in my code, if I do
var obj = new screenSub1();
var obj2 = new screenSub1();
The underlying "current" object for both objects are the same! Is there anyway to get around this issue? Thanks!
Julia