You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by walnutmon <ju...@gmail.com> on 2008/10/06 15:26:53 UTC

Newbie Question, Very Basic Model Use

After using property models, it's nice to have automatic binding to variables
in objects... However, I can't seem to get the same thing to work with local
variables... as an example...

new CheckBox("toggleSomething", new PropertyModel(someObject,
"toggleableProperty"));
works beautifully...

However, 
new CheckBox("toggleSomething", new Model(toggleableObject));
//toggleableObject is a Boolean

doesn't seem to change anything on form submit, that toggleable object only
dictates the initial state of the checkbox, but doesn't change with it....
What am I missing?

-- 
View this message in context: http://www.nabble.com/Newbie-Question%2C-Very-Basic-Model-Use-tp19837933p19837933.html
Sent from the Wicket - User 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: Newbie Question, Very Basic Model Use

Posted by Martijn Dashorst <ma...@gmail.com>.
see the models page on the wiki and read the javadoc for CompoundPropertyModel

Martijn

On Mon, Oct 6, 2008 at 3:26 PM, walnutmon <ju...@gmail.com> wrote:
>
> After using property models, it's nice to have automatic binding to variables
> in objects... However, I can't seem to get the same thing to work with local
> variables... as an example...
>
> new CheckBox("toggleSomething", new PropertyModel(someObject,
> "toggleableProperty"));
> works beautifully...
>
> However,
> new CheckBox("toggleSomething", new Model(toggleableObject));
> //toggleableObject is a Boolean
>
> doesn't seem to change anything on form submit, that toggleable object only
> dictates the initial state of the checkbox, but doesn't change with it....
> What am I missing?
>
> --
> View this message in context: http://www.nabble.com/Newbie-Question%2C-Very-Basic-Model-Use-tp19837933p19837933.html
> Sent from the Wicket - User 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
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.4 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

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


Re: Newbie Question, Very Basic Model Use

Posted by Serkan Camurcuoglu <se...@telenity.com>.
Model assigns a new object as the model object, and I think 
java.lang.Boolean is immutable so it can't change after it's constructed 
anyway. So instead of checking the value of toggleableObject I think you 
can check myCheckbox.getModelObject() == Boolean.TRUE etc..



Ryan Gravener wrote:
> If you would like the property model to work with local variables do
> new propertymodel(this,"property")
>
> On 10/6/08, walnutmon <ju...@gmail.com> wrote:
>   
>> After using property models, it's nice to have automatic binding to
>> variables
>> in objects... However, I can't seem to get the same thing to work with local
>> variables... as an example...
>>
>> new CheckBox("toggleSomething", new PropertyModel(someObject,
>> "toggleableProperty"));
>> works beautifully...
>>
>> However,
>> new CheckBox("toggleSomething", new Model(toggleableObject));
>> //toggleableObject is a Boolean
>>
>> doesn't seem to change anything on form submit, that toggleable object only
>> dictates the initial state of the checkbox, but doesn't change with it....
>> What am I missing?
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Newbie-Question%2C-Very-Basic-Model-Use-tp19837933p19837933.html
>> Sent from the Wicket - User 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: Newbie Question, Very Basic Model Use

Posted by Ryan Gravener <ry...@ryangravener.com>.
If you would like the property model to work with local variables do
new propertymodel(this,"property")

On 10/6/08, walnutmon <ju...@gmail.com> wrote:
>
> After using property models, it's nice to have automatic binding to
> variables
> in objects... However, I can't seem to get the same thing to work with local
> variables... as an example...
>
> new CheckBox("toggleSomething", new PropertyModel(someObject,
> "toggleableProperty"));
> works beautifully...
>
> However,
> new CheckBox("toggleSomething", new Model(toggleableObject));
> //toggleableObject is a Boolean
>
> doesn't seem to change anything on form submit, that toggleable object only
> dictates the initial state of the checkbox, but doesn't change with it....
> What am I missing?
>
> --
> View this message in context:
> http://www.nabble.com/Newbie-Question%2C-Very-Basic-Model-Use-tp19837933p19837933.html
> Sent from the Wicket - User 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
>
>


-- 
Ryan Gravener
http://twitter.com/ryangravener

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