Ah ha, that makes sense...I understand now.  I reorganized the code so I
could pre-load the input class first and it works.

Thanks much!


igor.vaynberg wrote:
> 
> you are not tying your checkbox's model to the form's model object so it
> saves into its own model..
> 
> as you can see here:
> IModel checkedModel = new Model(customer.isOptedForNewsletter());
> form.add(new CheckBox("optedForNewsletter", checkedModel));
> you are giving it its own model...
> 
> so in your onsubmit you have to call checkbox.getmodelobject() to retrieve
> the value, or give it a model that is properly tied to the form's model
> object via a propertymodel or something else
> 
> -igor
> 
> 
> On 10/3/07, V. Jenks <[EMAIL PROTECTED]> wrote:
>>
>>
>> NOTE: I'm stuck at Wicket 1.2.4 and cannot upgrade yet.
>>
>> I've got a very simple form with an input class that looks like this:
>>
>> ****************************
>> public class PaymentInfoInput implements Serializable
>> {
>>         private Boolean optedForNewsletter;
>>
>> .....................................
>>
>>         public Boolean isOptedForNewsletter()
>>         {
>>                 return this.optedForNewsletter;
>>         }
>>
>>         public void setOptedForNewsletter(Boolean optedForNewsletter)
>>         {
>>                 this.optedForNewsletter = optedForNewsletter;
>>         }
>> }
>> ****************************
>>
>> When the page loads I load a boolean value into my CheckBox from an
>> entity,
>> like so:
>>
>> ****************************
>>                 //model for checkbox value
>>                 IModel checkedModel = new Model(
>> customer.isOptedForNewsletter());
>>
>>                 //newsletter opt-in checkbox
>>                 form.add(new CheckBox("optedForNewsletter",
>> checkedModel));
>> ****************************
>>
>> ...I've walked through this portion in the debugger, it loads the correct
>> value.
>>
>> Now, when I submit the form, regardless of whether or not the CheckBox is
>> checked, the value is null:
>>
>> ****************************
>>                 //create form
>>                 final Form form = new Form("paymentInfoForm", new
>> CompoundPropertyModel(new PaymentInfoInput()));
>>
>> ...........................................
>>
>>                 //submit button
>>                 form.add(new Button("completeOrderButton")
>>                 {
>>                         public void onSubmit()
>>                         {
>>                                 try
>>                                 {
>>                                         //get form input
>>                                         PaymentInfoInput input =
>> (PaymentInfoInput)form.getModelObject();
>>                                         Boolean opted =
>> input.isOptedForNewsletter(); //WHY IS THIS NULL?
>>                                 }
>>                                 catch (Exception exp)
>>                                 {
>>                                         LogProxy.saveEntry(exp);
>>                                 }
>>                         }
>>                 });
>>
>> ...in the HTML:
>>
>> <input type="checkbox" wicket:id="optedForNewsletter" value="true" />
>> ****************************
>>
>> ...what's up with that?  I must be missing something painfully simple.
>>
>> Thanks!
>> --
>> View this message in context:
>> http://www.nabble.com/CheckBox-is-misbehaving...-tf4563018.html#a13022997
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/CheckBox-is-misbehaving...-tf4563018.html#a13025669
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to