Wicket:模式窗口中的表单
我写了一个支持文件/图像上传的面板。所以面板是一个简单的平面形式。该面板在正常的 Wicket 页面中工作。
我现在想做的事: 我想在模式窗口中使用该面板。面板显示正确。但是,当我提交/上传新文件时,我的浏览器会提示我是否要离开该页面。包含模式窗口 DIV 的页面本身就是一个表单。
我的研究没有发现有关模式窗口中表单的任何有趣信息,期望它必须是独立的(嵌套表单)。我认为这个先决条件已经满足。
有没有可用的信息,我做错了什么?有教程吗?
I have written an panel which supports file / image uploads. So the panel is a simple plain form. The panel works in a normal Wicket page.
What I would like to do now:
I would like to use the panel in a modal window. The panel is displayed correctly. However, when I submit it / upload a new file, my browser prompts whether or not I would like to leave the page. The page which contains the DIV of the modal window is a form itself.
My research didn't turn up any interesting information about forms in a modal window expect it has to be self contained (nested form). I think this prerequisit is met.
Is there any information available, what I have done wrong? Any tutorials?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用
AjaxSubmitButton
(或AjaxSubmitLink
)来提交表单。问题是模态窗口需要Ajax通信。如果您使用窗口只是重新处理整个页面而不关心 Ajax,那么您可以重写ModalWindow#getCloseJavaScript()
方法。You need to use an
AjaxSubmitButton
(orAjaxSubmitLink
) to submit your form. The problem is that the modal window requires Ajax communication. If you use the window to just reprocess a whole page and don't care about the Ajax'ness, then you can override theModalWindow#getCloseJavaScript()
method.正如 Martijn 指出的,模态窗口依赖于 AJAX 通信。因此,请使用 AjaxSubmitButton 或等效项。当模式窗口提交后需要更新主窗口中的组件时,可以通过将它们添加到
AjaxRequestTarget
来完成。然而,当涉及多部分表单(文件上传)时,这不太有效。显然,多部分不能很好地与 AJAX 配合使用。必须执行 IFrame 技巧,如下所示:http://www.doorient.com/blog/2008/04/23/wicket-ajax-like-file-upload-on-a-modal-window/
As Martijn pointed out, the modal window relies on AJAX communication. So use
AjaxSubmitButton
or equivalents. When components in the main window need to be updated after the submit of the modal window, this can be done by adding them to theAjaxRequestTarget
.However when it comes to multi part forms (file uploads) this does not work quite. Apparently multi part doesn't play nicely with AJAX. One has to do an IFrame trick as pointed out e.g. here: http://www.dooriented.com/blog/2008/04/23/wicket-ajax-like-file-upload-on-a-modal-window/