Source Code Cross Referenced for CoolDelayMessage.java in  » Ajax » NextApp-Echo2 » nextapp » echo2 » testapp » interactive » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Ajax » NextApp Echo2 » nextapp.echo2.testapp.interactive 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * This file is part of the Echo Web Application Framework (hereinafter "Echo").
003:         * Copyright (C) 2002-2005 NextApp, Inc.
004:         *
005:         * Version: MPL 1.1/GPL 2.0/LGPL 2.1
006:         *
007:         * The contents of this file are subject to the Mozilla Public License Version
008:         * 1.1 (the "License"); you may not use this file except in compliance with
009:         * the License. You may obtain a copy of the License at
010:         * http://www.mozilla.org/MPL/
011:         *
012:         * Software distributed under the License is distributed on an "AS IS" basis,
013:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
014:         * for the specific language governing rights and limitations under the
015:         * License.
016:         *
017:         * Alternatively, the contents of this file may be used under the terms of
018:         * either the GNU General Public License Version 2 or later (the "GPL"), or
019:         * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
020:         * in which case the provisions of the GPL or the LGPL are applicable instead
021:         * of those above. If you wish to allow use of your version of this file only
022:         * under the terms of either the GPL or the LGPL, and not to allow others to
023:         * use your version of this file under the terms of the MPL, indicate your
024:         * decision by deleting the provisions above and replace them with the notice
025:         * and other provisions required by the GPL or the LGPL. If you do not delete
026:         * the provisions above, a recipient may use your version of this file under
027:         * the terms of any one of the MPL, the GPL or the LGPL.
028:         */
029:
030:        package nextapp.echo2.testapp.interactive;
031:
032:        import java.io.IOException;
033:        import java.io.InputStream;
034:        import java.io.OutputStream;
035:
036:        import org.w3c.dom.Document;
037:        import org.w3c.dom.Element;
038:
039:        import nextapp.echo2.app.util.Uid;
040:        import nextapp.echo2.webcontainer.ContainerContext;
041:        import nextapp.echo2.webrender.ClientProperties;
042:        import nextapp.echo2.webrender.Connection;
043:        import nextapp.echo2.webrender.ContentType;
044:        import nextapp.echo2.webrender.ServerDelayMessage;
045:        import nextapp.echo2.webrender.Service;
046:        import nextapp.echo2.webrender.WebRenderServlet;
047:        import nextapp.echo2.webrender.output.HtmlDocument;
048:        import nextapp.echo2.webrender.output.XmlDocument;
049:
050:        /**
051:         * An example of a more creative <code>ServerDelayMessage</code>.
052:         * <p>
053:         * Creating a custom <code>ServerDelayMessage</code>
054:         * is a fairly advanced activity that requires working with the Echo
055:         * Web Render Engine API.
056:         */
057:        public class CoolDelayMessage extends ServerDelayMessage {
058:
059:            private static int BUFFER_SIZE = 4096;
060:            private static String IMAGE_RESOURCE_NAME = Styles.IMAGE_PATH
061:                    + "ShadowOverlay.png";
062:
063:            private static Service IMAGE_SERVICE = new ImageService();
064:            static {
065:                WebRenderServlet.getServiceRegistry().add(IMAGE_SERVICE);
066:            }
067:
068:            private static class ImageService implements  Service {
069:
070:                private static final String SERVICE_ID = Uid
071:                        .generateUidString();
072:
073:                /**
074:                 * @see nextapp.echo2.webrender.Service#getId()
075:                 */
076:                public String getId() {
077:                    return SERVICE_ID;
078:                }
079:
080:                /**
081:                 * @see nextapp.echo2.webrender.Service#getVersion()
082:                 */
083:                public int getVersion() {
084:                    return 0;
085:                }
086:
087:                /**
088:                 * @see nextapp.echo2.webrender.Service#service(nextapp.echo2.webrender.Connection)
089:                 */
090:                public void service(Connection conn) throws IOException {
091:                    conn.setContentType(ContentType.IMAGE_PNG);
092:                    OutputStream out = conn.getOutputStream();
093:
094:                    InputStream in = null;
095:                    byte[] buffer = new byte[BUFFER_SIZE];
096:                    int bytesRead = 0;
097:
098:                    try {
099:                        in = CoolDelayMessage.class
100:                                .getResourceAsStream(IMAGE_RESOURCE_NAME);
101:                        if (in == null) {
102:                            throw new IllegalArgumentException(
103:                                    "Specified resource does not exist: "
104:                                            + IMAGE_RESOURCE_NAME + ".");
105:                        }
106:                        do {
107:                            bytesRead = in.read(buffer);
108:                            if (bytesRead > 0) {
109:                                out.write(buffer, 0, bytesRead);
110:                            }
111:                        } while (bytesRead > 0);
112:                    } finally {
113:                        if (in != null) {
114:                            try {
115:                                in.close();
116:                            } catch (IOException ex) {
117:                            }
118:                        }
119:                    }
120:                }
121:            }
122:
123:            private Element messageElement;
124:
125:            public CoolDelayMessage(ContainerContext containerContext,
126:                    String messageText) {
127:                XmlDocument xmlDocument = new XmlDocument("div", null, null,
128:                        HtmlDocument.XHTML_1_0_NAMESPACE_URI);
129:                Document document = xmlDocument.getDocument();
130:                Element divElement = document.getDocumentElement();
131:                divElement.setAttribute("id", ELEMENT_ID_MESSAGE);
132:                divElement
133:                        .setAttribute(
134:                                "style",
135:                                "position:absolute;top:0px;left:0px;width:100%;height:100%;cursor:wait;"
136:                                        + "margin:0px;padding:0px;visibility:hidden;z-index:10000;");
137:
138:                Element tableElement = document.createElement("table");
139:                tableElement.setAttribute("style",
140:                        "width:100%;height:100%;border:0px;padding:0px;");
141:                divElement.appendChild(tableElement);
142:
143:                Element tbodyElement = document.createElement("tbody");
144:                tableElement.appendChild(tbodyElement);
145:
146:                Element trElement = document.createElement("tr");
147:                tbodyElement.appendChild(trElement);
148:
149:                Element tdElement = document.createElement("td");
150:                tdElement.setAttribute("style", "width:100%;height:100%;");
151:                tdElement.setAttribute("valign", "middle");
152:                tdElement.setAttribute("align", "center");
153:                trElement.appendChild(tdElement);
154:
155:                Element longDivElement = document.createElement("div");
156:                longDivElement.setAttribute("id", ELEMENT_ID_LONG_MESSAGE);
157:                String longDivStyleText = "color:#4f4f4f;width:277px;padding-top:120px;height:156px;"
158:                        + "font-family:verdana,arial,helvetica,sans-serif;font-size:14pt;font-weight:bold;font-style:italic;"
159:                        + "text-align:center;";
160:                if (containerContext
161:                        .getClientProperties()
162:                        .getBoolean(
163:                                ClientProperties.PROPRIETARY_IE_PNG_ALPHA_FILTER_REQUIRED)) {
164:                    // Use Internet Explorer PNG filter hack to achieve transparency.
165:                    longDivStyleText += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"
166:                            + containerContext.getServiceUri(IMAGE_SERVICE)
167:                            + "', sizingMethod='scale')";
168:                } else {
169:                    longDivStyleText += "background-image:url("
170:                            + containerContext.getServiceUri(IMAGE_SERVICE)
171:                            + ");";
172:                }
173:                longDivElement.setAttribute("style", longDivStyleText);
174:
175:                longDivElement
176:                        .appendChild(document.createTextNode(messageText));
177:                tdElement.appendChild(longDivElement);
178:
179:                messageElement = divElement;
180:            }
181:
182:            /**
183:             * @see nextapp.echo2.webrender.ServerDelayMessage#getMessage()
184:             */
185:            public Element getMessage() {
186:                return messageElement;
187:            }
188:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.