You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "wmike1987@gmail.com" <wm...@gmail.com> on 2011/07/21 23:41:39 UTC

updating a property model

>From the wicket java docs for property model, it says:

...we can create form components that work dynamically on the given model
object. For instance, we could create a text field that updates the name
property of a person like this: 

     add(new TextField("myTextField", new PropertyModel(person, "name"));

My question is:
How does the text field update the name field in the person object? Is it
built in on "onsubmit" or some function inside the TextField class?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/updating-a-property-model-tp3685186p3685186.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: updating a property model

Posted by Igor Vaynberg <ig...@gmail.com>.
use AjaxFormComponentUpdatingBehavior instead

-igor


On Thu, Jul 21, 2011 at 3:17 PM, wmike1987@gmail.com
<wm...@gmail.com> wrote:
> Thanks Igor,
>
> I've been trying to update the TextField's model myself through an added
> AjaxEventBehavior("onchange") event. But I can't seem to access the text
> that the user inputs in the TextField. I have:
>
> textField.add(new AjaxEventBehavior("onchange")
>        {
>                        @Override
>                        protected void onEvent(AjaxRequestTarget target)
>                        {
>                                system.out.println(textField.getInput());
>                        }
>        });
>
> This doesnt print out the text that's currently in the text box. How does
> the updateModel method in FromComponent know what the inputted text is?
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/updating-a-property-model-tp3685186p3685298.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: updating a property model

Posted by "wmike1987@gmail.com" <wm...@gmail.com>.
Thanks Igor,

I've been trying to update the TextField's model myself through an added
AjaxEventBehavior("onchange") event. But I can't seem to access the text
that the user inputs in the TextField. I have:

textField.add(new AjaxEventBehavior("onchange")
        {
			@Override
			protected void onEvent(AjaxRequestTarget target)
			{
				system.out.println(textField.getInput());
			}
        });

This doesnt print out the text that's currently in the text box. How does
the updateModel method in FromComponent know what the inputted text is?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/updating-a-property-model-tp3685186p3685298.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: updating a property model

Posted by Igor Vaynberg <ig...@gmail.com>.
updatemodel of textfield calls model.setobject(value) where model is a
property model

propertymodel then calls person.setname(value)

-igor

On Thu, Jul 21, 2011 at 2:41 PM, wmike1987@gmail.com
<wm...@gmail.com> wrote:
> From the wicket java docs for property model, it says:
>
> ...we can create form components that work dynamically on the given model
> object. For instance, we could create a text field that updates the name
> property of a person like this:
>
>     add(new TextField("myTextField", new PropertyModel(person, "name"));
>
> My question is:
> How does the text field update the name field in the person object? Is it
> built in on "onsubmit" or some function inside the TextField class?
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/updating-a-property-model-tp3685186p3685186.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org