我正在尝试在扩展组件中使用片段,但它会引发 MarkupNotFoundException。
代码与此类似:
BasePanel.html
<?xml version="1.0" encoding="UTF-8" ?>
<wicket:panel xmlns:wicket="http://wicket.apache.org">
<div wicket:id="dialog">
<div class="titlebar">
<h3 wicket:id="dialogTitle">[[ dialog title ]]</h3>
<div wicket:id="dialogCloseBtn" class="closeBtn right"></div>
</div>
<wicket:child />
</div>
</wicket:panel>
ChildPanel.html
<?xml version="1.0" encoding="UTF-8" ?>
<wicket:extend xmlns:wicket="http://wicket.apache.org">
<wicket:panel wicket:id="panel1" />
<wicket:fragment wicket:id="fragment1">
</wicket:fragment>
</wicket:extend>
ChildPanel.java
public class ChildPanel extends Panel
{
public ChildPanel(String id, IModel<?> model)
{
super(id, model);
add(new Fragment("panel1", "fragment1", this);
}
}
问题存在于 Wicket Markup.java类中:
public final IMarkupFragment find(final String id)
{
Args.notEmpty(id, "id");
MarkupStream stream = new MarkupStream(this);
stream.setCurrentIndex(0);
while (stream.hasMore())
{
MarkupElement elem = stream.get();
if (elem instanceof ComponentTag)
{
ComponentTag tag = stream.getTag();
if (tag.isOpen() || tag.isOpenClose())
{
if (tag.getId().equals(id))
{
return stream.getMarkupFragment();
}
if (tag.isOpen() && !tag.hasNoCloseTag() && !(tag instanceof WicketTag) &&
!"head".equals(tag.getName()) && !tag.isAutoComponentTag())
{
stream.skipToMatchingCloseTag(tag);
}
}
}
stream.next();
}
return null;
}
当应用程序遍历流时,它会在BasePanel 标记中查找。在查看打开标记后<div wicket:id="dialog">
,它会迭代到结束标记</div>
,因此它没有查看ChildPanel 标记内部。
您有什么建议或解决方案吗?
谢谢,曼努埃尔