001: /**
002: *
003: */package wicket.examples.ajax.builtin.modal;
004:
005: import wicket.Page;
006: import wicket.ajax.AjaxRequestTarget;
007: import wicket.ajax.markup.html.AjaxLink;
008: import wicket.examples.ajax.builtin.BasePage;
009: import wicket.extensions.ajax.markup.html.modal.ModalWindow;
010: import wicket.markup.html.basic.Label;
011: import wicket.model.PropertyModel;
012:
013: /**
014: * @author Matej Knopp
015: */
016: public class ModalWindowPage extends BasePage {
017:
018: /**
019: */
020: public ModalWindowPage() {
021: final Label result;
022: add(result = new Label("result", new PropertyModel(this ,
023: "result")));
024: result.setOutputMarkupId(true);
025:
026: /*
027: * First modal window
028: */
029:
030: final ModalWindow modal1;
031: add(modal1 = new ModalWindow("modal1"));
032:
033: modal1.setPageMapName("modal-1");
034: modal1.setCookieName("modal-1");
035:
036: modal1.setPageCreator(new ModalWindow.PageCreator() {
037: public Page createPage() {
038: return new ModalContent1Page(ModalWindowPage.this );
039: }
040: });
041: modal1
042: .setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
043: public void onClose(AjaxRequestTarget target) {
044: target.addComponent(result);
045: }
046: });
047: modal1
048: .setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {
049: public boolean onCloseButtonClicked(
050: AjaxRequestTarget target) {
051: setResult("Modal window 1 - close button");
052: return true;
053: }
054: });
055:
056: add(new AjaxLink("showModal1") {
057: public void onClick(AjaxRequestTarget target) {
058: modal1.show(target);
059: }
060: });
061:
062: /*
063: * Second modal window
064: */
065:
066: final ModalWindow modal2;
067: add(modal2 = new ModalWindow("modal2"));
068:
069: modal2.setContent(new ModalPanel1(modal2.getContentId()));
070: modal2.setTitle("This is modal window with panel content.");
071: modal2.setCookieName("modal-2");
072:
073: modal2
074: .setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {
075: public boolean onCloseButtonClicked(
076: AjaxRequestTarget target) {
077: setResult("Modal window 2 - close button");
078: return true;
079: }
080: });
081:
082: modal2
083: .setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
084: public void onClose(AjaxRequestTarget target) {
085: target.addComponent(result);
086: }
087: });
088:
089: add(new AjaxLink("showModal2") {
090: public void onClick(AjaxRequestTarget target) {
091: modal2.show(target);
092: }
093: });
094: }
095:
096: /**
097: * @return the result
098: */
099: public String getResult() {
100: return result;
101: }
102:
103: /**
104: * @param result
105: * the result to set
106: */
107: public void setResult(String result) {
108: this .result = result;
109: }
110:
111: private String result;
112:
113: }
|