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


001:        /* ListDataModelWrapper.java
002:         {{IS_NOTE
003:         Purpose:
004:         
005:         Description:
006:         
007:         History:
008:            Jul 25, 2007 10:03:38 AM , Created by Dennis Chen
009:         }}IS_NOTE
010:
011:         Copyright (C) 2007 Potix Corporation. All Rights Reserved.
012:
013:         {{IS_RIGHT
014:         This program is distributed under GPL Version 2.0 in the hope that
015:         it will be useful, but WITHOUT ANY WARRANTY.
016:         }}IS_RIGHT
017:         */
018:        package org.zkoss.seam;
019:
020:        import java.io.IOException;
021:        import java.io.ObjectInputStream;
022:        import java.io.ObjectOutputStream;
023:        import java.util.Collections;
024:        import java.util.HashMap;
025:        import java.util.Iterator;
026:        import java.util.LinkedList;
027:        import java.util.List;
028:
029:        import javax.faces.model.DataModelEvent;
030:        import javax.faces.model.DataModelListener;
031:
032:        import org.jboss.seam.jsf.ListDataModel;
033:        import org.zkoss.zkplus.databind.BindingListModel;
034:        import org.zkoss.zul.event.ListDataEvent;
035:        import org.zkoss.zul.event.ListDataListener;
036:
037:        /**
038:         * You should not create this class directly.<br/>
039:         * This Calss is for wrapper JSF's DataModel to ZK's DataModel.
040:         * @author Dennis.Chen
041:         *
042:         */
043:        public class ListDataModelWrapper extends ListDataModel implements 
044:                BindingListModel {
045:
046:            private ListDataModel _ldm;
047:
048:            private HashMap indexCache = new HashMap();
049:            private List listeners = Collections
050:                    .synchronizedList(new LinkedList());
051:
052:            public int indexOf(Object obj) {
053:                if (obj == null)
054:                    return -1;
055:                Integer i = (Integer) indexCache.get(obj);
056:                if (i == null)
057:                    return -1;
058:                return i.intValue();
059:            }
060:
061:            public ListDataModelWrapper(ListDataModel ldm) {
062:                _ldm = ldm;
063:                _ldm.addDataModelListener(new MyDataModelListener());
064:            }
065:
066:            public void addListDataListener(ListDataListener listener) {
067:                if (listeners.indexOf(listener) == -1) {
068:                    listeners.add(listener);
069:                }
070:            }
071:
072:            public Object getElementAt(int i) {
073:                _ldm.setRowIndex(i);
074:                Object obj = _ldm.getRowData();
075:                if (obj != null) {
076:                    indexCache.put(obj, new Integer(i));
077:                }
078:                return obj;
079:            }
080:
081:            public int getSize() {
082:                return _ldm.getRowCount();
083:            }
084:
085:            public void removeListDataListener(ListDataListener listener) {
086:                listeners.remove(listener);
087:            }
088:
089:            /**
090:             * Fire Contents Changed Event to ListDataListener
091:             * @param start
092:             * @param end
093:             */
094:            public void fireRowChanged(int start, int end) {
095:                new ListDataEvent(this , ListDataEvent.CONTENTS_CHANGED, start,
096:                        end);
097:            }
098:
099:            /**
100:             * Fire Contents Added Event to ListDataListener
101:             * @param start
102:             * @param end
103:             */
104:            public void fireRowAdded(int start, int end) {
105:                new ListDataEvent(this , ListDataEvent.INTERVAL_ADDED, start,
106:                        end);
107:            }
108:
109:            /**
110:             * Fire Contents Removed Event to ListDataListener
111:             * @param start
112:             * @param end
113:             */
114:            public void fireRowDeleted(int start, int end) {
115:                new ListDataEvent(this , ListDataEvent.INTERVAL_REMOVED, start,
116:                        end);
117:            }
118:
119:            protected void fireEvent(ListDataEvent event) {
120:                int i = listeners.size();
121:                for (Iterator iter = listeners.iterator(); iter.hasNext();) {
122:                    ((ListDataListener) iter.next()).onChange(event);
123:                }
124:            }
125:
126:            class MyDataModelListener implements  DataModelListener {
127:                public void rowSelected(DataModelEvent arg0) {
128:                    // TODO , nothing can do now.
129:                }
130:            }
131:
132:            /**
133:             * @return inner ListDataModel
134:             */
135:            public ListDataModel getInner() {
136:                return _ldm;
137:            }
138:
139:            //  Delegate org.jboss.seam.jsf.ListDataModel 
140:            public void addDataModelListener(DataModelListener arg0) {
141:                _ldm.addDataModelListener(arg0);
142:            }
143:
144:            public DataModelListener[] getDataModelListeners() {
145:                return _ldm.getDataModelListeners();
146:            }
147:
148:            public int getRowCount() {
149:                return _ldm.getRowCount();
150:            }
151:
152:            public Object getRowData() {
153:                return _ldm.getRowData();
154:            }
155:
156:            public int getRowIndex() {
157:                return _ldm.getRowIndex();
158:            }
159:
160:            public Object getWrappedData() {
161:                return _ldm.getWrappedData();
162:            }
163:
164:            public int hashCode() {
165:                return _ldm.hashCode();
166:            }
167:
168:            public boolean isRowAvailable() {
169:                return _ldm.isRowAvailable();
170:            }
171:
172:            public void removeDataModelListener(DataModelListener arg0) {
173:                _ldm.removeDataModelListener(arg0);
174:            }
175:
176:            public void setRowIndex(int arg0) {
177:                _ldm.setRowIndex(arg0);
178:            }
179:
180:            public void setWrappedData(Object arg0) {
181:                _ldm.setWrappedData(arg0);
182:            }
183:
184:            private void writeObject(ObjectOutputStream oos) throws IOException {
185:                oos.writeObject(getWrappedData());
186:                oos.writeInt(getRowIndex());
187:            }
188:
189:            private void readObject(ObjectInputStream ois) throws IOException,
190:                    ClassNotFoundException {
191:                this .setWrappedData(ois.readObject());
192:                this .setRowIndex(ois.readInt());
193:            }
194:            //end of Delegate
195:
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.