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


001:        /* BaseZScript.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Aug 8, 2007 5:48:27 PM     2007, Created by Dennis.Chen
010:        }}IS_NOTE
011:
012:        Copyright (C) 2007 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.jsf.zul.impl;
020:
021:        import java.io.IOException;
022:        import java.io.StringWriter;
023:        import javax.faces.context.FacesContext;
024:        import javax.faces.context.ResponseWriter;
025:
026:        import org.zkoss.util.logging.Log;
027:        import org.zkoss.zk.ui.Component;
028:        import org.zkoss.zk.ui.metainfo.ZScript;
029:
030:        /**
031:         * The Base implementation of ZScript. 
032:         * This component should be declared nested under {@link org.zkoss.jsf.zul.Page}.
033:         * @author Dennis.Chen
034:         */
035:        public class BaseZScript extends AbstractComponent {
036:
037:            private boolean _deferred;
038:            private String _lang = null;
039:
040:            private RootComponent _rootcomp;
041:            private BranchComponent _parentcomp;
042:
043:            StringWriter fakeSw = null;
044:
045:            ResponseWriter fakeOw = null;
046:
047:            public void loadZULTree(org.zkoss.zk.ui.Page page,
048:                    StringWriter writer) throws IOException {
049:                if (!isRendered() || !isEffective())
050:                    return; //nothing to do
051:
052:                String content = getBodyContent();
053:                setBodyContent(null);//clear it,
054:                if (content == null)
055:                    return;
056:                final ZScript zscript = ZScript.parseContent(content);
057:
058:                if (zscript.getLanguage() == null)
059:                    zscript.setLanguage(_lang != null ? _lang : _rootcomp
060:                            .getZScriptLanguage());
061:
062:                Component _parentzulcomp = null;
063:                if (_parentcomp != null) {
064:                    _parentzulcomp = _parentcomp.getZULComponent();
065:                }
066:
067:                _rootcomp.processZScript(_parentzulcomp, zscript);
068:            }
069:
070:            /** 
071:             * Override method,
072:             * We Construct ZUL JSF Component tree here.
073:             * This method is called by JSF implementation, deriving class rarely need to invoke this method.
074:             */
075:            public void encodeBegin(FacesContext context) throws IOException {
076:                fakeSw = new StringWriter();
077:
078:                fakeOw = context.getResponseWriter();
079:
080:                context.setResponseWriter(fakeOw.cloneWithWriter(fakeSw));
081:
082:                if (!isRendered() || !isEffective())
083:                    return; //nothing to do
084:                super .encodeBegin(context);
085:                final AbstractComponent ac = (AbstractComponent) findAncestorWithClass(
086:                        this , AbstractComponent.class);
087:                if (ac instanceof  RootComponent) { //root component tag
088:                    _rootcomp = (RootComponent) ac;
089:                } else if (ac instanceof  BranchComponent) {
090:                    _parentcomp = (BranchComponent) ac;
091:                    _rootcomp = _parentcomp.getRootComponent();
092:                } else {
093:                    throw new IllegalStateException(
094:                            "Must be nested inside the page component: " + this );
095:                }
096:
097:                //keep component tree structure for zul jsf component
098:                ComponentInfo cinfo = getComponentInfo();
099:                if (cinfo != null) {
100:                    if (_parentcomp != null) {
101:                        cinfo.addChildInfo(_parentcomp, this );
102:                    } else if (_rootcomp != null) {
103:                        cinfo.addChildInfo(_rootcomp, this );
104:                    }
105:                }
106:            }
107:
108:            /**
109:             * Override Method
110:             */
111:            public void encodeEnd(FacesContext context) throws IOException {
112:                context.setResponseWriter(fakeOw);
113:                fakeSw.close();
114:
115:                fakeSw = null;
116:                super .encodeEnd(context);
117:            }
118:
119:            /**
120:             * return ComponentInfo of RootComponent
121:             */
122:            protected ComponentInfo getComponentInfo() {
123:                if (_rootcomp != null) {
124:                    return _rootcomp.getComponentInfo();
125:                }
126:                return null;
127:            }
128:
129:            /**
130:             * Returns whether to defer the execution of this zscript.
131:             * <p>Default: false.
132:             */
133:            public boolean isDeferred() {
134:                return _deferred;
135:            }
136:
137:            /**
138:             * Sets whether to defer the execution of this zscript.
139:             * @param deferred whether to defer the execution.
140:             */
141:            public void setDeferred(boolean deferred) {
142:                this ._deferred = deferred;
143:            }
144:
145:            /** Returns the name of the scripting language in this ZScript tag.
146:             *
147:             * <p>Default: null (use what is defined in {@link org.zkoss.jsf.zul.tag.PageTag}).
148:             * @return the name of the scripting language in this ZScript tag. 
149:             */
150:            public String getLanguage() {
151:                return _lang;
152:            }
153:
154:            /**
155:             * Sets the name of the scripting language in this ZScript tag.
156:             *
157:             * <p>Default: Java.
158:             *
159:             * @param lang the name of the scripting language, such as
160:             * Java, Ruby and Groovy.
161:             */
162:            public void setLanguage(String lang) {
163:                this ._lang = lang;
164:            }
165:
166:            public Object saveState(FacesContext context) {
167:                Object values[] = new Object[3];
168:                values[0] = super .saveState(context);
169:                values[1] = _lang;
170:                values[2] = _deferred ? Boolean.TRUE : Boolean.FALSE;
171:                return (values);
172:            }
173:
174:            public void restoreState(FacesContext context, Object state) {
175:
176:                Object values[] = (Object[]) state;
177:                super .restoreState(context, values[0]);
178:                _lang = ((String) values[1]);
179:                _deferred = ((Boolean) values[2]).booleanValue();
180:            }
181:
182:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.