You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Johan Compagner <jc...@gmail.com> on 2007/07/18 15:14:29 UTC

getWrappedModel and getChainedModel (Component.getInnerMostModel())

we have this code in Component:

protected final IModel getInnermostModel(final IModel model)
    {
        IModel nested = model;
        while (nested != null && nested instanceof IWrapModel)
        {
            final IModel next = ((IWrapModel)nested).getWrappedModel();
            if (nested == next)
            {
                throw new WicketRuntimeException("Model for " + nested + "
is self-referential");
            }
            nested = next;
        }
        return nested;
    }

we also have IChainingModel shouldn't we also test for that?
because çurrently the behavior is that we only test for WramModels to get to
the innermost model
but what is then the big difference with IChainingModel?

johan

Re: getWrappedModel and getChainedModel (Component.getInnerMostModel())

Posted by Igor Vaynberg <ig...@gmail.com>.
hmmm

this is a tough one, it really depends on the definition of innermost model.
the nomenclature in place is not the best, but its very difficult to come up
with good words for all this stuff we are doing with models.

it really depends on how transparent we want ichainingmodel to be. so far
innermost model only unwraps layer that wouldve been placed there
automatically by wicket, and i am inclined to say it should probably stay
that way. ichainingmodel is a convinience interface - it brings a standard
to a common type of model - that decorates another. i dont know if we should
be unwrapping it.

in johan's example MyChainingModel is probably opaque to wicket, im not sure
hibernatemodel should be returned there.

-igor


On 7/20/07, Eelco Hillenius <ee...@gmail.com> wrote:
>
> > Component comp = new Component(new MyChainingModel(new
> HibernateModel(new
> > Pojo())));
> >
> > IModel model = comp.getInnerMostModel()
>
> Naively, just looking at the code, I would expect the HibernateModel to
> return.
>
> Eelco
>

Re: getWrappedModel and getChainedModel (Component.getInnerMostModel())

Posted by Eelco Hillenius <ee...@gmail.com>.
> Component comp = new Component(new MyChainingModel(new HibernateModel(new
> Pojo())));
>
> IModel model = comp.getInnerMostModel()

Naively, just looking at the code, I would expect the HibernateModel to return.

Eelco

Re: getWrappedModel and getChainedModel (Component.getInnerMostModel())

Posted by Johan Compagner <jc...@gmail.com>.
nope
not the IChainingModel
i think that was igor.
And also the getInnerMostModel() code is something i think from jonathan.

And IChainingModel is much more the replacement of IModel.getNestedModel()
then that IWrapModel is.. (thats really a new thing in 1.3)

So what do people expect here:

Component comp = new Component(new MyChainingModel(new HibernateModel(new
Pojo())));

IModel model = comp.getInnerMostModel()
??


johan


On 7/20/07, Eelco Hillenius <ee...@gmail.com> wrote:
>
> > we also have IChainingModel shouldn't we also test for that?
> > because çurrently the behavior is that we only test for WramModels to
> get to
> > the innermost model
> > but what is then the big difference with IChainingModel?
>
> Hey, didn't you code that stuff? :)
>
> Eelco
>

Re: getWrappedModel and getChainedModel (Component.getInnerMostModel())

Posted by Eelco Hillenius <ee...@gmail.com>.
> we also have IChainingModel shouldn't we also test for that?
> because çurrently the behavior is that we only test for WramModels to get to
> the innermost model
> but what is then the big difference with IChainingModel?

Hey, didn't you code that stuff? :)

Eelco