Mateusz Moroz
Mateusz Moroz

Reputation: 411

Wicket.Ajax: Cannot bind a listener for event "click" on element "radioGroup1d" because the element is not in the DOM

I have a page in apache-wicket-7 with RadioGroup. I want to call a method in the backend Page class with ajax. To do this, I add the:

AjaxFormChoiceComponentUpdatingBehavior

The code:

this.listInput = new RadioGroup<T>("radioGroup", this.model);
       this.listInput.add(new AjaxFormChoiceComponentUpdatingBehavior() {

            private static final long serialVersionUID = 1L;

            @Override
            protected void onUpdate(AjaxRequestTarget arg0) {
                System.out.println("The selected value is " + getComponent().getDefaultModelObjectAsString());
            }
        });

The component RadioGroup becomes visible after an earlier ajax call, so it is also rendered asynchronously. But when wicket tries to render the component, the error message appears:

Wicket.Ajax:  Cannot bind a listener for event "click" on element "radioGroup1d" because the element is not in the DOM

Adding:

setOutputMarkupPlaceholderTag(true)

does nothing. How this can be fixed?

Regards, Mateusz

Upvotes: 0

Views: 1012

Answers (1)

martin-g
martin-g

Reputation: 17513

Make sure you don't use <wicket:cotainer> for it in the HTML template. Those are not rendered.

Upvotes: 2

Related Questions