cheers, Steve On 31/05/2009, at 7:40 AM, Rick Gruber-Riemer wrote:
HiI have a checkbox which must be checked for the user to be able to submit (accept terms). I want the related submit button to be enabled only, whenthe checkbox is checked. This works fine when the button initially is disabled, then the checkbox is checked by the user (I followedhttp://www.nabble.com/Disabling-and-enabling-components-using-AjaxCheckBox-td20911338.html#a20911338) . However, when the user then unchecks the checkbox again, the button does notget disabled again :-( Any suggestions? <div wicket:id="feedback"></div> <form wicket:id="form"><span wicket:id="border"><input type="checkbox" wicket:id="acceptCB"id="acceptCB" /></span> <label for="acceptCB"><wicket:message key="acceptCB">[Accept delete]</wicket:message></label> <br/> <input type="submit" value="[Confirm]" id="confirmBtn" wicket:id="confirmBtn" wicket:message="value:confirmBtn"/> </form> ==========/** Whether or not the conditions for deletion are accepted. Acts asIModel for the checkbox */ private boolean accepted = false; /** The confirm button */ Button confirmBTN = null; /** The accept check box */ CheckBox acceptCB = null; public AccountDeletePage() { add(new FeedbackPanel("feedback")); Form form = new Form("form"); add(form); confirmBTN = new Button("confirmBtn") { @Override public void onSubmit() { doDelete(); } }; confirmBTN.setEnabled(false);confirmBTN.setOutputMarkupId(true); //not sure why this is neededform.add(confirmBTN); //CheckBox acceptCB = new CheckBox("acceptCB", new PropertyModel(this, "accepted")); acceptCB = new AjaxCheckBox("acceptCB",new PropertyModel(this, "accepted")) { @Override protected void onUpdate(AjaxRequestTarget arg0) { doUpdateConfirmButton(); if(arg0 != null) { arg0.addComponent(confirmBTN); } } }; acceptCB.setRequired(true);form.add(new FormComponentFeedbackBorder("border").add(acceptCB));} /** * Updates the enabled state of the delete button depending on acceptance */ private final void doUpdateConfirmButton() { boolean enabled = acceptCB.isEnabled(); confirmBTN.setEnabled(enabled); }
smime.p7s
Description: S/MIME cryptographic signature
