getModelObject has (in 1.3 not in 2.0) really a better function then
getModel().getObject(XXXX)
because getModelObject knows what to put in the XXXX
for example this is very different:
Form form = new Form("form", new CompoundModel(xxx));
Textfield tf = new Textfield("tf");
form.add(tf);
now if i want the tf model object i have to do: tf.getModel().getObject(tf)
and not null!
But if i want to get the model object of the Form i have to insert null and
NOT the form!
So in 1.3 the only reliable way to really get the right value out of a model
is to use getModelObject of component..
But if we backport the model changes then that is done inside the model and
that is much much cleaner (i am +1 for backporting that to 1.3)
johan
On 3/7/07, Eelco Hillenius <
eelco.hillenius@...> wrote:
>
> > no i am not pro for degenerifying it.
> > I like the getModelObject()
>
> What is so great about that method, and why don't you just directly
> work with the objects the models work on? And why not
> getModel().getObject?
>
> > But i am curious about where people talk to
> > is it just the model or are people go through componet.getModelObject()
> ?
>
> I hope the first. getModelObject is a convenience method, and in some
> case, like ListView's ListItem, it's the obvious thing to use.
> However, think of all the textfields, dropdownlists and other form
> components... no good using that method, imo. And what I never liked
> about that method in the first place is that it pushes people in the
> wrong direction. They should be thinking in models and the objects
> they work on rather than 'values' of components. In the same fashion
> I'm against setModelObject as well. If it were just up to me, I'd
> remove it/ them (also because getModel().setObject can result in
> something different then setModelObject).
>
> > But then how would you generify only the models?
> >
> > for example if we completely remove it from the components
> >
> > then we have this?
> >
> > TextField tf = new Textfield(new Model<String>("test"));
> >
> > but how get we that model generified back in?
> >
> > tf.getModel() should return Model<String> then because if we also loose
> that
> > then we can completely scrap it and i am really -1 about that.
>
> Yeah, hmmm. I didn't actually think about that yet. Looking at it,
> what I propose seems impossible? :(
>
> Eelco
>