001: /**
002: * Copyright 2006 Webmedia Group Ltd.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: **/package org.araneaframework.example.main.web.sample;
016:
017: import org.araneaframework.InputData;
018: import org.araneaframework.Message;
019: import org.araneaframework.OutputData;
020: import org.araneaframework.example.main.TemplateBaseWidget;
021: import org.araneaframework.example.main.message.LoginAndMenuSelectMessage;
022: import org.araneaframework.example.main.message.PopupMessageFactory;
023: import org.araneaframework.framework.FlowContext;
024: import org.araneaframework.framework.MountContext;
025: import org.araneaframework.http.support.PopupWindowProperties;
026: import org.araneaframework.uilib.core.PopupFlowWidget;
027:
028: /**
029: * @author Taimo Peelo (taimo@araneaframework.org)
030: */
031: public class SamplePopupWidget extends TemplateBaseWidget {
032: private static final long serialVersionUID = 1L;
033: String title;
034: int count = 1;
035:
036: public SamplePopupWidget() {
037: }
038:
039: protected SamplePopupWidget(int count) {
040: this .count = count;
041: }
042:
043: protected void init() throws Exception {
044: putViewData("title", "#" + Integer.toString(count)
045: + ". Popup Example");
046: setViewSelector("sample/samplePopup");
047: }
048:
049: public void handleEventCreateThread() throws Exception {
050: getMessageCtx()
051: .showInfoMessage(
052: "Popup window should have opened. If it did not, please relax your popup blocker settings.");
053: getPopupCtx().open(
054: new LoginAndMenuSelectMessage(
055: "Demos.Simple.Simple_Form"),
056: new PopupWindowProperties(), this );
057: }
058:
059: public void handleEventOpenUrl() throws Exception {
060: getMessageCtx()
061: .showInfoMessage(
062: "Popup window should have opened. If it did not, please relax your popup blocker settings.");
063: getPopupCtx().open("http://www.slashdot.org",
064: new PopupWindowProperties());
065: }
066:
067: public void handleEventOpenMountedPopup() throws Exception {
068: String url = getMountCtx().mount(getInputData(),
069: "my/very/own/mounted/path",
070: new MountContext.MessageFactory() {
071: public Message buildMessage(String url,
072: String suffix, InputData input,
073: OutputData output) {
074: return new LoginAndMenuSelectMessage(
075: "Demos.Simple.Simple_Form");
076: }
077: });
078:
079: getPopupCtx().openMounted(url, new PopupWindowProperties());
080: }
081:
082: public void handleEventOpenNewCustomFlow() throws Exception {
083: getMessageCtx()
084: .showInfoMessage(
085: "Popup window should have opened. If it did not, please relax your popup blocker settings.");
086:
087: PopupWindowProperties p = new PopupWindowProperties();
088: p.setHeight("600");
089: p.setWidth("1000");
090: p.setScrollbars("yes");
091: PopupFlowWidget pfw = new PopupFlowWidget(new NameWidget(), p,
092: new PopupMessageFactory());
093: getFlowCtx().start(pfw, new SampleHandler());
094: }
095:
096: public void handleEventOpenImmediatelyReturningCustomFlow()
097: throws Exception {
098: PopupWindowProperties p = new PopupWindowProperties();
099: p.setHeight("600");
100: p.setWidth("1000");
101: p.setScrollbars("yes");
102: PopupFlowWidget pfw = new PopupFlowWidget(new NameWidget(true),
103: p, new PopupMessageFactory());
104: getFlowCtx().start(pfw, null, new SampleHandler());
105: }
106:
107: public void handleEventEndFlow() {
108: getFlowCtx().finish("Funky end for SamplePopupWidget!");
109: }
110:
111: class SampleHandler implements FlowContext.Handler {
112: private static final long serialVersionUID = 1L;
113:
114: public void onCancel() throws Exception {
115: }
116:
117: public void onFinish(Object returnValue) throws Exception {
118: InvisibleElementFormWidget widget = new InvisibleElementFormWidget(
119: (String) returnValue);
120: getFlowCtx().replace(widget, null);
121: }
122: }
123: }
|