Quantcast

modal dialog and nesting of forms.

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

modal dialog and nesting of forms.

Johan Compagner
here:

http://wicket.apache.org/apidocs/1.5/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.html

we say

"If you want to use form in modal window component make sure that you put
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 dialog that
has that form
completely removes the form from the resulting component tree..

I guess this is because the modal dialog generates a form tag itself, and
then also a form tag is generated in the content of the modal dialog itself
and chrome just filters that out?
Weird thing is that chrome doesn't do that when you do a full page
refresh...

johan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: modal dialog and nesting of forms.

Igor Vaynberg-2
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...

-igor

On Thu, Feb 16, 2012 at 11:16 AM, Johan Compagner <[hidden email]> wrote:

> here:
>
> http://wicket.apache.org/apidocs/1.5/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.html
>
> we say
>
> "If you want to use form in modal window component make sure that you put
> 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 dialog that
> has that form
> completely removes the form from the resulting component tree..
>
> I guess this is because the modal dialog generates a form tag itself, and
> then also a form tag is generated in the content of the modal dialog itself
> and chrome just filters that out?
> Weird thing is that chrome doesn't do that when you do a full page
> refresh...
>
> johan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: modal dialog and nesting of forms.

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 <[hidden email]>wrote:

> 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...
>
> -igor
>
> On Thu, Feb 16, 2012 at 11:16 AM, Johan Compagner <[hidden email]>
> wrote:
> > here:
> >
> >
> http://wicket.apache.org/apidocs/1.5/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.html
> >
> > we say
> >
> > "If you want to use form in modal window component make sure that you put
> > 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 dialog
> that
> > has that form
> > completely removes the form from the resulting component tree..
> >
> > I guess this is because the modal dialog generates a form tag itself, and
> > then also a form tag is generated in the content of the modal dialog
> itself
> > and chrome just filters that out?
> > Weird thing is that chrome doesn't do that when you do a full page
> > refresh...
> >
> > johan
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: modal dialog and nesting of forms.

Johan Compagner
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 <[hidden email]> wrote:

> 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 <[hidden email]>wrote:
>
>> 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...
>>
>> -igor
>>
>> On Thu, Feb 16, 2012 at 11:16 AM, Johan Compagner <[hidden email]>
>> wrote:
>> > here:
>> >
>> >
>> http://wicket.apache.org/apidocs/1.5/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.html
>> >
>> > we say
>> >
>> > "If you want to use form in modal window component make sure that you
>> put
>> > 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 dialog
>> that
>> > has that form
>> > completely removes the form from the resulting component tree..
>> >
>> > I guess this is because the modal dialog generates a form tag itself,
>> and
>> > then also a form tag is generated in the content of the modal dialog
>> itself
>> > and chrome just filters that out?
>> > Weird thing is that chrome doesn't do that when you do a full page
>> > refresh...
>> >
>> > johan
>>
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: modal dialog and nesting of forms.

Igor Vaynberg-2
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

-igor

On Thu, Feb 16, 2012 at 11:36 AM, Johan Compagner <[hidden email]> 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 <[hidden email]> wrote:
>
>> 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 <[hidden email]>wrote:
>>
>>> 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...
>>>
>>> -igor
>>>
>>> On Thu, Feb 16, 2012 at 11:16 AM, Johan Compagner <[hidden email]>
>>> wrote:
>>> > here:
>>> >
>>> >
>>> http://wicket.apache.org/apidocs/1.5/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.html
>>> >
>>> > we say
>>> >
>>> > "If you want to use form in modal window component make sure that you
>>> put
>>> > 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 dialog
>>> that
>>> > has that form
>>> > completely removes the form from the resulting component tree..
>>> >
>>> > I guess this is because the modal dialog generates a form tag itself,
>>> and
>>> > then also a form tag is generated in the content of the modal dialog
>>> itself
>>> > and chrome just filters that out?
>>> > Weird thing is that chrome doesn't do that when you do a full page
>>> > refresh...
>>> >
>>> > johan
>>>
>>
>>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: modal dialog and nesting of forms.

Johan Compagner
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 <[hidden email]>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
>
> -igor
>
> On Thu, Feb 16, 2012 at 11:36 AM, Johan Compagner <[hidden email]>
> 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 <[hidden email]>
> wrote:
> >
> >> 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 <[hidden email]
> >wrote:
> >>
> >>> 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...
> >>>
> >>> -igor
> >>>
> >>> On Thu, Feb 16, 2012 at 11:16 AM, Johan Compagner <
> [hidden email]>
> >>> wrote:
> >>> > here:
> >>> >
> >>> >
> >>>
> http://wicket.apache.org/apidocs/1.5/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.html
> >>> >
> >>> > we say
> >>> >
> >>> > "If you want to use form in modal window component make sure that you
> >>> put
> >>> > 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
> dialog
> >>> that
> >>> > has that form
> >>> > completely removes the form from the resulting component tree..
> >>> >
> >>> > I guess this is because the modal dialog generates a form tag itself,
> >>> and
> >>> > then also a form tag is generated in the content of the modal dialog
> >>> itself
> >>> > and chrome just filters that out?
> >>> > Weird thing is that chrome doesn't do that when you do a full page
> >>> > refresh...
> >>> >
> >>> > johan
> >>>
> >>
> >>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: modal dialog and nesting of forms.

Igor Vaynberg-2
thats why the javadoc says to put the modal window component inside a
wicket form...

-igor

On Thu, Feb 16, 2012 at 11:55 AM, Johan Compagner <[hidden email]> 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 <[hidden email]>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
>>
>> -igor
>>
>> On Thu, Feb 16, 2012 at 11:36 AM, Johan Compagner <[hidden email]>
>> 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 <[hidden email]>
>> wrote:
>> >
>> >> 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 <[hidden email]
>> >wrote:
>> >>
>> >>> 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...
>> >>>
>> >>> -igor
>> >>>
>> >>> On Thu, Feb 16, 2012 at 11:16 AM, Johan Compagner <
>> [hidden email]>
>> >>> wrote:
>> >>> > here:
>> >>> >
>> >>> >
>> >>>
>> http://wicket.apache.org/apidocs/1.5/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.html
>> >>> >
>> >>> > we say
>> >>> >
>> >>> > "If you want to use form in modal window component make sure that you
>> >>> put
>> >>> > 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
>> dialog
>> >>> that
>> >>> > has that form
>> >>> > completely removes the form from the resulting component tree..
>> >>> >
>> >>> > I guess this is because the modal dialog generates a form tag itself,
>> >>> and
>> >>> > then also a form tag is generated in the content of the modal dialog
>> >>> itself
>> >>> > and chrome just filters that out?
>> >>> > Weird thing is that chrome doesn't do that when you do a full page
>> >>> > refresh...
>> >>> >
>> >>> > johan
>> >>>
>> >>
>> >>
>>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: modal dialog and nesting of forms.

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

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

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

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


On Thu, Feb 16, 2012 at 20:58, Igor Vaynberg <[hidden email]>wrote:

> thats why the javadoc says to put the modal window component inside a
> wicket form...
>
> -igor
>
> On Thu, Feb 16, 2012 at 11:55 AM, Johan Compagner <[hidden email]>
> 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 <[hidden email]
> >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
> >>
> >> -igor
> >>
> >> On Thu, Feb 16, 2012 at 11:36 AM, Johan Compagner <[hidden email]
> >
> >> 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 <[hidden email]>
> >> wrote:
> >> >
> >> >> 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 <
> [hidden email]
> >> >wrote:
> >> >>
> >> >>> 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...
> >> >>>
> >> >>> -igor
> >> >>>
> >> >>> On Thu, Feb 16, 2012 at 11:16 AM, Johan Compagner <
> >> [hidden email]>
> >> >>> wrote:
> >> >>> > here:
> >> >>> >
> >> >>> >
> >> >>>
> >>
> http://wicket.apache.org/apidocs/1.5/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.html
> >> >>> >
> >> >>> > we say
> >> >>> >
> >> >>> > "If you want to use form in modal window component make sure that
> you
> >> >>> put
> >> >>> > 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
> >> dialog
> >> >>> that
> >> >>> > has that form
> >> >>> > completely removes the form from the resulting component tree..
> >> >>> >
> >> >>> > I guess this is because the modal dialog generates a form tag
> itself,
> >> >>> and
> >> >>> > then also a form tag is generated in the content of the modal
> dialog
> >> >>> itself
> >> >>> > and chrome just filters that out?
> >> >>> > Weird thing is that chrome doesn't do that when you do a full page
> >> >>> > refresh...
> >> >>> >
> >> >>> > johan
> >> >>>
> >> >>
> >> >>
> >>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: modal dialog and nesting of forms.

Igor Vaynberg-2
On Thu, Feb 16, 2012 at 12:03 PM, Johan Compagner <[hidden email]> 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.

-igor

>
>
> On Thu, Feb 16, 2012 at 20:58, Igor Vaynberg <[hidden email]>wrote:
>
>> thats why the javadoc says to put the modal window component inside a
>> wicket form...
>>
>> -igor
>>
>> On Thu, Feb 16, 2012 at 11:55 AM, Johan Compagner <[hidden email]>
>> 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 <[hidden email]
>> >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
>> >>
>> >> -igor
>> >>
>> >> On Thu, Feb 16, 2012 at 11:36 AM, Johan Compagner <[hidden email]
>> >
>> >> 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 <[hidden email]>
>> >> wrote:
>> >> >
>> >> >> 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 <
>> [hidden email]
>> >> >wrote:
>> >> >>
>> >> >>> 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...
>> >> >>>
>> >> >>> -igor
>> >> >>>
>> >> >>> On Thu, Feb 16, 2012 at 11:16 AM, Johan Compagner <
>> >> [hidden email]>
>> >> >>> wrote:
>> >> >>> > here:
>> >> >>> >
>> >> >>> >
>> >> >>>
>> >>
>> http://wicket.apache.org/apidocs/1.5/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.html
>> >> >>> >
>> >> >>> > we say
>> >> >>> >
>> >> >>> > "If you want to use form in modal window component make sure that
>> you
>> >> >>> put
>> >> >>> > 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
>> >> dialog
>> >> >>> that
>> >> >>> > has that form
>> >> >>> > completely removes the form from the resulting component tree..
>> >> >>> >
>> >> >>> > I guess this is because the modal dialog generates a form tag
>> itself,
>> >> >>> and
>> >> >>> > then also a form tag is generated in the content of the modal
>> dialog
>> >> >>> itself
>> >> >>> > and chrome just filters that out?
>> >> >>> > Weird thing is that chrome doesn't do that when you do a full page
>> >> >>> > refresh...
>> >> >>> >
>> >> >>> > johan
>> >> >>>
>> >> >>
>> >> >>
>> >>
>>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: modal dialog and nesting of forms.

Sven Meier
>  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<[hidden email]>  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.
>
> -igor
>
>>
>> On Thu, Feb 16, 2012 at 20:58, Igor Vaynberg<[hidden email]>wrote:
>>
>>> thats why the javadoc says to put the modal window component inside a
>>> wicket form...
>>>
>>> -igor
>>>
>>> On Thu, Feb 16, 2012 at 11:55 AM, Johan Compagner<[hidden email]>
>>> 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<[hidden email]
>>>> 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
>>>>>
>>>>> -igor
>>>>>
>>>>> On Thu, Feb 16, 2012 at 11:36 AM, Johan Compagner<[hidden email]
>>>>> 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<[hidden email]>
>>>>> wrote:
>>>>>>> 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<
>>> [hidden email]
>>>>>> wrote:
>>>>>>>> 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...
>>>>>>>>
>>>>>>>> -igor
>>>>>>>>
>>>>>>>> On Thu, Feb 16, 2012 at 11:16 AM, Johan Compagner<
>>>>> [hidden email]>
>>>>>>>> wrote:
>>>>>>>>> here:
>>>>>>>>>
>>>>>>>>>
>>> http://wicket.apache.org/apidocs/1.5/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.html
>>>>>>>>> we say
>>>>>>>>>
>>>>>>>>> "If you want to use form in modal window component make sure that
>>> you
>>>>>>>> put
>>>>>>>>> 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
>>>>> dialog
>>>>>>>> that
>>>>>>>>> has that form
>>>>>>>>> completely removes the form from the resulting component tree..
>>>>>>>>>
>>>>>>>>> I guess this is because the modal dialog generates a form tag
>>> itself,
>>>>>>>> and
>>>>>>>>> then also a form tag is generated in the content of the modal
>>> dialog
>>>>>>>> itself
>>>>>>>>> and chrome just filters that out?
>>>>>>>>> Weird thing is that chrome doesn't do that when you do a full page
>>>>>>>>> refresh...
>>>>>>>>>
>>>>>>>>> johan
>>>>>>>

Loading...