You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Brown, Berlin [GCG-PFS]" <Be...@Primerica.com> on 2010/10/04 15:06:41 UTC

Understanding the model, initial/default value

Panel.java:
...
 final IModel<Boolean> modelForAgree = new
Model<Boolean>("yes".equalsIgnoreCase(obj.getAgree())));
 
form.add(modelForAgree);
...
 
In this code, how can I ensure that modelForAgree has the right default
value when the panel loads.  Is it possible that the Panel gets
deserialized with an older version of modelForAgree?
 
Berlin Brown
 

RE: Understanding the model, initial/default value

Posted by "Brown, Berlin [GCG-PFS]" <Be...@Primerica.com>.
And my pseudo code was wrong, I meant to add the model to a component.

final IModel<Boolean> modelForAgree = new 
   Model<Boolean>("yes".equalsIgnoreCase(obj.getAgree())));

final AjaxCheckBox yesChoiceBox = new AjaxCheckBox( "Agree", modelForAgree) {  
} 
form.add(yesChoiceBox)

I have another question, in the case of the checkbox, it expects a model with a boolean value.
I would need to add a property field that holds a boolean?  Is this correct.

Let's say the property has a string?

-----Original Message-----
From: jcarman@carmanconsulting.com [mailto:jcarman@carmanconsulting.com] On Behalf Of James Carman
Sent: Monday, October 04, 2010 9:13 AM
To: users@wicket.apache.org
Subject: Re: Understanding the model, initial/default value

You're not binding your model to the "agree" property, really.  So, if the value changes, it won't update your model.  If you want to bind it, use a PropertyModel.

On Mon, Oct 4, 2010 at 9:06 AM, Brown, Berlin [GCG-PFS] <Be...@primerica.com> wrote:
> Panel.java:
> ...
>  final IModel<Boolean> modelForAgree = new 
> Model<Boolean>("yes".equalsIgnoreCase(obj.getAgree())));
>
> form.add(modelForAgree);
> ...
>
> In this code, how can I ensure that modelForAgree has the right 
> default value when the panel loads.  Is it possible that the Panel 
> gets deserialized with an older version of modelForAgree?
>
> Berlin Brown
>
>

---------------------------------------------------------------------
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: Understanding the model, initial/default value

Posted by James Carman <ja...@carmanconsulting.com>.
You're not binding your model to the "agree" property, really.  So, if
the value changes, it won't update your model.  If you want to bind
it, use a PropertyModel.

On Mon, Oct 4, 2010 at 9:06 AM, Brown, Berlin [GCG-PFS]
<Be...@primerica.com> wrote:
> Panel.java:
> ...
>  final IModel<Boolean> modelForAgree = new
> Model<Boolean>("yes".equalsIgnoreCase(obj.getAgree())));
>
> form.add(modelForAgree);
> ...
>
> In this code, how can I ensure that modelForAgree has the right default
> value when the panel loads.  Is it possible that the Panel gets
> deserialized with an older version of modelForAgree?
>
> Berlin Brown
>
>

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