您可能正在尋找片段。 以下示例顯示如何添加AjaxLazyLoadPanel的實例並放置來自相同標記的內容,到目前爲止,您不必爲了分離內容而創建任何其他類或標記文件。完整的工作示例,請https://stash.twinstone.org/projects/WISTF/repos/wicket-examples-6.x/browse
AjaxLazyLoadPanelPage(JAVA)
public class AjaxLazyLoadPanelPage extends WebPage {
private static final long serialVersionUID = 1L;
/**
* @param parameters
*/
public AjaxLazyLoadPanelPage(PageParameters parameters) {
super(parameters);
add(new AjaxLazyLoadPanel("lazyLoadedPanel") {
private static final long serialVersionUID = 1L;
@Override
public Component getLazyLoadComponent(String componentId) {
return new Fragment(componentId, "lazyContentFragment", AjaxLazyLoadPanelPage.this)
.add(new Label("text", Model.of("real content")));
}
});
}
}
AjaxLazyLoadPanelPage.html(標記)
<body xmlns:wicket="http://wicket.apache.org">
<div>
<h1>Ajax Laxy Load Panel Example</h1>
<div wicket:id="lazyLoadedPanel">This is a lazy loaded panel</div>
</div>
<wicket:fragment wicket:id="lazyContentFragment">
If you see this content, the lazy laoded panel has been replaced with its <span wicket:id="text">[data]</span> after lazy loading.
</wicket:fragment>
</body>
這正是我需要!我讚賞這個工作的例子。 – JeredM