atom feed10 messages in org.apache.wicket.devRe: modal dialog and nesting of forms.
FromSent OnAttachments
Johan CompagnerFeb 16, 2012 11:16 am 
Igor VaynbergFeb 16, 2012 11:20 am 
Johan CompagnerFeb 16, 2012 11:22 am 
Johan CompagnerFeb 16, 2012 11:36 am 
Igor VaynbergFeb 16, 2012 11:51 am 
Johan CompagnerFeb 16, 2012 11:55 am 
Igor VaynbergFeb 16, 2012 11:57 am 
Johan CompagnerFeb 16, 2012 12:03 pm 
Igor VaynbergFeb 16, 2012 12:11 pm 
Sven MeierFeb 17, 2012 8:35 am 
Subject:Re: modal dialog and nesting of forms.
From:Sven Meier (
Date:Feb 17, 2012 8:35:00 am

imho simpler to put a form inside modal's panel and call it a day

IMHO the modalwindow-form requirement is weird. It's counter-intuitive and
inelegant - just look at all the html elements created in modal window's js. It breaks encapsulation: Why should I put the modal window into a form, when I
don't even know whether a nested panel uses a form or not? Furthermore I remember having problems with nesting a multipart-form inside a
modal window (inside a form). Form nesting is a special (questionable) case, why should a developer even know
about if he just want's to put a form into a modal window?

We should fix this issue exactly as it has been proposed already, by introducing
a new interface in core: IMarkupSeparator (or whatever its name) could indicate that its contained markup
will not be in the normal markup tree.

This marker could be useful for other cases too, not only form separation.
Someone mentioned another use case but I'll have to look up the details.

I'll create a new patch for WICKET-3404.

Regards Sven

On 02/16/2012 09:11 PM, Igor Vaynberg wrote:

On Thu, Feb 16, 2012 at 12:03 PM, Johan Compagner<> wrote:

its way better to say that you should override that method and return false..

that would require every panel that has a form to be built with this in mind. imho much simpler to always put the modal inside a form instead.

because now you have to already know that you will show forms in a dialog and place a form on some page..

you just have to make sure that you always put your modal window inside a wicket form

What if you just have a modal window that you reuse all over the place in many pages then you have to add a form? Why doesn't wicket do that him self then inside the modal window component....

i suppose since modal window is a panel it can have a form in it. patch? :)

now it is also not always that nice, now the panel must know that it is shown in a modal window and override that method i am just thinking can't we make that isRootForm smarter that it also test if it is inside a modal window..

that would require the modal to be in core, or implement some new core interface. imho simpler to put a form inside modal's panel and call it a day.


On Thu, Feb 16, 2012 at 20:58, Igor Vaynberg<>wrote:

thats why the javadoc says to put the modal window component inside a wicket form...


On Thu, Feb 16, 2012 at 11:55 AM, Johan Compagner<> wrote:

but the modal dialog iself is not in a form..

there are only 2 forms in my example the one that the modal dialog generates in js code and the one inside the panel that i show in the modal dialog

But it is fixed by overriding that isRootForm() and returning false myself then it works just fine

On Thu, Feb 16, 2012 at 20:52, Igor Vaynberg< wrote:

the modal dialog form is, but since the panel is rendered inside modal's parent initially the wicket form inside the modal should see the wicket form that the modal itself is in...

the rendered hierarchy should be like this

form - wicket form modal window content panel div - wicket form inside the modal rendered as div instead of form

now when modal is opened the content panel is reparented in dom

body form - dom form created by modal js content panel div - wicket form inside the modal's content


On Thu, Feb 16, 2012 at 11:36 AM, Johan Compagner< wrote:

ok for a form inside a modal dialog you need to override:

/** * @see org.apache.wicket.markup.html.form.Form#isRootForm() */ @Override public boolean isRootForm() { return false; }

because the default behavior will ofcourse not find any other form because the modal dialog form is just in javascript/html, its not a wicket component..

On Thu, Feb 16, 2012 at 20:22, Johan Compagner<>


yes i just read that in a jira issue :) but in my example it doesn't ... will check it

On Thu, Feb 16, 2012 at 20:20, Igor Vaynberg<


the whole idea of putting the modal into a wicket form is that forms inside the modal should change their form tags to divs because they see they are inside another form...


On Thu, Feb 16, 2012 at 11:16 AM, Johan Compagner<> wrote:


we say

"If you want to use form in modal window component make sure that



the modal window itself in another form (nesting forms is legal in Wicket) and that the form on modal window is submitted before the window get closed."

problem is that this is illegal in the browser. And chrome some if i push through ajax new content in the modal



has that form completely removes the form from the resulting component tree..

I guess this is because the modal dialog generates a form tag



then also a form tag is generated in the content of the modal



and chrome just filters that out? Weird thing is that chrome doesn't do that when you do a full page refresh...