I want to swap panels using the event model in 1.5. This is very similar to
the panel swapping code (wicket 1.4.x) found in the Apache Wicket Cookbook but
uses the event model instead. The problem is I can't set the panel equal to
its replacement, like you would in 1.4.x. This is found on the line marked
***** THIS IS NOT POSSIBLE *****.
How would you go about doing this? Is it even possible?
Component workingPanel = new MyEmptyPanel("workingPanel") {
@Override
public void onEvent(IEvent<?> event) {
if (event.getPayload()
instanceof MyPanelEvent) {
MyPanelEvent e
= (MyPanelEvent) event.getPayload();
Component replacement;
switch
(e.getType()) {
case
MyPanelEvent.PANEL1:
replacement = new MyFirstPanel(this.getId());
break;
default:
replacement =
this;
break;
}
this.replaceWith(replacement);
this. = replacement;
// ****** THIS IS NOT POSSIBLE - HOW WOULD I DO THIS *******
this.setOutputMarkupId(true);
AjaxRequestTarget target =
e.getTarget();
target.add(this);
}
super.onEvent(event);
}
workingPanel.setOutputMarkupId(true);
add(workingPanel);
AjaxLink firsttab = new AjaxLink("firsttab") {
@Override
public void onClick(AjaxRequestTarget target) {
send(getPage(), Broadcast.BREADTH, new
MyPanelEvent (target, MyPanelEvent.PANEL1));
}
};
firsttab.setOutputMarkupId(true);
firsttab.setMarkupId("firsttab ");
add(firsttab);