KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > aspects > gui > web > Page


1 /*
2   Copyright (C) 2002-2003 Laurent Martelli <laurent@aopsys.com>
3   
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2 of the
7   License, or (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12   GNU Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public License
15   along with this program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */

17
18 package org.objectweb.jac.aspects.gui.web;
19
20 import java.io.IOException JavaDoc;
21 import java.io.PrintWriter JavaDoc;
22 import javax.servlet.http.HttpServletResponse JavaDoc;
23 import org.apache.log4j.Logger;
24 import org.objectweb.jac.aspects.gui.*;
25
26 /**
27  * An HTML page containing a View and a close button.
28  */

29 public class Page extends AbstractPage implements WindowListener
30 {
31     static Logger loggerWeb = Logger.getLogger("gui.events");
32
33     public Page(View view, boolean newWindow) {
34         super(view,newWindow);
35     }
36
37     // HTMLViewer interface
38

39     public void genBody(PrintWriter JavaDoc out) throws IOException JavaDoc {
40         out.println("<div class=\""+type+"\">");
41         if (description!=null)
42             out.println("<div class=\"description\">"+description+"</div>");
43         openForm(out);
44         ((HTMLViewer)view).genHTML(out);
45         showFormButtons(out,false);
46         closeForm(out);
47         out.println("</div>");
48     }
49
50     // WindowListener interface
51

52     HttpServletResponse JavaDoc response;
53     JacRequest jacRequest;
54
55     public void onOK(JacRequest request) {
56         logger.debug(this+".onOK");
57         WebDisplay display = (WebDisplay)context.getDisplay();
58         try {
59             response = WebDisplay.getResponse();
60             jacRequest = WebDisplay.getRequest();
61             display.closeWindow(this,true);
62         } finally {
63             display.refresh();
64         }
65     }
66
67     public void onRefresh(JacRequest request) {
68         logger.debug(this+".onRefresh");
69         WebDisplay display = (WebDisplay)context.getDisplay();
70         response = WebDisplay.getResponse();
71         jacRequest = WebDisplay.getRequest();
72         WebDisplay.readValuesAndRefresh(context,request,true);
73     }
74
75     public void onCancel() {
76         // Each view inside the page is supposed to be validated with
77
// its own OK/Cancel buttons. Since the close link is not a
78
// button in a form, editors must not try to readValue()
79
// because there will never be any data to be read.
80
CustomizedDisplay display = (WebDisplay)context.getDisplay();
81         display.closeWindow(this,false);
82         display.refresh();
83     }
84
85     public void onValidate(JacRequest request) {
86         WebDisplay.readValues(context,request,true);
87     }
88 }
89
Popular Tags