If you want to change the state of the input fields via javascript then do
what Richard said. I guess since you are using an AjaxCheckBox you want to
do it on the server side via ajax. So, here's what you need to do:

add a boolean property to the Panel (e.g. "componentsEnabled") and bind
AjaxCheckBox to it: form.add(new AjaxCheckBox("anyStupidId", new
PropertyModel<Boolean>(this, "componentsEnabled")).

Now whenever the checkbox is updated, the change is reflected to the
componentsEnabled property. You can use this property in the onConfigure
method of the panel or the individual components to alter their state:
e.g. form.add(new TextField("name") {
 public void onConfigure() {
   setEnabled(componentsEnabled);
 }
});

To get the update working after the checkbox is clicked you need to handle
its onUpdate method and add the components whose change should change to
the ajax request target.

Hope this helps,
Marios


On Tue, Jul 9, 2013 at 8:58 PM, Dmitriy Neretin <
dmitriy.nere...@googlemail.com> wrote:

> Hi everyone,
>
> I have a dummy question:
>
> If I have a panel with a form (not everything is my code) ->
>
> public class MyPanel{
>
>   public MyPanel(id, IModel<MyObj> model){
>         super(id, new CompoundPropertyModel<MyObj>(model);
>         ....
>         Form<MyObj> form = new Form("id", model);
>         form.add(new AjaxCheckBox("anyStupidId");
>         add(form);
>
>      }
>
> }
>
> And I want to add a Component (AjaxCheckBox) to the form above, but this
> component shouldn't have anything to do with a model object. It's purpose
> is just a change the state of the input fields. If I check the box the
> field should be deactivated and vice versa. Nothing more.
>
> My problem is, that Wicket thinks (and I even know  why :)) the
> "anyStupidId" is a field of MyObj and tries to change the value... Well,
> the checkbox should be inside of the form, but I don't know if is it
> possible to make this checkbox independent from the Model handling... How
> can I tell wicket, "hey dude, anyStupidId has nothing to do with MyObj, it
> is really just a stupid id"
>
> Regards,
> Dmitriy
>

Reply via email to