Source Code Cross Referenced for Checkbox.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:        /* Checkbox.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Thu Jun 16 23:45:45     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 org.zkoss.lang.Objects;
022:        import org.zkoss.xml.HTMLs;
023:
024:        import org.zkoss.zk.ui.UiException;
025:        import org.zkoss.zk.ui.WrongValueException;
026:        import org.zkoss.zk.ui.ext.client.Checkable;
027:        import org.zkoss.zk.ui.event.Events;
028:
029:        import org.zkoss.zul.impl.LabelImageElement;
030:
031:        /**
032:         * A checkbox.
033:         *
034:         * <p>Event:
035:         * <ol>
036:         * <li>org.zkoss.zk.ui.event.CheckEvent is sent when a checkbox
037:         * is checked or unchecked by user.</li>
038:         * </ol>
039:         *
040:         * @author tomyeh
041:         */
042:        public class Checkbox extends LabelImageElement {
043:            /** The name. */
044:            private String _name;
045:            private int _tabindex = -1;
046:            private boolean _checked;
047:            private boolean _disabled;
048:            private boolean _readonly;
049:
050:            public Checkbox() {
051:            }
052:
053:            public Checkbox(String label) {
054:                setLabel(label);
055:            }
056:
057:            public Checkbox(String label, String image) {
058:                setLabel(label);
059:                setImage(image);
060:            }
061:
062:            /** Returns whether it is disabled.
063:             * <p>Default: false.
064:             */
065:            public boolean isDisabled() {
066:                return _disabled;
067:            }
068:
069:            /** Sets whether it is disabled.
070:             */
071:            public void setDisabled(boolean disabled) {
072:                if (_disabled != disabled) {
073:                    _disabled = disabled;
074:                    smartUpdate("disabled", _disabled);
075:                }
076:            }
077:
078:            /** Returns whether it is checked.
079:             * <p>Default: false.
080:             */
081:            public boolean isChecked() {
082:                return _checked;
083:            }
084:
085:            /** Sets whether it is checked.
086:             */
087:            public void setChecked(boolean checked) {
088:                if (_checked != checked) {
089:                    _checked = checked;
090:                    smartUpdate("checked", _checked);
091:                }
092:            }
093:
094:            /** Returns whether it is readonly.
095:             * <p>Default: false.
096:             * <p>This method has no real effect.
097:             * See <a href="http://www.w3.org/TR/html4/interact/forms.html">w3.org</a>
098:             * @deprecated As of release 2.4.1, since this method has no real effect.
099:             */
100:            public boolean isReadonly() {
101:                return _readonly;
102:            }
103:
104:            /** Sets whether it is readonly.
105:             * <p>This method has no real effect.
106:             * See <a href="http://www.w3.org/TR/html4/interact/forms.html">w3.org</a>
107:             * @deprecated As of release 2.4.1, since this method has no real effect.
108:             */
109:            public void setReadonly(boolean readonly) {
110:                _readonly = readonly;
111:            }
112:
113:            /** Returns the name of this component.
114:             * <p>Default: null.
115:             * <p>Don't use this method if your application is purely based
116:             * on ZK's event-driven model.
117:             * <p>The name is used only to work with "legacy" Web application that
118:             * handles user's request by servlets.
119:             * It works only with HTTP/HTML-based browsers. It doesn't work
120:             * with other kind of clients.
121:             */
122:            public String getName() {
123:                return _name;
124:            }
125:
126:            /** Sets the name of this component.
127:             * <p>Don't use this method if your application is purely based
128:             * on ZK's event-driven model.
129:             * <p>The name is used only to work with "legacy" Web application that
130:             * handles user's request by servlets.
131:             * It works only with HTTP/HTML-based browsers. It doesn't work
132:             * with other kind of clients.
133:             *
134:             * @param name the name of this component.
135:             */
136:            public void setName(String name) {
137:                if (name != null && name.length() == 0)
138:                    name = null;
139:                if (!Objects.equals(_name, name)) {
140:                    _name = name;
141:                    smartUpdate("name", _name);
142:                }
143:            }
144:
145:            /** Returns the tab order of this component.
146:             * <p>Default: -1 (means the same as browser's default).
147:             */
148:            public int getTabindex() {
149:                return _tabindex;
150:            }
151:
152:            /** Sets the tab order of this component.
153:             */
154:            public void setTabindex(int tabindex) throws WrongValueException {
155:                if (_tabindex != tabindex) {
156:                    _tabindex = tabindex;
157:                    if (tabindex < 0)
158:                        smartUpdate("tabindex", null);
159:                    else
160:                        smartUpdate("tabindex", Integer.toString(_tabindex));
161:                }
162:            }
163:
164:            /** Returns the attributes used by the embedded HTML LABEL tag.
165:             * It returns text-relevant styles only.
166:             * <p>Used only by component developer.
167:             */
168:            public String getLabelAttrs() {
169:                final String style = HTMLs.getTextRelevantStyle(getRealStyle());
170:                return style.length() > 0 ? " style=\"" + style + '"' : "";
171:            }
172:
173:            //-- super --//
174:            /** Appends interior attributes for generating the HTML checkbox tag
175:             * (the name, disabled and other attribute).
176:             * <p>Used only by component developers.
177:             */
178:            public String getInnerAttrs() {
179:                final StringBuffer sb = new StringBuffer(64).append(super 
180:                        .getInnerAttrs());
181:
182:                HTMLs.appendAttribute(sb, "name", getName());
183:                if (isDisabled())
184:                    HTMLs.appendAttribute(sb, "disabled", "disabled");
185:                if (isChecked())
186:                    HTMLs.appendAttribute(sb, "checked", "checked");
187:                if (_tabindex >= 0)
188:                    HTMLs.appendAttribute(sb, "tabindex", _tabindex);
189:                return sb.toString();
190:            }
191:
192:            /** Appends exterior attributes for generating the HTML span tag
193:             * (the event relevant attribute).
194:             * <p>Used only by component developers.
195:             */
196:            public String getOuterAttrs() {
197:                final StringBuffer sb = new StringBuffer(64).append(super 
198:                        .getOuterAttrs());
199:
200:                appendAsapAttr(sb, Events.ON_FOCUS);
201:                appendAsapAttr(sb, Events.ON_BLUR);
202:                appendAsapAttr(sb, Events.ON_CHECK);
203:                appendAsapAttr(sb, Events.ON_RIGHT_CLICK);
204:                appendAsapAttr(sb, Events.ON_DOUBLE_CLICK);
205:                //no z.lfclk since it is handled by widget.js
206:
207:                return sb.toString();
208:            }
209:
210:            //-- ComponentCtrl --//
211:            protected Object newExtraCtrl() {
212:                return new ExtraCtrl();
213:            }
214:
215:            /** A utility class to implement {@link #getExtraCtrl}.
216:             * It is used only by component developers.
217:             */
218:            protected class ExtraCtrl extends LabelImageElement.ExtraCtrl
219:                    implements  Checkable {
220:                //-- Checkable --//
221:                public void setCheckedByClient(boolean checked) {
222:                    _checked = checked;
223:                }
224:            }
225:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.