I have the following case:

I have an IAssignmentAwareModel: on assignment, the model creates a wrapper
that is appropriate for a component. If the user assigns this model to a
form, the form ends up with an IWrapModel that is itself an
IInheritableModel: on inheritance, it creates a wrapper for a specific
formComponent.

So the idea is that, when the user does not specify a model for a
formComponent, it ends up with a wrapper provided by the form's model. But
this does not work, because the form's model is at the same time an
IWrapModel. In the code of Component:initModel(), when it comes accross an
IWrapModel, it always gets its nested model, not considering if this model
itself might be an IInheritableModel.

        for (Component current = getParent(); current != null; current =
current.getParent())
        {
                // Get model
                IModel model = current.getModel();

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

                if (model instanceof IInheritableModel)
                {
                        ....
                }
        }

Would it be correct do make the following correction ?

        if (model instanceof IWrapModel && !(model instanceof 
IInheritableModel))
                {
                        model = ((IWrapModel)model).getNestedModel();
                }

Jan.
-- 
View this message in context: 
http://www.nabble.com/Inheritable-model-cannot-be-a-wrap-model-tf3308687.html#a9203428
Sent from the Wicket - Dev mailing list archive at Nabble.com.

Reply via email to