You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Korbinian Bachl - privat <ko...@whiskyworld.de> on 2008/04/08 13:44:49 UTC

ModalWindow + Submit

Hello,

I've noticed that a Form inside a ModalWindow can't be submitted using 
the onSubmit function (and dislikes a standard submit button) but 
instead requires an AjaxButton to call the action - why is this so? It 
makes my life currently somehow hard as I need 2 nearly identical forms 
- one with AjaxButton (in case I want to use it in  ModalWindow), one 
without AjaxButton for non JS pages.

Also I noticed a strage behaviour:

when using ModalWindow with a Page we have the pageConstructor() that 
creates a whole new page (all models are fresh) when opening it, while 
in case you use it with a Panel/ Component the component is created just 
once and Models arent cleaned up in case you close the window and reopen 
it (e.g.: a form you put in and submit and close window and reopen it 
using initial link displays the submited values) - opposite behaviour 
compared to ModalWindow with Page where on each creation all is cleaned.

Best,

Korbinian







Re: ModalWindow + Submit

Posted by Korbinian Bachl - privat <ko...@whiskyworld.de>.
Hi Nino,

> Why not use the panel directly?
> 
> I use panels for my modal window and it works fine:)
> 
> I meant this:
> |myformPanel
> |
> |-myformPanelWithAjaxSubmitANDModalAware
> |-myformPanelWithNormalButton

so you have a Panel holding the Form and extend this then to hold the 
right submitter then? I mean this would go to 3 Java + 3 HTML files for 
1 form, seems a bit much on the long run for me.

> 
> And this for displaying:
>        AjaxLink popupLink = new AjaxLink("manageWeightPop") {
>            @Override
>            public void onClick(AjaxRequestTarget target) {
>                target
>                        
> .appendJavascript("Wicket.Window.unloadConfirmation = false;");
>                modalWindow.setTitle("Weight Log.");
>                modalWindow.setMinimalHeight(700);
>                modalWindow.setContent(new ManageWeightPanel(modalWindow
>                        .getContentId(), modalWindow,
>                        new BaseEntityDetachableModel(getPerson())));
>                modalWindow.show(target);
>            }
>        };

youre creating a modalWindow here directly using JS? Or where do you 
create it?

Im currently creating a final ModalWindow and attaching it to a fixed 
div while calling it:
  final ModalWindow mw = new ModalWindow("mw");
         EigenschaftenFormPanel ep = new 
EigenschaftenFormPanel(mw.getContentId(), new Eigenschaften());
         ep.setWindow(mw);
         mw.setContent(ep);
         mw.setInitialHeight(140);
         mw.setResizable(false);

add(new AjaxLink("showmw")
         {
             public void onClick(AjaxRequestTarget target)
             {
                 mw.show(target);
             }
         });

Is this the right usage then?

Best,

Korbinian

> 
> 
> regards Nino
> 
> Maurice Marrink wrote:
>> I think it would be even better to wrap the panel nino is talking
>> about in a new page for your modal window.
>>
>> Maurice
>>
>> On Tue, Apr 8, 2008 at 2:59 PM, Nino Saturnino Martinez Vazquez Wael
>> <ni...@jayway.dk> wrote:
>>  
>>>  Korbinian Bachl - privat wrote:
>>>
>>>    
>>>> Hello,
>>>>
>>>> I've noticed that a Form inside a ModalWindow can't be submitted 
>>>> using the
>>>>       
>>> onSubmit function (and dislikes a standard submit button) but instead
>>> requires an AjaxButton to call the action - why is this so? It makes 
>>> my life
>>> currently somehow hard as I need 2 nearly identical forms - one with
>>> AjaxButton (in case I want to use it in  ModalWindow), one without
>>> AjaxButton for non JS pages.
>>>    
>>>>       
>>>  Because of the server round trip I think.. Why not have one panel, 
>>> which
>>> contains your form and then two childs, which adds the submit part eg a
>>> submit link etc...
>>>
>>>
>>>
>>>    
>>>> Also I noticed a strage behaviour:
>>>>
>>>> when using ModalWindow with a Page we have the pageConstructor() that
>>>>       
>>> creates a whole new page (all models are fresh) when opening it, 
>>> while in
>>> case you use it with a Panel/ Component the component is created just 
>>> once
>>> and Models arent cleaned up in case you close the window and reopen it
>>> (e.g.: a form you put in and submit and close window and reopen it using
>>> initial link displays the submited values) - opposite behaviour 
>>> compared to
>>> ModalWindow with Page where on each creation all is cleaned.
>>>    
>>>> Best,
>>>>
>>>> Korbinian
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>       
>>>  --
>>>  -Wicket for love
>>>
>>>  Nino Martinez Wael
>>>  Java Specialist @ Jayway DK
>>>  http://www.jayway.dk
>>>  +45 2936 7684
>>>
>>>
>>>     
>>
>>
>>   
> 

Re: ModalWindow + Submit

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
Why not use the panel directly?

I use panels for my modal window and it works fine:)

I meant this:
|myformPanel
|
|-myformPanelWithAjaxSubmitANDModalAware
|-myformPanelWithNormalButton

And this for displaying:
        AjaxLink popupLink = new AjaxLink("manageWeightPop") {
            @Override
            public void onClick(AjaxRequestTarget target) {
                target
                        
.appendJavascript("Wicket.Window.unloadConfirmation = false;");
                modalWindow.setTitle("Weight Log.");
                modalWindow.setMinimalHeight(700);
                modalWindow.setContent(new ManageWeightPanel(modalWindow
                        .getContentId(), modalWindow,
                        new BaseEntityDetachableModel(getPerson())));
                modalWindow.show(target);
            }
        };


regards Nino

Maurice Marrink wrote:
> I think it would be even better to wrap the panel nino is talking
> about in a new page for your modal window.
>
> Maurice
>
> On Tue, Apr 8, 2008 at 2:59 PM, Nino Saturnino Martinez Vazquez Wael
> <ni...@jayway.dk> wrote:
>   
>>  Korbinian Bachl - privat wrote:
>>
>>     
>>> Hello,
>>>
>>> I've noticed that a Form inside a ModalWindow can't be submitted using the
>>>       
>> onSubmit function (and dislikes a standard submit button) but instead
>> requires an AjaxButton to call the action - why is this so? It makes my life
>> currently somehow hard as I need 2 nearly identical forms - one with
>> AjaxButton (in case I want to use it in  ModalWindow), one without
>> AjaxButton for non JS pages.
>>     
>>>       
>>  Because of the server round trip I think.. Why not have one panel, which
>> contains your form and then two childs, which adds the submit part eg a
>> submit link etc...
>>
>>
>>
>>     
>>> Also I noticed a strage behaviour:
>>>
>>> when using ModalWindow with a Page we have the pageConstructor() that
>>>       
>> creates a whole new page (all models are fresh) when opening it, while in
>> case you use it with a Panel/ Component the component is created just once
>> and Models arent cleaned up in case you close the window and reopen it
>> (e.g.: a form you put in and submit and close window and reopen it using
>> initial link displays the submited values) - opposite behaviour compared to
>> ModalWindow with Page where on each creation all is cleaned.
>>     
>>> Best,
>>>
>>> Korbinian
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>       
>>  --
>>  -Wicket for love
>>
>>  Nino Martinez Wael
>>  Java Specialist @ Jayway DK
>>  http://www.jayway.dk
>>  +45 2936 7684
>>
>>
>>     
>
>
>   

-- 
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


Re: ModalWindow + Submit

Posted by Korbinian Bachl - privat <ko...@whiskyworld.de>.

Nino Saturnino Martinez Vazquez Wael schrieb:
>>   
> I guess he could also solve this by having one constructor for ajax and 
> another for non ajax in his panel.. That would mean only one panel.. It 
> depends on what he wants..
> 
> Wicket in a nutshell letting OO concerns up to you:)

well, thats the trouble ;)

I have a complex objectgraph over currently 15 entities that goes into a 
single complex form and where I need a bunch of ModalWindows to display 
little forms to give additional input/ manipulating method for the 
mainform, so the mainform doesnt get too complex all over.

And the trouble is now the point where to start and how to have many 
ModalWindows holding smaller Form's each without creating too much 
manually... gave me now some headache for the last days.

Re: ModalWindow + Submit

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.

Maurice Marrink wrote:
> @Nino, i seem to remember some issues a while back
>  with modalwindows and forms and i needed a page to solve them. It's
> possible this was caused by something special i needed to do, so
> perhaps it also works without in other situations. I haven't used
> modal window often enough to know for sure.
>
>   
Ahh, thats why then...
> @Korbinian, If you wrap the panel in a page you could delegate the
> close behavior to the page by using a WindowClosedCallback. the panel
> never needs to know it will be used in a modalwindow.
>
> As for the multitude of markupfiles i think you could have a parent
> panel with markup which contains a form and a normal button to submit
> the form. the ajaxified panel then only needs to replace the button
> with an ajaxbutton. it does not need a new markup.
>
>   
I guess he could also solve this by having one constructor for ajax and 
another for non ajax in his panel.. That would mean only one panel.. It 
depends on what he wants..

Wicket in a nutshell letting OO concerns up to you:)
> Maurice
>
> On Tue, Apr 8, 2008 at 4:01 PM, Korbinian Bachl - whiskyworld
> <ko...@whiskyworld.de> wrote:
>   
>> Hi Maurice,
>>
>>  the problem is that the panel needs to know about the modal window so it
>> can close/ react on it. And as I wrote to Nino, this additional extending
>> means a lot of code bleed - however, im not sure if its not just me who
>> didnt understand the usage of them right...
>>
>>  Im using the mw mainly for the ability to add additional lines in a
>> DropDownChoice etc.;
>>
>>  Best,
>>
>>  Korbinian
>>
>>
>>  Maurice Marrink schrieb:
>>
>>
>>
>>     
>>> I think it would be even better to wrap the panel nino is talking
>>> about in a new page for your modal window.
>>>
>>> Maurice
>>>
>>> On Tue, Apr 8, 2008 at 2:59 PM, Nino Saturnino Martinez Vazquez Wael
>>> <ni...@jayway.dk> wrote:
>>>
>>>       
>>>>  Korbinian Bachl - privat wrote:
>>>>
>>>>
>>>>         
>>>>> Hello,
>>>>>
>>>>> I've noticed that a Form inside a ModalWindow can't be submitted using
>>>>>           
>> the
>>     
>>>> onSubmit function (and dislikes a standard submit button) but instead
>>>> requires an AjaxButton to call the action - why is this so? It makes my
>>>>         
>> life
>>     
>>>> currently somehow hard as I need 2 nearly identical forms - one with
>>>> AjaxButton (in case I want to use it in  ModalWindow), one without
>>>> AjaxButton for non JS pages.
>>>>
>>>>         
>>>>>           
>>>>  Because of the server round trip I think.. Why not have one panel,
>>>>         
>> which
>>     
>>>> contains your form and then two childs, which adds the submit part eg a
>>>> submit link etc...
>>>>
>>>>
>>>>
>>>>
>>>>         
>>>>> Also I noticed a strage behaviour:
>>>>>
>>>>> when using ModalWindow with a Page we have the pageConstructor() that
>>>>>
>>>>>           
>>>> creates a whole new page (all models are fresh) when opening it, while
>>>>         
>> in
>>     
>>>> case you use it with a Panel/ Component the component is created just
>>>>         
>> once
>>     
>>>> and Models arent cleaned up in case you close the window and reopen it
>>>> (e.g.: a form you put in and submit and close window and reopen it using
>>>> initial link displays the submited values) - opposite behaviour compared
>>>>         
>> to
>>     
>>>> ModalWindow with Page where on each creation all is cleaned.
>>>>
>>>>         
>>>>> Best,
>>>>>
>>>>> Korbinian
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>           
>>>>  --
>>>>  -Wicket for love
>>>>
>>>>  Nino Martinez Wael
>>>>  Java Specialist @ Jayway DK
>>>>  http://www.jayway.dk
>>>>  +45 2936 7684
>>>>
>>>>
>>>>
>>>>         
>>  --
>>  ____________________________________
>>   whiskyworld e.K.
>>   http://www.whiskyworld.de
>>   Ziegelfeld 6
>>   94481 Grafenau/ Haus im Wald
>>   Tel. 08555/ 406 320
>>   Fax. 08555/ 406 319
>>
>>   Amtsgericht Passau: HRA 11760
>>   Geschäftsführer: Ulrike Bachl
>>   UstID: DE193152422
>>   ________________________________
>>
>>     
>
>
>   

-- 
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


Re: ModalWindow + Submit

Posted by Maurice Marrink <ma...@gmail.com>.
@Nino, i seem to remember some issues a while back
 with modalwindows and forms and i needed a page to solve them. It's
possible this was caused by something special i needed to do, so
perhaps it also works without in other situations. I haven't used
modal window often enough to know for sure.

@Korbinian, If you wrap the panel in a page you could delegate the
close behavior to the page by using a WindowClosedCallback. the panel
never needs to know it will be used in a modalwindow.

As for the multitude of markupfiles i think you could have a parent
panel with markup which contains a form and a normal button to submit
the form. the ajaxified panel then only needs to replace the button
with an ajaxbutton. it does not need a new markup.

Maurice

On Tue, Apr 8, 2008 at 4:01 PM, Korbinian Bachl - whiskyworld
<ko...@whiskyworld.de> wrote:
> Hi Maurice,
>
>  the problem is that the panel needs to know about the modal window so it
> can close/ react on it. And as I wrote to Nino, this additional extending
> means a lot of code bleed - however, im not sure if its not just me who
> didnt understand the usage of them right...
>
>  Im using the mw mainly for the ability to add additional lines in a
> DropDownChoice etc.;
>
>  Best,
>
>  Korbinian
>
>
>  Maurice Marrink schrieb:
>
>
>
> > I think it would be even better to wrap the panel nino is talking
> > about in a new page for your modal window.
> >
> > Maurice
> >
> > On Tue, Apr 8, 2008 at 2:59 PM, Nino Saturnino Martinez Vazquez Wael
> > <ni...@jayway.dk> wrote:
> >
> > >
> > >  Korbinian Bachl - privat wrote:
> > >
> > >
> > > > Hello,
> > > >
> > > > I've noticed that a Form inside a ModalWindow can't be submitted using
> the
> > > >
> > > onSubmit function (and dislikes a standard submit button) but instead
> > > requires an AjaxButton to call the action - why is this so? It makes my
> life
> > > currently somehow hard as I need 2 nearly identical forms - one with
> > > AjaxButton (in case I want to use it in  ModalWindow), one without
> > > AjaxButton for non JS pages.
> > >
> > > >
> > > >
> > >  Because of the server round trip I think.. Why not have one panel,
> which
> > > contains your form and then two childs, which adds the submit part eg a
> > > submit link etc...
> > >
> > >
> > >
> > >
> > > > Also I noticed a strage behaviour:
> > > >
> > > > when using ModalWindow with a Page we have the pageConstructor() that
> > > >
> > > creates a whole new page (all models are fresh) when opening it, while
> in
> > > case you use it with a Panel/ Component the component is created just
> once
> > > and Models arent cleaned up in case you close the window and reopen it
> > > (e.g.: a form you put in and submit and close window and reopen it using
> > > initial link displays the submited values) - opposite behaviour compared
> to
> > > ModalWindow with Page where on each creation all is cleaned.
> > >
> > > > Best,
> > > >
> > > > Korbinian
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > >  --
> > >  -Wicket for love
> > >
> > >  Nino Martinez Wael
> > >  Java Specialist @ Jayway DK
> > >  http://www.jayway.dk
> > >  +45 2936 7684
> > >
> > >
> > >
> >
>
>  --
>  ____________________________________
>   whiskyworld e.K.
>   http://www.whiskyworld.de
>   Ziegelfeld 6
>   94481 Grafenau/ Haus im Wald
>   Tel. 08555/ 406 320
>   Fax. 08555/ 406 319
>
>   Amtsgericht Passau: HRA 11760
>   Geschäftsführer: Ulrike Bachl
>   UstID: DE193152422
>   ________________________________
>

Re: ModalWindow + Submit

Posted by Korbinian Bachl - whiskyworld <ko...@whiskyworld.de>.
Hi Maurice,

the problem is that the panel needs to know about the modal window so it 
can close/ react on it. And as I wrote to Nino, this additional 
extending means a lot of code bleed - however, im not sure if its not 
just me who didnt understand the usage of them right...

Im using the mw mainly for the ability to add additional lines in a 
DropDownChoice etc.;

Best,

Korbinian


Maurice Marrink schrieb:
> I think it would be even better to wrap the panel nino is talking
> about in a new page for your modal window.
> 
> Maurice
> 
> On Tue, Apr 8, 2008 at 2:59 PM, Nino Saturnino Martinez Vazquez Wael
> <ni...@jayway.dk> wrote:
>>
>>  Korbinian Bachl - privat wrote:
>>
>>> Hello,
>>>
>>> I've noticed that a Form inside a ModalWindow can't be submitted using the
>> onSubmit function (and dislikes a standard submit button) but instead
>> requires an AjaxButton to call the action - why is this so? It makes my life
>> currently somehow hard as I need 2 nearly identical forms - one with
>> AjaxButton (in case I want to use it in  ModalWindow), one without
>> AjaxButton for non JS pages.
>>>
>>  Because of the server round trip I think.. Why not have one panel, which
>> contains your form and then two childs, which adds the submit part eg a
>> submit link etc...
>>
>>
>>
>>> Also I noticed a strage behaviour:
>>>
>>> when using ModalWindow with a Page we have the pageConstructor() that
>> creates a whole new page (all models are fresh) when opening it, while in
>> case you use it with a Panel/ Component the component is created just once
>> and Models arent cleaned up in case you close the window and reopen it
>> (e.g.: a form you put in and submit and close window and reopen it using
>> initial link displays the submited values) - opposite behaviour compared to
>> ModalWindow with Page where on each creation all is cleaned.
>>> Best,
>>>
>>> Korbinian
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>  --
>>  -Wicket for love
>>
>>  Nino Martinez Wael
>>  Java Specialist @ Jayway DK
>>  http://www.jayway.dk
>>  +45 2936 7684
>>
>>

-- 
____________________________________
   whiskyworld e.K.
   http://www.whiskyworld.de
   Ziegelfeld 6
   94481 Grafenau/ Haus im Wald
   Tel. 08555/ 406 320
   Fax. 08555/ 406 319

   Amtsgericht Passau: HRA 11760
   Geschäftsführer: Ulrike Bachl
   UstID: DE193152422
   ________________________________

Re: ModalWindow + Submit

Posted by Maurice Marrink <ma...@gmail.com>.
I think it would be even better to wrap the panel nino is talking
about in a new page for your modal window.

Maurice

On Tue, Apr 8, 2008 at 2:59 PM, Nino Saturnino Martinez Vazquez Wael
<ni...@jayway.dk> wrote:
>
>
>  Korbinian Bachl - privat wrote:
>
> > Hello,
> >
> > I've noticed that a Form inside a ModalWindow can't be submitted using the
> onSubmit function (and dislikes a standard submit button) but instead
> requires an AjaxButton to call the action - why is this so? It makes my life
> currently somehow hard as I need 2 nearly identical forms - one with
> AjaxButton (in case I want to use it in  ModalWindow), one without
> AjaxButton for non JS pages.
> >
> >
>  Because of the server round trip I think.. Why not have one panel, which
> contains your form and then two childs, which adds the submit part eg a
> submit link etc...
>
>
>
> > Also I noticed a strage behaviour:
> >
> > when using ModalWindow with a Page we have the pageConstructor() that
> creates a whole new page (all models are fresh) when opening it, while in
> case you use it with a Panel/ Component the component is created just once
> and Models arent cleaned up in case you close the window and reopen it
> (e.g.: a form you put in and submit and close window and reopen it using
> initial link displays the submited values) - opposite behaviour compared to
> ModalWindow with Page where on each creation all is cleaned.
> >
> > Best,
> >
> > Korbinian
> >
> >
> >
> >
> >
> >
> >
> >
>
>  --
>  -Wicket for love
>
>  Nino Martinez Wael
>  Java Specialist @ Jayway DK
>  http://www.jayway.dk
>  +45 2936 7684
>
>

Re: ModalWindow + Submit

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.

Korbinian Bachl - privat wrote:
> Hello,
>
> I've noticed that a Form inside a ModalWindow can't be submitted using 
> the onSubmit function (and dislikes a standard submit button) but 
> instead requires an AjaxButton to call the action - why is this so? It 
> makes my life currently somehow hard as I need 2 nearly identical 
> forms - one with AjaxButton (in case I want to use it in  
> ModalWindow), one without AjaxButton for non JS pages.
>
Because of the server round trip I think.. Why not have one panel, which 
contains your form and then two childs, which adds the submit part eg a 
submit link etc...
> Also I noticed a strage behaviour:
>
> when using ModalWindow with a Page we have the pageConstructor() that 
> creates a whole new page (all models are fresh) when opening it, while 
> in case you use it with a Panel/ Component the component is created 
> just once and Models arent cleaned up in case you close the window and 
> reopen it (e.g.: a form you put in and submit and close window and 
> reopen it using initial link displays the submited values) - opposite 
> behaviour compared to ModalWindow with Page where on each creation all 
> is cleaned.
>
> Best,
>
> Korbinian
>
>
>
>
>
>
>

-- 
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684