wicket-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Igor Vaynberg" <igor.vaynb...@gmail.com>
Subject another big 2.0 refactor
Date Fri, 05 Jan 2007 01:29:51 GMT
ive been discussing with johan offline, and here is what we came up with

there is still a big onattach refactor to do in 2.0. big meaning it will
affect a lot of users.

the contract for onattach/ondetach was that these methods are called before
the framework executes any method on the component, but right now onattach
is pretty much onbeginrender with the exception that you are allowed to
modify the component hieararchy.

take a simple case of clicking link.

the story should be:

currently it is

1) resolve link component
2) invoke onclick
3) invoke onattach
4) invoke onbeforerender
5) invoke render
6) invoke onafterrender
7) invoke ondetach

but should be

1) resolve link component
2) invoke onattach
3) invoke onclick
4) invoke onbeforerender
5) invoke render
6) invoke onafterrender
7) invoke ondetach

notice 2 and 3 are reversed as per contract of onattach
but there is a problem with this. suppose link has a compound model, and
inside the link you call getmodelobject() since the model belongs to link's
parent shouldnt link parent's onattach be called as well? the contract says
so.

the only way to guarantee onattach contract is to alter the event chain to
this

1) resolve link component
2) invoke page.onattach
3) invoke onclick
4) invoke onbeforerender
5) invoke render
6) invoke onafterrender
7) invoke page.ondetach

this means that all code that is in onattach needs to move to onbeforerender
and onbeforerender needs to be relaxed to allow changes in the component
hierarchy, while onattach should not allow modification of hierarchy. this
restriction is necessary so, for example, link's parent doesnt remove the
link before onclick is invoked on it.

invocation chain for a page set into the request cycle via setresponsepage()
would be the same but with step 3 taken out.

the refactor itself will be pretty easy
make onbeforerender final - this will make all overrides visible
move code from overrides to onattach
delete onbeforerender
rename onattach to onbeforerender
create new onattach


thoughts?



-igor

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message