I think it is wrong that the getWrappedModel() returns null it is pretty much the contract that it has to return the model that it wraps around it is used in more places. (set model, inner model or getInnerMostModel)
and no if the model is not a inherited model but a component assign aware model then i want to handle the detach directly else every kind of implementation has to do it themselfs that will be forgotton now and then. johan On 7/9/07, Jan Vermeulen <[EMAIL PROTECTED]> wrote:
Following code provokes a NPE the wrappedModel is null: // also detach the wrapped model of a component assignet wrap (not inherited) if (model instanceof IWrapModel && !getFlag(FLAG_INHERITABLE_MODEL)) { ((IWrapModel)model).getWrappedModel().detach(); } We have that case because we have an IContextWrapModel that wraps models that are stored in a context outside of the component graph. It lazily looks up the model by key in the context, and in its detach() it does the following: public void detach() { if (wrappedModel instanceof IContextModel) wrappedModel = null; } Two questions: (1) Would it not be more correct to leave the 'detach' responsability to the wrapModel implementation ? (2) If not, can there be a check for null pointers in the code above ? Jan -- View this message in context: http://www.nabble.com/NPE-in-Component.detachModel%28%29-when-wrappedModel-is-null-tf4048326.html#a11499084 Sent from the Wicket - Dev mailing list archive at Nabble.com.