We (igor and me) talked about it and we let developers of models control
what they want
if we unwrap it then it is really final. Now they can control and do
anything they want
by also implementing the wrap models right, for example let them implement
again the IInheritanceAware or IAssignmentAware
So they can do exactly what they want if the notice that the wrap model is
again assigned to something.

johan



On 10/1/06, Martijn Dashorst <[EMAIL PROTECTED]> wrote:

I think I have found a discrepancy in the setModel implementation.

I think that if the new model is also an Wrapped model, then it should
be normalized to its nested model, before the IAssignmentAware check.

From Component:

public Component setModel(final IModel<T> model)
{
    // Detach current model
    if (this.model != null)
    {
        this.model.detach();
    }

    IModel prevModel = this.model;
    if (prevModel instanceof IWrapModel)
    {
        prevModel = ((IWrapModel)prevModel).getNestedModel();
    }

+    // normalize the new model to the nested
+    if(model instanceof IWrapModel)
+    {
+        model = ((IWrapModel)model).getNestedModel();
+    }

    // Change model
    if (prevModel != model)
    {
        if (prevModel != null)
        {
            addStateChange(new ComponentModelChange(prevModel));
        }

        if (model instanceof IAssignmentAware)
        {
            this.model =
((IAssignmentAware<T>)model).wrapOnAssignment(this);
        }
        else
        {
            this.model = model;
        }
    }

    modelChanged();
    return this;
}


--
<a href="http://www.thebeststuffintheworld.com/vote_for/wicket";>Vote</a>
for <a href="http://www.thebeststuffintheworld.com/stuff/wicket
">Wicket</a>
at the <a href="http://www.thebeststuffintheworld.com/";>Best Stuff in
the World!</a>

Reply via email to