Source Code Cross Referenced for BranchOutput.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:        /* BranchOutput.java
002:
003:         {{IS_NOTE
004:         Purpose:
005:         
006:         Description:
007:         
008:         History:
009:         Aug 9, 2007 12:42:46 PM     2007, Created by Dennis.Chen
010:         }}IS_NOTE
011:
012:         Some code of this file is refer to Apache License Version 2.0
013:         the license file is http://www.apache.org/licenses/LICENSE-2.0 
014:
015:         Copyright (C) 2007 Potix Corporation. All Rights Reserved.
016:
017:         {{IS_RIGHT
018:         This program is distributed under GPL Version 2.0 in the hope that
019:         it will be useful, but WITHOUT ANY WARRANTY.
020:         }}IS_RIGHT
021:         */
022:        package org.zkoss.jsf.zul.impl;
023:
024:        import javax.faces.component.EditableValueHolder;
025:        import javax.faces.component.ValueHolder;
026:        import javax.faces.context.FacesContext;
027:        import javax.faces.convert.Converter;
028:        import javax.faces.el.ValueBinding;
029:
030:        import org.zkoss.lang.reflect.Fields;
031:        import org.zkoss.zk.ui.Component;
032:
033:        /**
034:         *  The skeletal class used to implement the ZULJSF components
035:         *  which needs to support {@link javax.faces.component.ValueHolder}.<br/>
036:         *  Components should be declared nested under {@link org.zkoss.jsf.zul.Page}.
037:         *  
038:         *  see Javadoc of <a href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/index.html">JSF Specification</a>
039:         *  
040:         * @author Dennis.Chen
041:         */
042:        abstract public class BranchOutput extends BranchComponent implements 
043:                ValueHolder, ValueHolderSupport {
044:
045:            private boolean _localValueSet;
046:
047:            public boolean isLocalValueSet() {
048:                return _localValueSet;
049:            }
050:
051:            public void setLocalValueSet(boolean localValueSet) {
052:                this ._localValueSet = localValueSet;
053:            }
054:
055:            //------------code refer to Apache MyFaces-----------------
056:
057:            public Object getLocalValue() {
058:                return (this ._value);
059:            }
060:
061:            private Converter _converter;
062:            private Object _value;
063:
064:            public Converter getConverter() {
065:                if (this ._converter != null) {
066:                    return this ._converter;
067:                }
068:                ValueBinding vb = getValueBinding("converter");
069:                if (vb != null) {
070:                    return (Converter) vb.getValue(getFacesContext());
071:                } else {
072:                    return null;
073:                }
074:            }
075:
076:            public void setConverter(Converter converter) {
077:                this ._converter = converter;
078:            }
079:
080:            public Object getValue() {
081:                //modify dennis, maybe use set null to value,
082:                if (_localValueSet/*_value != null*/) {
083:                    return this ._value;
084:                }
085:                ValueBinding vb = getValueBinding("value");
086:                if (vb != null) {
087:                    return vb.getValue(getFacesContext());
088:                } else {
089:                    return null;
090:                }
091:
092:            }
093:
094:            public void setValue(Object value) {
095:                this ._value = value;
096:                _localValueSet = true;
097:            }
098:
099:            // ----------------------------------------------------- StateHolder Methods
100:            /**
101:             * Override Method, save the state of this component.
102:             */
103:            public Object saveState(FacesContext context) {
104:
105:                Object values[] = new Object[4];
106:                values[0] = super .saveState(context);
107:                values[1] = saveAttachedState(context, _converter);
108:                values[2] = _value;
109:                values[3] = _localValueSet ? Boolean.TRUE : Boolean.FALSE;
110:                return (values);
111:
112:            }
113:
114:            /**
115:             * Override Method, restore the state of this component.
116:             */
117:            public void restoreState(FacesContext context, Object state) {
118:
119:                Object values[] = (Object[]) state;
120:                super .restoreState(context, values[0]);
121:                _converter = (Converter) restoreAttachedState(context,
122:                        values[1]);
123:                _value = values[2];
124:                _localValueSet = ((Boolean) values[3]).booleanValue();
125:
126:            }
127:
128:            //	------------end of code refer--------------------
129:
130:            /**
131:             * Override Method,
132:             * if instance implements {@link ValueHolderSupport} (always for now), 
133:             * then i will try to set the value from ValueHolder to ZUL Component.
134:             * 
135:             */
136:            protected void afterZULComponentComposed(Component zulcomp) {
137:                super .afterZULComponentComposed(zulcomp);
138:
139:                //check if need to put value attribute of ValueHolder to ZUL
140:                if (this  instanceof  ValueHolderSupport
141:                        && (isLocalValueSet() || getValueBinding("value") != null)) {
142:                    Object value = null;
143:                    String att = ((ValueHolderSupport) this )
144:                            .getMappedAttributeName();
145:                    if (att != null) {
146:                        if (this  instanceof  EditableValueHolder
147:                                && !((EditableValueHolder) this ).isValid()) {
148:                            value = ((EditableValueHolder) this )
149:                                    .getSubmittedValue();
150:                            try {
151:                                if (value != null && value instanceof  String) {
152:                                    value = transferValueForAttribute((String) value);
153:                                }
154:                                Fields.setField(zulcomp, att, value, true);
155:                                return;
156:                            } catch (Exception x) {
157:                                //when invalid, I ignore the exception and set to original value by getValue.
158:                            }
159:                        }
160:
161:                        value = getValue();
162:                        Converter converter = getConverter();
163:                        if (converter != null) {
164:                            value = converter.getAsString(getFacesContext(),
165:                                    this , value);
166:                        }
167:
168:                        try {
169:                            if (value != null && value instanceof  String) {
170:                                value = transferValueForAttribute((String) value);
171:                            }
172:                            Fields.setField(zulcomp, att, value, true);
173:                        } catch (Exception x) {
174:                            throw new RuntimeException(
175:                                    "set Field fail at attribute :" + att, x);
176:                        }
177:                    }
178:                }
179:            }
180:
181:            /**
182:             * Return ZUL Component attribute to map to value attribute of ValueHolder,
183:             * delivering class might override this method to return corresponding name.
184:             *  
185:             * Note : Default is "value"
186:             * 
187:             * @see ValueHolderSupport
188:             */
189:            public String getMappedAttributeName() {
190:                return "value";
191:            }
192:
193:            /**
194:             * Default implementation return original String
195:             * @see ValueHolderSupport
196:             */
197:            public Object transferValueForAttribute(String value) {
198:                return value;
199:            }
200:
201:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.