Quantcast

How to redirect from a ModalWindow

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

How to redirect from a ModalWindow

Matthias Keller
Hi

I've got a ModalWindow which lets the user select some choices.
Now I need a button in that ModalWindow allowing the user to enter some
new choices.
I don't want that target to be another ModalWindow (as it's referenced
from other places too), so I need to redirect the user to that new page
if he wishes to add a new choice.

Basically that works, using a Button or an AjaxButton both works, but
since the ModalWindow is still open, I get the ugly browser warning
about navigating away from the current page.
What can I do to solve that?
I tried an AjaxButton using

window.close(target);
setResponsePage(OtherPage.class);

But that doesn't work. Any ideas?

Thanks

Matt

smime.p7s (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to redirect from a ModalWindow

Peter Ertl-3


     throw new RestartResponseException(OtherPage.class)

window.close() is not needed!


Am 10.09.2009 um 12:50 schrieb Matthias Keller:

> OtherPage.class


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

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

Re: How to redirect from a ModalWindow

Matthias Keller
Hi Peter

You would be right as long as it wasn't for a ModalWindow.
When having an open ModalWindow, wicket seems to register an unload
javascript event which - when trying to navigate away from the page (be
it by following a link, closing the window etc), displays a confirmation
message which you have to accept. I need to avoid that message, but the
only way to do that probably is by closing that window first so that the
javascript event gets unloaded.

Matt

Peter Ertl wrote:

>
>
>     throw new RestartResponseException(OtherPage.class)
>
> window.close() is not needed!
>
>
> Am 10.09.2009 um 12:50 schrieb Matthias Keller:
>
>> OtherPage.class
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


smime.p7s (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to redirect from a ModalWindow

Michal Kurtak
Hi Matthias,

Try to navigate to another page from WindowClosedCallback

window.close(target);
window.setWindowClosedCallback(new WindowClosedCallback()
{
     public void onClose(AjaxRequestTarget target)
     {
           setResponsePage(OtherPage.class);
     }
}


But remember to remove WindowClosedCallback before you open your
window next time

Michal

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

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

Re: How to redirect from a ModalWindow

Peter Ertl-3
That is sick! :-(

Isn't there a better solution?


Am 11.09.2009 um 08:42 schrieb Michal Kurtak:

> Hi Matthias,
>
> Try to navigate to another page from WindowClosedCallback
>
> window.close(target);
> window.setWindowClosedCallback(new WindowClosedCallback()
> {
>     public void onClose(AjaxRequestTarget target)
>     {
>           setResponsePage(OtherPage.class);
>     }
> }
>
>
> But remember to remove WindowClosedCallback before you open your
> window next time
>
> Michal
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

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

Re: How to redirect from a ModalWindow

vladimir.kovalyuk
In reply to this post by Matthias Keller
Try adding this one to the page markup

                <script language="javascript" type="text/javascript"> jQuery(document).ready(function(){ if (typeof Wicket != 'undefined' && Wicket.Window) Wicket.Window.unloadConfirmation = false; }); </script>
Matthias Keller wrote
Hi Peter

You would be right as long as it wasn't for a ModalWindow.
When having an open ModalWindow, wicket seems to register an unload
javascript event which - when trying to navigate away from the page (be
it by following a link, closing the window etc), displays a confirmation
message which you have to accept. I need to avoid that message, but the
only way to do that probably is by closing that window first so that the
javascript event gets unloaded.

Matt

Peter Ertl wrote:
>
>
>     throw new RestartResponseException(OtherPage.class)
>
> window.close() is not needed!
>
>
> Am 10.09.2009 um 12:50 schrieb Matthias Keller:
>
>> OtherPage.class
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


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

RE: How to redirect from a ModalWindow

Mikko Pukki-3
Hi,

I wouldn't mess around with such scripts unless really necessary. Mainly, because
Wicket can handle domreadyEvents on its own. I solved the problem by extending
ModalWindow and by adding a behavior that disables the unloadConfirmation. Like this:


        public MyModalWindow(String id, IModel title, int initialHeight, int initialWidth)
        {
                super(id);

                setTitle(title);

                add(new DisableDefaultConfirmBehavior());
....

        private class DisableDefaultConfirmBehavior extends AbstractBehavior implements IHeaderContributor {

                private static final long serialVersionUID = 1L;

                @Override
                public void renderHead(IHeaderResponse response)
                {
                        response.renderOnDomReadyJavascript("Wicket.Window.unloadConfirmation = false");
                }

        }

Of course, when having multiple Modal windows on the same page, that script would fire multiple
times, but then again, would it be a good idea to have multiple modal windows in the first place?

- Mikko


-----Original Message-----
From: Vladimir K [mailto:[hidden email]]
Sent: 12. syyskuuta 2009 9:37
To: [hidden email]
Subject: Re: How to redirect from a ModalWindow


Try adding this one to the page markup

                <script language="javascript" type="text/javascript">
                        jQuery(document).ready(function(){
                                if (typeof Wicket != 'undefined' && Wicket.Window)
                                        Wicket.Window.unloadConfirmation = false;
                        });
                </script>


Matthias Keller wrote:

>
> Hi Peter
>
> You would be right as long as it wasn't for a ModalWindow.
> When having an open ModalWindow, wicket seems to register an unload
> javascript event which - when trying to navigate away from the page (be
> it by following a link, closing the window etc), displays a confirmation
> message which you have to accept. I need to avoid that message, but the
> only way to do that probably is by closing that window first so that the
> javascript event gets unloaded.
>
> Matt
>
> Peter Ertl wrote:
>>
>>
>>     throw new RestartResponseException(OtherPage.class)
>>
>> window.close() is not needed!
>>
>>
>> Am 10.09.2009 um 12:50 schrieb Matthias Keller:
>>
>>> OtherPage.class
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
>
>  
>

--
View this message in context: http://www.nabble.com/How-to-redirect-from-a-ModalWindow-tp25381117p25411990.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

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

Re: How to redirect from a ModalWindow

Peter Ertl
Wouldn't it make sense to disable this confirmation dialog in  
deployment mode?

What is it good for anyway?

Am 12.09.2009 um 14:50 schrieb Mikko Pukki:

> Hi,
>
> I wouldn't mess around with such scripts unless really necessary.  
> Mainly, because
> Wicket can handle domreadyEvents on its own. I solved the problem by  
> extending
> ModalWindow and by adding a behavior that disables the  
> unloadConfirmation. Like this:
>
>
> public MyModalWindow(String id, IModel title, int initialHeight,  
> int initialWidth)
> {
> super(id);
>
> setTitle(title);
>
> add(new DisableDefaultConfirmBehavior());
> ....
>
> private class DisableDefaultConfirmBehavior extends  
> AbstractBehavior implements IHeaderContributor {
>
> private static final long serialVersionUID = 1L;
>
> @Override
> public void renderHead(IHeaderResponse response)
> {
> response.renderOnDomReadyJavascript
> ("Wicket.Window.unloadConfirmation = false");
> }
>
> }
>
> Of course, when having multiple Modal windows on the same page, that  
> script would fire multiple
> times, but then again, would it be a good idea to have multiple  
> modal windows in the first place?
>
> - Mikko
>
>
> -----Original Message-----
> From: Vladimir K [mailto:[hidden email]]
> Sent: 12. syyskuuta 2009 9:37
> To: [hidden email]
> Subject: Re: How to redirect from a ModalWindow
>
>
> Try adding this one to the page markup
>
> <script language="javascript" type="text/javascript">
> jQuery(document).ready(function(){
> if (typeof Wicket != 'undefined' && Wicket.Window)
> Wicket.Window.unloadConfirmation = false;
> });
> </script>
>
>
> Matthias Keller wrote:
>>
>> Hi Peter
>>
>> You would be right as long as it wasn't for a ModalWindow.
>> When having an open ModalWindow, wicket seems to register an unload
>> javascript event which - when trying to navigate away from the page  
>> (be
>> it by following a link, closing the window etc), displays a  
>> confirmation
>> message which you have to accept. I need to avoid that message, but  
>> the
>> only way to do that probably is by closing that window first so  
>> that the
>> javascript event gets unloaded.
>>
>> Matt
>>
>> Peter Ertl wrote:
>>>
>>>
>>>    throw new RestartResponseException(OtherPage.class)
>>>
>>> window.close() is not needed!
>>>
>>>
>>> Am 10.09.2009 um 12:50 schrieb Matthias Keller:
>>>
>>>> OtherPage.class
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/How-to-redirect-from-a-ModalWindow-tp25381117p25411990.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

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

Re: How to redirect from a ModalWindow

Ryan McKinley
In reply to this post by vladimir.kovalyuk
even better is to add this call to the request that opens the window:

onClick( AjaxRequestTarget target )
{
   target.appendJavascript( "Wicket.Window.unloadConfirmation =  
false;" );
   ...
   modal.show( target);
}

This way the logic is still contained in java and it works for a panel  
or a page popup.



On Sep 12, 2009, at 2:36 AM, Vladimir K wrote:

>
> Try adding this one to the page markup
>
> <script language="javascript" type="text/javascript">
> jQuery(document).ready(function(){
> if (typeof Wicket != 'undefined' && Wicket.Window)
> Wicket.Window.unloadConfirmation = false;
> });
> </script>
>
>
> Matthias Keller wrote:
>>
>> Hi Peter
>>
>> You would be right as long as it wasn't for a ModalWindow.
>> When having an open ModalWindow, wicket seems to register an unload
>> javascript event which - when trying to navigate away from the page  
>> (be
>> it by following a link, closing the window etc), displays a  
>> confirmation
>> message which you have to accept. I need to avoid that message, but  
>> the
>> only way to do that probably is by closing that window first so  
>> that the
>> javascript event gets unloaded.
>>
>> Matt
>>
>> Peter Ertl wrote:
>>>
>>>
>>>    throw new RestartResponseException(OtherPage.class)
>>>
>>> window.close() is not needed!
>>>
>>>
>>> Am 10.09.2009 um 12:50 schrieb Matthias Keller:
>>>
>>>> OtherPage.class
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/How-to-redirect-from-a-ModalWindow-tp25381117p25411990.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...