Hi,

Did you try using AjaxCheckBox instead of CheckBox with ajax behavior?

Best regards,
Michal Wegrzyn

> -----Original Message-----
> From: Gytis [mailto:lietuvis...@mail.ru]
> Sent: Friday, March 16, 2012 10:32
> To: users@wicket.apache.org
> Subject: AjaxFormComponentUpdatingBehavior after validation problem
> 
> Hello, I have such a problem with AjaxFormComponentUpdatingBehavior.
> I have some DropDownChoice and a CheckBox on a Form. I need to make a
> change to DropDown, when I click on CheckBox. But as I try to submit a
> Form, got some error, and then click CheckBox DropDown doesn`t change.
> The code looks like this:
> 
>    DropDownChoice<SomeEnum> dropDownz = new
> DropDownChoice<SomeEnum>("dropDownId",
>                       Arrays.asList(SomeEnum.values()), new
> EnumChoiceRenderer<SomeEnum>(this));
>    getGenericModelObject().setValues(SomeEnum.FIRSTVALUE);
>    CheckBox boxz = new CheckBox("BoxId");
>    boxz.add(new AjaxFormComponentUpdatingBehavior("onchange")
>               {
>                       @Override
>                       protected void onUpdate(AjaxRequestTarget target) {
>                               if (boxz.getModelObject())
>                               {
> 
>       getGenericModelObject().setValues(SomeEnum.SECONDVALUE);
>                                       get("dropDownId").setEnabled(false);
>                                       target.addComponent(get("dropDownId"));
>                               }
>                               else
>                               {
>                                       get("dropDownId").setEnabled(true);
>                                       target.addComponent(get("dropDownId"));
>                               }
>                       }
>                       @Override
>                       protected void onError(AjaxRequestTarget target,
> RuntimeException e) {
>                               if (boxz.getModelObject())
>                               {
> 
>       getGenericModelObject().setValues(SomeEnum.SECONDVALUE);
>                                       get("dropDownId").setEnabled(false);
>                                       target.addComponent(get("dropDownId"));
>                               }
>                               else
>                               {
>                                       get("dropDownId").setEnabled(true);
>                                       target.addComponent(get("dropDownId"));
>                               }
>                               super.onError(target, e);
>                       }
>               });
>      Form form = new Form("formId", getGenericModel());
>      form.add(dropDownz);
>      form.add(boxz);
> 
> So as I said, after form validation, if errors occur, it won`t change
> dropdown to SECONDVALUE, but sets it as setEnabled(false), why this
> happens?
> 
> --
> View this message in context: http://apache-
> wicket.1842946.n4.nabble.com/AjaxFormComponentUpdatingBehavior-after-
> validation-problem-tp4477705p4477705.html
> Sent from the Users forum mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org


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

Reply via email to