Hi,
I’m trying to advance my knowledge of OOP, as it relates to SC.
I wrote a comment for myself, and for any other developers in my office who may work with this code.
I was hoping you could check it over, and make any corrections to my understanding of what’s going on in the code.
Specifically:
-
Is a widget I create called a “subclass” or an “instance” (or both)?
-
Does the location of Super matter (before or after custom code)?
-
Am I leaving out any important parameters to Super()?
-
Is this the correct way to implement what I’m trying to do in this specific case? Is there a better way?
Thanks,
Mike
isc.Window.create({
ID: "submittedInvoiceWindow",
title: "Submitted Invoices",
autoDraw:false,
items: [submittedInvoiceLayout],
show: function() {
// When we create this isc.Window called "submittedInvoiceWindow"
// we are actually creating a subclass of the class isc.Window
// (...Or is it called an "instance" ? )
// Normally, when we call the "show" method
// it executes the code stored in the parent, or "super" class
// which is usually sufficient and we don't need to mess with it at all
// However, in some cases, the usual course of action is not enough
// and we need to "override" the default behavior
// For instance, in this case, it's not enough to simply
// "show" this Window because the data in its listGrid may have
// become stale since the last time the user viewed and closed
// the window
// (The "submittedInvoiceWindow" instance remains in memory
// even when closed). We can destroy it when closed, but that's
// another topic for later...
// So, we want to add our own code to the "show" method
// to tell the listGrid to refresh its data each time
// However, we don't want to *replace* the default isc code
// We want to run our code *in addition to* the default code
// So we make a call to Super()
// This will run the default isc code
// If we don't include this command
// Our custom code would run, but the original isc code would not!
// The first parameter for super is the original method to call
this.Super('show');
// Now we can include our code below
// We need to refresh the data whenever this window is shown
postedInvoiceList.data.invalidateCache();
// Does it matter if Super() is called first or last?
}
});