我使用Wicket 6.7.0并在运行时收到以下异常:
最后一个原因:Wicket命名空间的未知标记名称:'panel'。你可能没有安装合适的解析器? ''(第3行,第2栏)
我正在扩展BookmarkablePageLink,我的组件有自己的标记html。 它类似于wicket-bootstrap的代码: https://github.com/l0rdn1kk0n/wicket-bootstrap/blob/master/bootstrap-core/src/main/java/de/agilecoders/wicket/core/markup/html/bootstrap/button/BootstrapBookmarkablePageLink.java
ExtBookMarkablePageLink.java
public class ExtBookMarkablePageLink<T> extends BookmarkablePageLink<T> {
private final Component label;
public <C extends Page> ExtBookMarkablePageLink(String id, Class<C> pageClass) {
this(id, pageClass, new PageParameters());
}
public <C extends Page> ExtBookMarkablePageLink(String id, Class<C> pageClass, final PageParameters parameters) {
super(id, pageClass, parameters);
add(label = newLabel("label"));
}
protected Component newLabel(final String markupId) {
return new Label(markupId, new Model<String>("")).setRenderBodyOnly(true);
}
@Override
protected IMarkupSourcingStrategy newMarkupSourcingStrategy() {
return new PanelMarkupSourcingStrategy(true);
}
public ExtBookMarkablePageLink<T> setLabel(IModel<?> label) {
this.label.setDefaultModel(label);
return this;
}
}
ExtBookMarkablePageLink.html
<!doctype html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<span wicket:id="label"></span>
</wicket:panel>
</html>
<!doctype html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<span wicket:id="label"></span>
</wicket:panel>
</html>
答案 0 :(得分:0)
您应该在组件的静态块中注册面板标签:
public class ExtBookMarkablePageLink<T> extends BookmarkablePageLink<T> {
static {
WicketTagIdentifier.registerWellKnownTagName(PANEL);
}
// ...
}