gpt4 book ai didi

java - 按按钮关闭 Wicket 模式窗口

转载 作者:行者123 更新时间:2023-11-30 05:57:56 24 4
gpt4 key购买 nike

我想通过按模态窗口页面上的按钮来关闭模态窗口。它不起作用。我的模式窗口页面包含一个视频播放器。

我的代码是:

public class PlayVideoWindow extends WebPage {
public PlayVideoWindow(final Page modalWindowPage, final ModalWindow window, final String itemId) {
final String xmlFilePath = ((WebApplication) getApplication()).getServletContext().getRealPath("/resources/video/xml/video.xml");
String filename = null;

try {
filename = WebVideo.getVideo(itemId, xmlFilePath);
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

WebMarkupContainer videoContainer = new WebMarkupContainer("videoDiv");
add(videoContainer);

add(HeaderContributor.forJavaScript("resources/video/js/swfobject.js"));

final String script = "var swfVersionStr = '10.0.0';"
+ "var xiSwfUrlStr = 'playerProductInstall.swf';"
+ "var flashvars = {};"
+ "flashvars.filename = '"+ filename +"'" +";"
+ "var params = {};"
+ "params.wmode = 'transparent';"
+ "params.quality = 'high';"
+ "params.allowscriptaccess = 'always';"
+ "params.allowfullscreen = 'true';"
+ "params.allownetworking = 'all';"
+ "var attributes = {};"
+ "attributes.id = 'Player';"
+ "attributes.name = 'Player';"
+ "attributes.align = 'left';"
+ "swfobject.embedSWF('/jtrac/resources/video/swf/Player.swf', 'movieDiv', '320', '320', swfVersionStr, xiSwfUrlStr, flashvars, params, attributes);"
+ "swfobject.createCSS('#flashContent', 'display:block;text-align:left;');";

add(new AbstractBehavior() {
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
response.renderOnLoadJavascript(script);
}
});

//videoContainer.add(new AjaxButton("close") {
// protected void onSubmit(final AjaxRequestTarget target, final Form form) {
// PlayVideoWindow.this.close(target);
//}
//});

//Button closeButton;
//videoContainer.add(closeButton = new Button("close"));
//closeButton.add(new AttributeAppender("onclick", new Model("window.close();"), ";"));
}
}

这是 HTML:

<div wicket:id="videoDiv">
<div id="movieDiv"></div>
<input type="button" wicket:id="close" />
</div>

注释掉的代码行是我的测试。任何信息都会对我非常有帮助。谢谢。

编辑:
我用这段代码解决了我的问题:

add(new AjaxLink("close") {
public void onClick(AjaxRequestTarget target) {
window.close(target);
}
});

最佳答案

这是一个示例脚本:

<script type="text/javascript">

if (top != self) {
var wicket = top.Wicket;
if (wicket && wicket.Window) {
var modal = wicket.Window.get();
if (modal) {
modal.close();
}
}
top.location.href = location.href;
}
</script>

关于java - 按按钮关闭 Wicket 模式窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4944728/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com