user2645194
user2645194

Reputation: 1

Wicket RadioChoice returns null all the time

how is said in the title I can not to resolve this problem for several hours. I hope I will get some useful replies, thank you.

wicket version: 1.5.7

public class EvalSearcherPage extends MenuPage {
   ...
   private Code selectedEvalChoice;
   ... 

   ...
   RadioChoice<Code> evalRadioChoice = new RadioChoice<Code>("evalRadioChoice", new PropertyModel<Code>(this, "selectedEvalChoice"), EVAL_CHOICES, new ChoiceRenderer<Code>(getLocaleColumn()));
    evalRadioChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {

        private static final long serialVersionUID = 1L;


        @Override
        protected void onUpdate(AjaxRequestTarget target) {
                ...
            target.add(...);
        }
    });
    evalChoiceForm.add(evalRadioChoice);
            ...

in constructor: EVAL_CHOICES is filled by choices, selectedEvalChoice is filled by default choice

Everything works good till the moment when I want to select another choice. After that RadioChoice saves null to selectedEvalChoice.

So where is the problem, could anybody help, please?

Btw getter and setter are implemented for selectedEvalChoice but I learned that is not necessary.

Upvotes: 0

Views: 503

Answers (1)

svenmeier
svenmeier

Reputation: 5681

For RadioChoice you have to use AjaxForm*Choice*ComponentUpdatingBehavior.

Check your log output, you should find a warning there.

Upvotes: 2

Related Questions