Form Inheritance Bug with "this"

I’ve got an interesting form inheritance issue that only seems to happen under this unique situation. Basically, it seems that _super.methodName() in conjunction with the “this” keyword, seems to run out of context (at least in my opinion). Below is an example.

First, a global function, globals.Test1:

function global.test1(formObj){
    application.output(formObj.formVar1)
}

Next, a base/parent form, lets call it Parent1, has something like this, where formVar1 is a form var:

var formVar1 = null; //formVariable

function test(){
  globals.test1(this)
}

Finally, the child form, which extends Parent1, lets call it Child1:

//override parent method
function test(){
   _super.test()
}

//override form var
function onLoad(){
   formVar1 = "some value"
}

So, if you run forms.Child1.test() it will error. When it reaches the global method, its seems to have lost context. The value of formVar1 gets overridden on the child form, and if you test its value in the Parent1 form it also has the proper overridden value. However, when it reaches the global, it seems that when passing in “this” isn’t actually passing in the proper context and so the form variable isn’t showing as set. Seems like its getting a handle to the wrong instance. So, overriding the form variable works in Parent and Child as expected, but when the Parent form passes in “this” then it gets screwed up. If I pass in “this” from the Child form, then its fine, but I need it from the parent form.

Without this working, it makes some framework code more difficult :(

i fixed this for 6 (RC3) at the moment, so that the super scope “this” will behaves as much as the normal this of the actual form.

problem is that i don’t know completely if there will be side effects i think they are minimal and what still doesn’t work is stuff like:

function functionInSuperForm()
{
this.functionOverWrittenInSubForm()
}

where functionOverWrittenInSubForm is a function of the super and the sub. then when called in the super it will call directly the super code. Not first the sub’s code. this is the way rhino works and is quite hard to go around (without hacking it in rhino itself)

that will only be a problem if you use “this” though right? so if I have

ChildForm:

function test2(){
   //something
}

SuperForm:

function test1(){
   test2()
}

function test2(){
   //something
}

and I call forms.childForm.test1() It will execute the test2() in the child form right? not in the parent? otherwise that would be even worse.

that will work fine,

even in your example if this was the superforms test1:

function test1(){
   this.test2()
}

that would still work fine.

it only fails if you are already in a _super.xxx() call and that call does this.yyyy() and yyyy is also in a sub, then that is not called.