Hi,

When the user clicks on a certain icon, a specific part of the page should be 
reloaded through ajax. The icon is part of a panel, the specific part is a 
webmarkupcontainer added directly to the page. I am using Wicket Events to push 
the click event. However, when adding the web markup container as target, I am 
getting an internal error.

-> update.getTarget().add(container);

Can someone help me to fix this?

*********************
***** PANEL *****
final WebMarkupContainer suitcaseIcon = new WebMarkupContainer("icon");
icon.setOutputMarkupId(true);
icon.add(new AjaxEventBehavior("onclick") {
        protected void onEvent(AjaxRequestTarget target) {
                send(getPage(), Broadcast.BREADTH, new AddItem(target));
        }
});

*********************
***** PAGE *****
...
WebMarkupContainer container;
public HomePage() {
        container = new WebMarkupContainer("container");
        add(container);
}

@Override
public void onEvent(IEvent<?> event) {
        super.onEvent(event);
        if (event.getPayload() instanceof AddItem) {
        AddItem update = (AddItem) event.getPayload();
        update.getTarget().add(container);
    }
}

*********************
***** AddItem *****
public class AddItem {
    private final AjaxRequestTarget target;

    public AddItem(AjaxRequestTarget target) {
        this.target = target;
    }

    public AjaxRequestTarget getTarget() {
        return target;
    }
}

Thanks.
Chris

Reply via email to