您可以将面板添加到 div:
标记:
<div wicket:id="panel" />
Java代码:
final YourPanel panel = new YourPanel("panel");
add(panel);
要更改附加到页面的面板,我将用标记容器围绕面板,在(ajax)事件上更改面板(删除旧的并附加新创建的)并更新标记容器。
标记:
<div wicket:id="markupContainer">
<div wicket:id="panel" />
</div>
Java代码
// initially create the panel
final WebMarkupContainer wmc = new WebMarkupContainer("markupContainer");
wmc.setOutputMarkupId(true);
add(wmc);
Panel panel = new YourPanel("panel");
wmc.add(panel);
// ...
// updating the panel on an ajax event (here: button click)
final AjaxButton yourButton = new AjaxButton(...) {
@Override
public void onSubmit(AjaxRequestTarget target) {
wmc.remove(panel);
panel = new AnotherPanel("panel");
wmc.add(panel);
target.add(wmc);
}
}
// ...