I can see no problem in your code. Maybe something else? On Fri, Oct 31, 2008 at 12:29 PM, ds26680 <[EMAIL PROTECTED]> wrote: > > I am new to creating web applications with Wicket and I am struggling with > getting a CheckBox to set a boolean variable in my domain object using a > PropertyModel. > > I have had a good search around on the web for examples and I think the code > bellow should work just fine. However when I click the submit button on my > form (after checking the checkbox), the domain model is not updated and the > print line in the onSubmit method always returns false. > > I have watched this code in the debugger and the setSelected method (in > domain class) never gets called. Does anyone have an idea why the code > bellow should not work? > > I have created the following Java code for the view:- > > public HomePage() { > > MyForm form = new MyForm("form"); > add(form); > } > > private class MyForm extends Form { > > private CheckBoxModel checkBoxModel = new CheckBoxModel(); > > public MyForm(String s) { > super(s); > > CheckBox myCheckBox = new CheckBox("selected", > new PropertyModel(checkBoxModel, "selected")); > add(myCheckBox); > } > > protected void onSubmit() { > boolean bool = checkBoxModel.getSelected(); > > // I expect this to print true when check box has been clicked > System.out.println(bool); > } > } > > My domain class is as follows:- > > public class CheckBoxModel { > > private boolean selected; > > public boolean getSelected() { > return selected; > } > > public void setSelected(boolean selected) { > this.selected = selected; > } > > public String toString() { > return String.valueOf(selected); > } > } > > Thanks in advance for your help. > -- > View this message in context: > http://www.nabble.com/Help-with-simple-CheckBox-example-tp20267081p20267081.html > Sent from the Wicket - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
-- Alan R. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]