Wicket developers,
I have a couple of questions about the Wicket code that I'm hoping
someone can answer. These are related to the questions that I had
about models before. I came across these bits of code while trying to
figure out how Wicket handles IComponentAssignedModel and
IComponentInheritedModel.
One thing that caught my eye was this, in Component.detachModel:
// also detach the wrapped model of a component assigned wrap
(not
// inherited)
if (model instanceof IWrapModel &&
!getFlag(FLAG_INHERITABLE_MODEL))
{
((IWrapModel)model).getWrappedModel().detach();
}
Shouldn't IWrapModel be calling detach on the model that it's
wrapping? And in fact, when I looked at the IWrapModel
implementations, every one of them was calling detach on the wrapped
models in their own detach methods. (Even
AttachedCompoundPropertyModel calls detach on its wrapped model even
though this method tries to avoid doing so.) Is this code doing
anything useful?
The other question I have is about AjaxEditableLabel. This class
grabs its own model in its onBeforeRender method and uses the model to
initialize two other components. But what happens if the model that
AjaxEditableLabel finds is a transient IWrapModel created by
IComponentInheritedModel? There must be some reason why Component
removes all the IComponentInheritedModel-created models on detach.
Would there be any downside to just leaving the
IComponentInheritedModel-created models attached to their components
once they've been created?
Thanks in advance,
W