开发者

Wicket: Form in a modal window

开发者 https://www.devze.com 2023-03-31 12:02 出处:网络
I have written an panel which supports file / image uploa开发者_如何学编程ds. So the panel is a simple plain form. The panel works in a normal Wicket page.

I have written an panel which supports file / image uploa开发者_如何学编程ds. 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?


You need to use an AjaxSubmitButton (or AjaxSubmitLink) 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 the ModalWindow#getCloseJavaScript() method.


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 the AjaxRequestTarget.

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/

0

精彩评论

暂无评论...
验证码 换一张
取 消