我有这个 html 标记:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org/" xml:lang="cs" lang="cs">
<wicket:panel>
<div id="nav">
<ul>
<li>
<a href="./page2.html" class="here">page 1</a>
</li>
<li>
<a href="./page3.html" class="">page 2</a>
</li>
<li>
<a href="./kontakt.html" class="">page 3</a>
</li>
</ul>
</div>
</wicket:panel>
</html>
这是我非常简单的面板检票口代码:
public class PanelMenu extends Panel{
private static final long serialVersionUID = 1L;
public PanelMenu(String id){
super(id);
}
}
@Override
protected void onBeforeRender(){
String markup = this.getAssociatedMarkup().toString();
markup = markup.replaceAll("a", "b");
//how to write modyfied markup for panel to response?
this.getResponse().write(markup);//this write to start of the page, not panel
super.onBeforeRender();
}
在我的页面上,我这样做:
this.add((new PanelMenu("panelMenu")).setRenderBodyOnly(true));
我需要知道如何将变量中面板的修改后的 html 标记写markup
回响应。我该怎么做?this.getResponse().write(markup)
写在页面的开头。