Source Code Cross Referenced for BaseComponentDefinition.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:        /* BaseComponentDefinition.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		2007/11/21 , 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.util.Iterator;
023:        import java.util.LinkedHashMap;
024:        import java.util.Map;
025:
026:        import javax.faces.context.FacesContext;
027:
028:        import org.zkoss.zk.ui.Page;
029:        import org.zkoss.zk.ui.UiException;
030:        import org.zkoss.zk.ui.metainfo.ComponentDefinition;
031:        import org.zkoss.zk.ui.metainfo.impl.ComponentDefinitionImpl;
032:
033:        /**
034:         * A Implement of component definition tag<br/>
035:         * @author Dennis.Chen
036:         *
037:         */
038:        public class BaseComponentDefinition extends AbstractComponent {
039:
040:            private String _macroURI;
041:
042:            private String _extends;
043:
044:            private String _useClass;
045:
046:            private String _name;
047:
048:            private boolean _inline;
049:
050:            private String _moldName;
051:
052:            private String _moldURI;
053:
054:            private Map _compAttrMap;
055:
056:            public String getMacroURI() {
057:                return _macroURI;
058:            }
059:
060:            public void setMacroURI(String macroURI) {
061:                this ._macroURI = macroURI;
062:            }
063:
064:            public String getExtends() {
065:                return _extends;
066:            }
067:
068:            public void setExtends(String _extends) {
069:                this ._extends = _extends;
070:            }
071:
072:            public String getUseClass() {
073:                return _useClass;
074:            }
075:
076:            public void setUseClass(String useClass) {
077:                this ._useClass = useClass;
078:            }
079:
080:            public String getName() {
081:                return _name;
082:            }
083:
084:            public void setName(String name) {
085:                this ._name = name;
086:            }
087:
088:            public boolean isInline() {
089:                return _inline;
090:            }
091:
092:            public void setInline(boolean inline) {
093:                this ._inline = inline;
094:            }
095:
096:            public String getMoldName() {
097:                return _moldName;
098:            }
099:
100:            public void setMoldName(String moldName) {
101:                this ._moldName = moldName;
102:            }
103:
104:            public String getMoldURI() {
105:                return _moldURI;
106:            }
107:
108:            public void setMoldURI(String moldURI) {
109:                this ._moldURI = moldURI;
110:            }
111:
112:            /**
113:             * Set dynamic attribute
114:             * @param map the dynamic attributes.
115:             */
116:            public void setDynamicAttribute(Map map) {
117:                _compAttrMap = map;
118:            }
119:
120:            // ----------------------------------------------------- StateHolder Methods
121:
122:            /**
123:             * Override Method, save the state of this component.
124:             */
125:            public Object saveState(FacesContext context) {
126:                Object values[] = new Object[10];
127:                values[0] = super .saveState(context);
128:                Object m[] = saveAttachedMapState(context, _compAttrMap);
129:                values[1] = m[0];
130:                values[2] = m[1];
131:                values[3] = _macroURI;
132:                values[4] = _extends;
133:                values[5] = _useClass;
134:                values[6] = _name;
135:                values[7] = _inline ? Boolean.TRUE : Boolean.FALSE;
136:                values[8] = _moldName;
137:                values[9] = _moldURI;
138:                return (values);
139:
140:            }
141:
142:            /**
143:             * Override Method, restore the state of this component.
144:             */
145:            public void restoreState(FacesContext context, Object state) {
146:                Object values[] = (Object[]) state;
147:                super .restoreState(context, values[0]);
148:                _compAttrMap = (Map) restoreAttachedMapState(context,
149:                        values[1], values[2]);
150:                _macroURI = (String) values[3];
151:                _extends = (String) values[4];
152:                _useClass = (String) values[5];
153:                _name = (String) values[6];
154:                _inline = ((Boolean) values[7]).booleanValue();
155:                _moldName = (String) values[8];
156:                _moldURI = (String) values[9];
157:            }
158:
159:            public void encodeBegin(FacesContext context) throws IOException {
160:                if (!isRendered() || !isEffective())
161:                    return; //nothing to do
162:                super .encodeBegin(context);
163:                Map requestMap = (Map) context.getExternalContext()
164:                        .getRequestMap();
165:                Map macros = (Map) requestMap.get(BaseComponentDefinition.class
166:                        .getName());
167:                if (macros == null)
168:                    requestMap.put(BaseComponentDefinition.class.getName(),
169:                            macros = new LinkedHashMap());
170:                macros.put(_name, this );
171:            }
172:
173:            /** Helper method, check a string is null or empty. */
174:            private static boolean isEmpty(String s) {
175:                return s == null || s.length() == 0;
176:            }
177:
178:            /**
179:             * register component definition to page.
180:             * @param page a zul page instance
181:             */
182:            /*public*/void registerComponentDefinition(Page page) {
183:                ComponentDefinition compdef;
184:                if (_macroURI != null) {
185:                    compdef = page.getLanguageDefinition().getMacroDefinition(
186:                            _name, _macroURI, _inline, null);
187:                    if (!isEmpty(_useClass)) {
188:                        if (_inline)
189:                            throw new UiException(
190:                                    "class not allowed with inline macros, ");
191:                        compdef.setImplementationClass(_useClass);
192:                    }
193:                } else if (_extends != null) {
194:                    final ComponentDefinition ref = page
195:                            .getLanguageDefinition().getComponentDefinition(
196:                                    _extends);
197:                    if (ref.isMacro())
198:                        throw new UiException(
199:                                "Unable to extend from a macro component, "
200:                                        + _extends);
201:                    compdef = ref.clone(null, _name);
202:                    if (!isEmpty(_useClass)) {
203:                        compdef.setImplementationClass(_useClass);
204:                        //Resolve later since might defined in zscript
205:                    }
206:                } else {
207:                    if (isEmpty(_useClass))
208:                        throw new UiException(
209:                                " The Macro-define's property: 'use' cannot be empty! ");
210:                    final ComponentDefinitionImpl cdi = new ComponentDefinitionImpl(
211:                            page.getLanguageDefinition(), null, _name,
212:                            (Class) null);
213:                    cdi.setCurrentDirectory(null);
214:                    //mold URI requires it
215:                    compdef = cdi;
216:                    compdef.setImplementationClass(_useClass);
217:                }
218:
219:                if (!isEmpty(_moldURI))
220:                    compdef.addMold(isEmpty(_moldName) ? "default" : _moldName,
221:                            _moldURI);
222:                for (Iterator e = _compAttrMap.entrySet().iterator(); e
223:                        .hasNext();) {
224:                    final Map.Entry me = (Map.Entry) e.next();
225:                    compdef.addProperty((String) me.getKey(), (String) me
226:                            .getValue());
227:                }
228:
229:                page.getComponentDefinitionMap().add(compdef);
230:            }
231:
232:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.