but now that i think about it, i think i would be ok with removing
onattach() altogether. the reason is that it can be quite wasteful. when
invoking a simple listener, like link's onclick we have to attach the
entire
page, and i think most of that will go to waste. i think a lazy-load
pattern, just like the one we use in models works much better here and
maybe
we should force it onto our users. i would like to see if anyone can come
up
with viable usecases for the onattach() within this new definition.
one usecase is our own usecase. I agree with you that developers don't use
it
But we need it. We need to know if a page is attached. or better said if
components
are in an attached state or not. So that we can call detach() on it.
detach for example should return a boolean so that a user knows that it also
have to
detach its models things or what ever he wants there or not i think.
boolean Component.detach()
{
if(TEST_ATTACHED_FLAG)
{
detachModels()
detachXXX();
setATTACHEDFLAG(false)
return true;
}
return false
}
then developers can do this:
boolean MyComponent.detach()
{
if(super.detach())
{
// own detach
return true;
}
return false;
}
Then we don't have that problem of double detach() calls anymore.