是否可以在Fragment中添加面板(片段用于继承其他页面的页面),所以我也使用了标签?)
答案 0 :(得分:3)
是的,确实如此。这是一个简单的例子:
页:
package com.mycompany;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.html.WebPage;
public class HomePage extends WebPage {
public HomePage(final PageParameters parameters) {
super(parameters);
Fragment fragment = new Fragment("fragment", "fragment-markup", this);
fragment.add(new MyPanel("panel"));
add(fragment);
}
}
页面标记:
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<body>
<div wicket:id="fragment"/>
<wicket:fragment wicket:id="fragment-markup">
<div wicket:id="panel"/>
</wicket:fragment>
</body>
</html>
面板:
package com.mycompany;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.Model;
public class MyPanel extends Panel {
public MyPanel(String id) {
super(id);
add(new Label("hello", Model.of("Hello")));
add(new Label("world", Model.of("World")));
}
}
面板标记:
<!DOCTYPE html>
<html>
<body>
<wicket:panel>
<div wicket:id="hello"/>
<div wicket:id="world"/>
</wicket:panel>
</body>
</html>