You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by wicket user <wi...@comley.org> on 2007/12/11 13:47:40 UTC

When to use getModelObject, getConvertedInput, getInput

Hi,

This is more a question of understanding models and input of a particular
component, lets say DropDownChoice (DDC) for example.

You give it a model initially on creation, this has nothing to do with, in
the case of a DDC the selected values as that is supplied by the Choices
paramater in the constuctor.

So we now have a DDC configured.

A user comes along and selects a value, if we have and
AjaxFormComponentUpdatingBehavior associated we see that the getModelObject
returns null as well as getConvertedInput but getInput actually has
something but it's in string form. Is this because we are intercepting the
event before the input is converted to the model?

Basically I'm never sure when to use which accessor and the trial and error
method that I have been using so far is starting to scare me. I guess the
lifecycle of model is what I really need to understand and googling hasn't
thrown up much. I have read the wiki article on models but it doesn't go
into details such as this...

Anyway, it will be a nice thing to not have nagging me over xmas!

thanks
simon

Re: When to use getModelObject, getConvertedInput, getInput

Posted by Johan Compagner <jc...@gmail.com>.
But the AjaxFormComponentUpdatingBehavior  should set the model object to
what is now in the browser
(if no validation error occurs)

So you should be able to base your decision on whats in side the model.

johan

On Dec 12, 2007 12:42 PM, wicket user <wi...@comley.org> wrote:

> Ok that's cool but on an AjaxFormComponentUpdatingBehavior the model is
> null/hasn't been set so you can't use it? What happens if you want to base
> a
> decision on the value that the user has just changed to?
>
>
>
> On 11/12/2007, Johan Compagner <jc...@gmail.com> wrote:
> >
> > you shouldn't call getConvertedInput() or getInput yourself except if
> you
> > where making a special formcomponent itself.
> > The model of an component lives as long as the component does.
> >
> > But the dropdownchoice (or all select tag components) have another
> special
> > thing call IChoiceRenderer
> > That first tries to convert the string to an option object.
> >
> > johan
> >
> >
> > On Dec 11, 2007 1:47 PM, wicket user <wi...@comley.org> wrote:
> >
> > > Hi,
> > >
> > > This is more a question of understanding models and input of a
> > particular
> > > component, lets say DropDownChoice (DDC) for example.
> > >
> > > You give it a model initially on creation, this has nothing to do
> with,
> > in
> > > the case of a DDC the selected values as that is supplied by the
> Choices
> > > paramater in the constuctor.
> > >
> > > So we now have a DDC configured.
> > >
> > > A user comes along and selects a value, if we have and
> > > AjaxFormComponentUpdatingBehavior associated we see that the
> > > getModelObject
> > > returns null as well as getConvertedInput but getInput actually has
> > > something but it's in string form. Is this because we are intercepting
> > the
> > > event before the input is converted to the model?
> > >
> > > Basically I'm never sure when to use which accessor and the trial and
> > > error
> > > method that I have been using so far is starting to scare me. I guess
> > the
> > > lifecycle of model is what I really need to understand and googling
> > hasn't
> > > thrown up much. I have read the wiki article on models but it doesn't
> go
> > > into details such as this...
> > >
> > > Anyway, it will be a nice thing to not have nagging me over xmas!
> > >
> > > thanks
> > > simon
> > >
> >
>

Re: When to use getModelObject, getConvertedInput, getInput

Posted by wicket user <wi...@comley.org>.
Ok that's cool but on an AjaxFormComponentUpdatingBehavior the model is
null/hasn't been set so you can't use it? What happens if you want to base a
decision on the value that the user has just changed to?



On 11/12/2007, Johan Compagner <jc...@gmail.com> wrote:
>
> you shouldn't call getConvertedInput() or getInput yourself except if you
> where making a special formcomponent itself.
> The model of an component lives as long as the component does.
>
> But the dropdownchoice (or all select tag components) have another special
> thing call IChoiceRenderer
> That first tries to convert the string to an option object.
>
> johan
>
>
> On Dec 11, 2007 1:47 PM, wicket user <wi...@comley.org> wrote:
>
> > Hi,
> >
> > This is more a question of understanding models and input of a
> particular
> > component, lets say DropDownChoice (DDC) for example.
> >
> > You give it a model initially on creation, this has nothing to do with,
> in
> > the case of a DDC the selected values as that is supplied by the Choices
> > paramater in the constuctor.
> >
> > So we now have a DDC configured.
> >
> > A user comes along and selects a value, if we have and
> > AjaxFormComponentUpdatingBehavior associated we see that the
> > getModelObject
> > returns null as well as getConvertedInput but getInput actually has
> > something but it's in string form. Is this because we are intercepting
> the
> > event before the input is converted to the model?
> >
> > Basically I'm never sure when to use which accessor and the trial and
> > error
> > method that I have been using so far is starting to scare me. I guess
> the
> > lifecycle of model is what I really need to understand and googling
> hasn't
> > thrown up much. I have read the wiki article on models but it doesn't go
> > into details such as this...
> >
> > Anyway, it will be a nice thing to not have nagging me over xmas!
> >
> > thanks
> > simon
> >
>

Re: When to use getModelObject, getConvertedInput, getInput

Posted by Johan Compagner <jc...@gmail.com>.
you shouldn't call getConvertedInput() or getInput yourself except if you
where making a special formcomponent itself.
The model of an component lives as long as the component does.

But the dropdownchoice (or all select tag components) have another special
thing call IChoiceRenderer
That first tries to convert the string to an option object.

johan


On Dec 11, 2007 1:47 PM, wicket user <wi...@comley.org> wrote:

> Hi,
>
> This is more a question of understanding models and input of a particular
> component, lets say DropDownChoice (DDC) for example.
>
> You give it a model initially on creation, this has nothing to do with, in
> the case of a DDC the selected values as that is supplied by the Choices
> paramater in the constuctor.
>
> So we now have a DDC configured.
>
> A user comes along and selects a value, if we have and
> AjaxFormComponentUpdatingBehavior associated we see that the
> getModelObject
> returns null as well as getConvertedInput but getInput actually has
> something but it's in string form. Is this because we are intercepting the
> event before the input is converted to the model?
>
> Basically I'm never sure when to use which accessor and the trial and
> error
> method that I have been using so far is starting to scare me. I guess the
> lifecycle of model is what I really need to understand and googling hasn't
> thrown up much. I have read the wiki article on models but it doesn't go
> into details such as this...
>
> Anyway, it will be a nice thing to not have nagging me over xmas!
>
> thanks
> simon
>