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


001:        /* MilComponent.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		May 31, 2007 4:25:10 PM, Created by henrichen
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:
020:        package org.zkoss.mil;
021:
022:        import org.zkoss.mil.au.in.CommandCommand;
023:        import org.zkoss.xml.HTMLs;
024:        import org.zkoss.zk.ui.AbstractComponent;
025:        import org.zkoss.zk.ui.event.EventListener;
026:        import org.zkoss.zk.ui.event.Events;
027:
028:        /**
029:         * Super class of MIL component.
030:         * 
031:         * @author henrichen
032:         */
033:        abstract public class MilComponent extends AbstractComponent {
034:            /** Returns whether to send back the request of the specified event
035:             * immediately -- i.e., non-deferrable.
036:             * Returns true if you want the component (on the server)
037:             * to process the event immediately.
038:             *
039:             * <p>Default: return true if any non-deferable event listener of
040:             * the specified event is found. In other words, it returns
041:             * {@link Events#isListened} with asap = true.
042:             */
043:            protected boolean isAsapRequired(String evtnm) {
044:                return Events.isListened(this , evtnm, true);
045:            }
046:
047:            /** Appends the HTML attribute for the specified event name, say, onChange.
048:             * It is called by derived's {@link #getOuterAttrs}.
049:             *
050:             * @param sb the string buffer to hold the HTML attribute. If null and
051:             * {@link #isAsapRequired} is true, a string buffer is created and returned.
052:             * @return the string buffer. If sb is null and {@link #isAsapRequired}
053:             * returns false, null is returned.
054:             * If the caller passed non-null sb, the returned value must be the same
055:             * as sb (so it usually ignores the returned value).
056:             */
057:            protected StringBuffer appendAsapAttr(StringBuffer sb, String evtnm) {
058:                if (isAsapRequired(evtnm)) {
059:                    if (sb == null)
060:                        sb = new StringBuffer(80);
061:                    HTMLs.appendAttribute(sb, getAttrOfEvent(evtnm), "t");
062:                }
063:                return sb;
064:            }
065:
066:            private static String getAttrOfEvent(String evtnm) {
067:                return "onBack".equals(evtnm) ? "bc"
068:                        : "onCancel".equals(evtnm) ? "cc" : "onExit"
069:                                .equals(evtnm) ? "ec"
070:                                : "onHelp".equals(evtnm) ? "hc" : "onItem"
071:                                        .equals(evtnm) ? "in" : "onOK"
072:                                        .equals(evtnm) ? "oc" : "onScreen"
073:                                        .equals(evtnm) ? "sc" : "onStop"
074:                                        .equals(evtnm) ? "sn" : "onChange"
075:                                        .equals(evtnm) ? "on" : "onChanging"
076:                                        .equals(evtnm) ? "og" : "onSelect"
077:                                        .equals(evtnm) ? "os" : "onSlide"
078:                                        .equals(evtnm) ? "ol" : "";
079:            }
080:
081:            /**
082:             * Encode text to make it complies to XML standard.
083:             * @param str the input string
084:             * @return the output string that complies to XML standard.
085:             */
086:            protected String encodeString(String str) {
087:                if (str == null)
088:                    return null;
089:                final int len = str.length();
090:                final StringBuffer sb = new StringBuffer(len + 100);
091:                for (int j = 0; j < len; ++j) {
092:                    final char c = str.charAt(j);
093:                    switch (c) {
094:                    case '"':
095:                        sb.append("&#34;");
096:                        break;
097:                    case '&':
098:                        sb.append("&#38;");
099:                        break;
100:                    case '<':
101:                        sb.append("&#60;");
102:                        break;
103:                    default:
104:                        sb.append(c);
105:                    }
106:                }
107:                return sb.toString();
108:            }
109:
110:            //-- Component --//
111:            public boolean addEventListener(String evtnm, EventListener listener) {
112:                final boolean asap = isAsapRequired(evtnm);
113:                final boolean ret = super .addEventListener(evtnm, listener);
114:                if (ret && !asap && isAsapRequired(evtnm))
115:                    smartUpdate(getAttrOfEvent(evtnm), "t");
116:                return ret;
117:            }
118:
119:            public boolean removeEventListener(String evtnm,
120:                    EventListener listener) {
121:                final boolean asap = isAsapRequired(evtnm);
122:                final boolean ret = super .removeEventListener(evtnm, listener);
123:                if (ret && asap && !isAsapRequired(evtnm))
124:                    smartUpdate(getAttrOfEvent(evtnm), null);
125:                return ret;
126:            }
127:
128:            public String getOuterAttrs() {
129:                return "";
130:            }
131:
132:            //register the MIL related event
133:            static {
134:                new CommandCommand("onCommand",
135:                        org.zkoss.zk.au.Command.IGNORE_OLD_EQUIV);
136:            }
137:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.