I have 2 radio buttons and 1 TextField and now I want to do changing between enabled and disabled TextField. If radioFindText is selected then TextField must be enabled otherwise it must be disabled. I was trying with such code but it doesn't work and I am running out of possible solutions. It seems that method onSelectionChanged is never called, why?
EDIT Ok I finally found a solution and maybe it is obvious for ppl who work in wicket for a while but for my first project I found it difficult to solve it. Here is the working code.
searchedText.setOutputMarkupId(true);
RadioGroup group = new RadioGroup("group", selected);
group.setOutputMarkupId(true);
Radio radioErrors = new Radio("errors", new Model<String>("ERRORS"));
Radio radioFindText = new Radio("text", new Model<String>("Find text"));
group.add(radioFindText.add(new AjaxEventBehavior("onchange") {
@Override
protected void onEvent(AjaxRequestTarget art) {
searchedText.setEnabled(true);
art.add(searchedText);
}
}));
group.add(radioErrors.add(new AjaxEventBehavior(("onchange")) {
@Override
protected void onEvent(AjaxRequestTarget art) {
searchedText.setEnabled(false);
art.add(searchedText);
}
}));
group.add(searchedText);
form.add(group);
its been a long time, since i coded wicket, but maybe you could use this:
radioGroup.add(new AjaxFormSubmitBehavior("onchange") {public void onSubmit(AjaxRequestTarget target) {...}}
i guess you need this to get "onchange" - notifications