01: /**
02: *
03: */package wicket.examples.ajax.builtin.modal;
04:
05: import wicket.Page;
06: import wicket.ajax.AjaxRequestTarget;
07: import wicket.ajax.markup.html.AjaxLink;
08: import wicket.extensions.ajax.markup.html.modal.ModalWindow;
09: import wicket.markup.html.WebPage;
10:
11: /**
12: * @author Matej Knopp
13: *
14: */
15: public class ModalContent1Page extends WebPage {
16:
17: /**
18: *
19: */
20: public ModalContent1Page() {
21: this (null);
22: }
23:
24: /**
25: *
26: * @param modalWindowPage
27: */
28: public ModalContent1Page(final ModalWindowPage modalWindowPage) {
29: add(new AjaxLink("closeOK") {
30: public void onClick(AjaxRequestTarget target) {
31: if (modalWindowPage != null)
32: modalWindowPage
33: .setResult("Modal window 1 - close link OK");
34: ModalWindow.close(target);
35: }
36: });
37:
38: add(new AjaxLink("closeCancel") {
39: public void onClick(AjaxRequestTarget target) {
40: if (modalWindowPage != null)
41: modalWindowPage
42: .setResult("Modal window 1 - close link Cancel");
43: ModalWindow.close(target);
44: }
45: });
46:
47: final ModalWindow modal;
48: add(modal = new ModalWindow("modal"));
49: modal.setPageMapName("modal-2");
50:
51: modal.setCookieName("modal window 2");
52:
53: modal.setResizable(false);
54: modal.setInitialWidth(30);
55: modal.setInitialHeight(15);
56: modal.setWidthUnit("em");
57: modal.setHeightUnit("em");
58:
59: modal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
60:
61: modal.setPageCreator(new ModalWindow.PageCreator() {
62: public Page createPage() {
63: return new ModalContent2Page();
64: }
65: });
66:
67: modal
68: .setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {
69: public boolean onCloseButtonClicked(
70: AjaxRequestTarget target) {
71: target
72: .appendJavascript("alert('You can\\'t close this modal window using close button."
73: + " Use the link inside the window instead.');");
74: return false;
75: }
76: });
77:
78: add(new AjaxLink("open") {
79: public void onClick(AjaxRequestTarget target) {
80: modal.show(target);
81: }
82: });
83:
84: }
85: }
|