我正在尝试从wicket应用程序弹出一个html页面。 html页面没有相应的.java文件。该页面是静态html页面。
我尝试使用以下逻辑弹出html页面,这是wicket应用程序的一部分:
PopupSettings popupSettings =
new PopupSettings(PopupSettings.RESIZABLE | PopupSettings.SCROLLBARS).setHeight(500).setWidth(700);
Link link = new Link("link") {
@Override
public void onClick() {
System.out.println("clicked");
setResponsePage(PopupPage.class);
}
};
link.setPopupSettings(popupSettings);
add(link);
但为了这个工作,我需要有一个带有java页面的html页面。但根据我的要求,我已经修复了html页面(比如test.html),我想弹出它。 另外我想点击按钮弹出这个html页面。但我没有为按钮获取任何方法,如setPopupSettings()。有人可以告诉我如何为按钮实现它吗?
答案 0 :(得分:0)
我能想到的最简单的方法是在你的html中添加按钮:
<button type="button" wicket:id="popupButton">Pop</button>
在代码中你可以做这样的事情:
add(new WebMarkupContainer("popupButton").add(AttributeAppender.append("onclick",
"window.open('test.html', 'popup', 'width=500,height=700,scrollbars=yes');")));
或者如果您希望它更具动态性,您可以使用模型:
add(new WebMarkupContainer("popupButton").add(AttributeAppender.append("onclick",
new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return "window.open('test.html', 'popup', 'width=500,height=700,scrollbars=yes');";
}
})));