You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Doug Leeper <do...@yahoo.com> on 2007/11/01 15:54:45 UTC

ModalWindow question

I would like to use a ModalWindow to prompt for a choice of action for the
user.

Upon selecting the choice, I would like to close the ModalWindow then
redirect the user to a page based on the selected choice.

I know you can use setResponsePage in the Link on the ModalWindow page...so
how would one go about doing this?

Thanks in advance,
- Doug
-- 
View this message in context: http://www.nabble.com/ModalWindow-question-tf4731828.html#a13530210
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AW: ModalWindow question

Posted by Doug Leeper <do...@yahoo.com>.
Thanks Stefan.

I figured that this is what I was left with...had to wait to the
onWindowCloseCallback to handle the user action properly.  

I was hoping for a more elegant (already built) means to be able to "pass
back" to the calling ModalWindow to identify what "action" was performed. 
But since I was not able to find anything, I did the following:

1) Created a ModalWindowCallbackState

public class ModalWindowCallbackState implements Serializable {
	public Object value;
}

2) Passed that into my displayed component in the ModalWindow

final ModalWindowCallbackState callbackState = new
ModalWindowCallbackState();

...

successWindow.setPageCreator(new ModalWindow.PageCreator() {
	public Page createPage() {
		return new SuccessConfirmation(successWindow, callbackState);
	}
});


3)  Check the callback state in the onWindowClosedCallback

successWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback()
{
	public void onClose(AjaxRequestTarget target) {
		if ( callbackState.value == null || callbackState.value.equals( /* Cancel
*/ ) {
			setResponsePage( /* CancelPage */ );
		}
		else if ( callbackState.value.equals( /* ACTION FOO */)) {
			setResponsePage(  /* FooPage */ );
		}
		...
        } );
-- 
View this message in context: http://www.nabble.com/ModalWindow-question-tf4731828.html#a13532596
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


AW: ModalWindow question

Posted by Stefan Lindner <li...@visionet.de>.
You can try something like

			private boolean closedByCloseButton = false;
			ModalWindow modalWindow = ....

			modalWindow.setCloseButtonCallback(new ModalWindow.CloseButtonCallback(){
				private static final long serialVersionUID = 1L;
				public boolean onCloseButtonClicked(@SuppressWarnings("unused") AjaxRequestTarget target) {
					closedByCloseButton = true;
					return true;
				}
			});

			modalWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
				private static final long serialVersionUID = 1L;
				public void onClose(AjaxRequestTarget target) {
					if (!closedByCloseButton) {
						setResponsePage....
					}
				}
			}
			);

I hope that leads you to the solution for your problem

Stefan Lindner

-----Ursprüngliche Nachricht-----
Von: Doug Leeper [mailto:dougleeper@yahoo.com] 
Gesendet: Donnerstag, 1. November 2007 15:55
An: users@wicket.apache.org
Betreff: ModalWindow question


I would like to use a ModalWindow to prompt for a choice of action for the user.

Upon selecting the choice, I would like to close the ModalWindow then redirect the user to a page based on the selected choice.

I know you can use setResponsePage in the Link on the ModalWindow page...so how would one go about doing this?

Thanks in advance,
- Doug
--
View this message in context: http://www.nabble.com/ModalWindow-question-tf4731828.html#a13530210
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org