is your checkbox required? any validation errors? see if onerror() is
called instead of onupdate()

-igor

On Sun, May 31, 2009 at 11:04 AM, Rick Gruber-Riemer <[email protected]> wrote:
> Hi
>
> Thank you for your answer.
>
> Unfortunately this did not solve the problem. In the meantime I found out,
> that the onUpdate method is only called when the checkbox is checked, but
> not when the checkbox is removed (i.e. check, uncheck, check, uncheck
> results in two invocations of onUpdate). This does not sound correct to me,
> but I am not sure.
>
> 2009/5/31 Steve Swinsburg <[email protected]>
>
>> Call doUpdateConfirmButton() when the page first loads so you can set it up
>> initially, then again when the checkbox is clicked as you already do.
>>
>>
>> cheers,
>> Steve
>>
>>
>>
>> On 31/05/2009, at 7:40 AM, Rick Gruber-Riemer wrote:
>>
>>  Hi
>>>
>>> I 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, when
>>> the checkbox is checked. This works fine when the button initially is
>>> disabled, then the checkbox is checked by the user (I followed
>>>
>>> http://www.nabble.com/Disabling-and-enabling-components-using-AjaxCheckBox-td20911338.html#a20911338
>>> ).
>>> However, when the user then unchecks the checkbox again, the button does
>>> not
>>> get 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 as
>>> IModel 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 needed
>>>       form.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);
>>>   }
>>>
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to