Access base class method from multiple subclasses

I have subclassed multiple levels

WebPage->Window1->Window2->Window3->Window4

One or more of the classes in Window1, Window2 and Window3, Window4 have overridden a method in WebPage and then call super.Method.

If I have a Window4 class and wish to call only the base Method in WebPage, how can I do that? Super.Method in a Window4 class will only get something in Window1, Window2, or Window3 (whatever the next one down the chain is)

Dim myWebPage As WebPage= WebPage(Self) myWebPage.Method

No that doesn’t work. I think it is proper for an overridden method to go back up the chain to find the right one to execute, as long as it matches name and arguments.

So in my example above if WebPage has a method called Close and so does Window1, Window2 and Window3 (each with a call to super.Close after the extra work is done), and self is Window4, using your example put me into the method for Window3.Close

I think you’ll need to have a unique base class method that’s not overridden. The point of overriding a base method in a subclass is because the subclass is doing something unique that the base class isn’t.

FWIW, I am curious if you’re really subclassing a Webpage that many times? Or is this a throwaway example? In my experience WebPages and Windows will maybe, sometimes, get a single subclass but never more than that.

I have subclassed WebPage up to 4 levels. My example of the Close method is used especially on the Web project to help it get back to what the proper “previous” page and what it should do with that. I don’t have a close method in each subclass, but I have 2 of them in between WebPage.Close and the existing class. In my one instance I want to perform the Close on Webpage without all the extra stuff happening.

Xojo is very robust in this area (IMO) and works very well with having common code between Web projects and Desktop projects.

I was hoping for a more straightforward solution, but had thought of yours if nothing else was available. Thanks for the conversation.

[quote=413500:@Dan Harding]No that doesn’t work…
[/quote]
You have right, try with this. That works to me.

Dan - you may be able to achieve what you need in a fairly generic (not needing to store class names in constants) with a combination of Introspection and the CurrentMethodName method.

Here’s an example project which shows the idea/pattern:

https://www.dropbox.com/s/7796ssczemd5cul/call_base.xojo_binary_project?dl=0

Apologies in advance for my snake case usage (I’ve been accused of being a parselmouth) and goofy promotional chicken references. I’m a bit loopy/under-the-weather today.

Also - while this should work, Xojo really encourages using events. Using events vs. the “hack” in my sample will likely make your code more accessible to other Xojo developers if you ever want/need to collaborate.

Also, also - Introspection does have some “weight” to it, which is potentially a larger concern in a WebFramework app; be wary of unintentionally creating hundreds (or thousands!) of Introspection objects due to multiple users/sessions.

Anthony