Source Code Cross Referenced for Include.java in  » Ajax » zk » org » zkoss » zul » 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 » zk » org.zkoss.zul 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Include.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Wed Sep 28 18:01:03     2005, Created by tomyeh
010:        }}IS_NOTE
011:
012:        Copyright (C) 2005 Potix Corporation. All Rights Reserved.
013:
014:        {{IS_RIGHT
015:        	This program is distributed under GPL Version 2.0 in the hope that
016:        	it will be useful, but WITHOUT ANY WARRANTY.
017:        }}IS_RIGHT
018:         */
019:        package org.zkoss.zul;
020:
021:        import java.util.HashMap;
022:        import java.io.Writer;
023:        import java.io.IOException;
024:
025:        import org.zkoss.lang.Objects;
026:        import org.zkoss.lang.Exceptions;
027:        import org.zkoss.mesg.Messages;
028:        import org.zkoss.util.logging.Log;
029:
030:        import org.zkoss.web.Attributes;
031:
032:        import org.zkoss.zk.mesg.MZk;
033:        import org.zkoss.zk.ui.Desktop;
034:        import org.zkoss.zk.ui.Execution;
035:        import org.zkoss.zk.ui.UiException;
036:        import org.zkoss.zk.ui.WrongValueException;
037:        import org.zkoss.zk.ui.sys.UiEngine;
038:        import org.zkoss.zk.ui.sys.WebAppCtrl;
039:
040:        import org.zkoss.zul.impl.XulElement;
041:
042:        /**
043:         * Includes the result generated by any servlet.
044:         *
045:         * <p>Non-XUL extension.
046:         *
047:         * <p>If the servlet is eventually another ZUL page, the page will be
048:         * added to the current desktop when this element is added to
049:         * the current desktop.
050:         *
051:         * @author tomyeh
052:         */
053:        public class Include extends XulElement {
054:            private static final Log log = Log.lookup(Include.class);
055:
056:            protected String _src;
057:            private boolean _localized;
058:
059:            public Include() {
060:            }
061:
062:            public Include(String src) {
063:                setSrc(src);
064:            }
065:
066:            /** Returns the src.
067:             * <p>Default: null.
068:             */
069:            public String getSrc() {
070:                return _src;
071:            }
072:
073:            /** Sets the src.
074:             * <p>If src is changed, the whole component is invalidate.
075:             * Thus, you want to smart-update, you have to override this method.
076:             *
077:             * @param src the source URL. If null or empty, nothing is included.
078:             */
079:            public void setSrc(String src) throws WrongValueException {
080:                if (src != null && src.length() == 0)
081:                    src = null;
082:
083:                if (!Objects.equals(_src, src)) {
084:                    _src = src;
085:                    invalidate();
086:                }
087:            }
088:
089:            /** Returns whether the source depends on the current Locale.
090:             * If true, it will search xxx_en_US.yyy, xxx_en.yyy and xxx.yyy
091:             * for the proper content, where src is assumed to be xxx.yyy.
092:             *
093:             * <p>Default: false;
094:             */
095:            public final boolean isLocalized() {
096:                return _localized;
097:            }
098:
099:            /** Sets whether the source depends on the current Locale.
100:             */
101:            public final void setLocalized(boolean localized) {
102:                if (_localized != localized) {
103:                    _localized = localized;
104:                    invalidate();
105:                }
106:            }
107:
108:            //-- Component --//
109:            /** Default: not childable.
110:             */
111:            public boolean isChildable() {
112:                return false;
113:            }
114:
115:            public void redraw(Writer out) throws IOException {
116:                final UiEngine ueng = ((WebAppCtrl) getDesktop().getWebApp())
117:                        .getUiEngine();
118:                ueng.pushOwner(this );
119:                try {
120:                    out.write("<div id=\"");
121:                    out.write(getUuid());
122:                    out.write('"');
123:                    out.write(getOuterAttrs());
124:                    out.write(getInnerAttrs());
125:                    out.write(">\n");
126:
127:                    if (_src != null && _src.length() > 0)
128:                        include(out);
129:
130:                    out.write("\n</div>");
131:                } finally {
132:                    ueng.popOwner();
133:                }
134:            }
135:
136:            private void include(Writer out) throws IOException {
137:                final Desktop desktop = getDesktop();
138:                final Execution exec = desktop.getExecution();
139:                final String src = exec.toAbsoluteURI(_src, false);
140:                try {
141:                    exec.include(out, src, null, 0);
142:                } catch (Throwable err) {
143:                    //though DHtmlLayoutServlet handles exception, we still have to
144:                    //handle it because src might not be ZUML
145:                    final String errpg = desktop.getWebApp().getConfiguration()
146:                            .getErrorPage(desktop.getDeviceType(), err);
147:                    if (errpg != null) {
148:                        try {
149:                            exec.setAttribute("javax.servlet.error.message",
150:                                    Exceptions.getMessage(err));
151:                            exec.setAttribute("javax.servlet.error.exception",
152:                                    err);
153:                            exec.setAttribute(
154:                                    "javax.servlet.error.exception_type", err
155:                                            .getClass());
156:                            exec.setAttribute(
157:                                    "javax.servlet.error.status_code",
158:                                    new Integer(500));
159:                            exec.include(out, errpg, null, 0);
160:                            return; //done
161:                        } catch (IOException ex) { //eat it (connection off)
162:                        } catch (Throwable ex) {
163:                            log.warning("Failed to load the error page: "
164:                                    + errpg, ex);
165:                        }
166:                    }
167:
168:                    final String msg = Messages.get(MZk.PAGE_FAILED,
169:                            new Object[] {
170:                                    src,
171:                                    Exceptions.getMessage(err),
172:                                    Exceptions.formatStackTrace(null, err,
173:                                            null, 6) });
174:                    final HashMap attrs = new HashMap();
175:                    attrs.put(Attributes.ALERT_TYPE, "error");
176:                    attrs.put(Attributes.ALERT, msg);
177:                    exec.include(out, "~./html/alert.dsp", attrs,
178:                            Execution.PASS_THRU_ATTR);
179:                }
180:            }
181:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.