Source Code Cross Referenced for HtmlComposite.java in  » J2EE » Sofia » com » salmonllc » html » 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 » J2EE » Sofia » com.salmonllc.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //** Copyright Statement ***************************************************
002:        //The Salmon Open Framework for Internet Applications (SOFIA)
003:        // Copyright (C) 1999 - 2002, Salmon LLC
004:        //
005:        // This program is free software; you can redistribute it and/or
006:        // modify it under the terms of the GNU General Public License version 2
007:        // as published by the Free Software Foundation;
008:        // 
009:        // This program is distributed in the hope that it will be useful,
010:        // but WITHOUT ANY WARRANTY; without even the implied warranty of
011:        // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012:        // GNU General Public License for more details.
013:        // 
014:        // You should have received a copy of the GNU General Public License
015:        // along with this program; if not, write to the Free Software
016:        // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
017:        // 
018:        // For more information please visit http://www.salmonllc.com
019:        //** End Copyright Statement ***************************************************
020:        package com.salmonllc.html;
021:
022:        /////////////////////////
023:        //$Archive: /JADE/SourceCode/com/salmonllc/html/HtmlComposite.java $
024:        //$Author: Dan $
025:        //$Revision: 11 $
026:        //$Modtime: 10/30/02 2:38p $
027:        /////////////////////////
028:
029:        import com.salmonllc.util.MessageLog;
030:
031:        import java.util.Enumeration;
032:        import java.util.Vector;
033:
034:        /**
035:         * This class is used as a typed container object. Primarily used with the HtmlLookup Object
036:         * and the list forms. Making the lookup component extend HtmlComposite allows the listform to interigate
037:         * the object for information to be able search on the value automatically.
038:         */
039:        public class HtmlComposite extends HtmlContainer {
040:            /** add the type for each comp ex. Datastore.DATA_TYPES integer values */
041:            private Vector _dataType = new Vector();
042:
043:            /** is it bound to a column boolean values */
044:            private Vector _bound = new Vector();
045:
046:            /** if yes which table.column */
047:            private Vector _tables = new Vector();
048:            private Vector _columns = new Vector();
049:
050:            /** for use by user meaningless inside */
051:            private Vector _flags = new Vector();
052:
053:            static final int DATATYPE_ANY = 99;
054:
055:            /**
056:             * HtmlComposite constructor.
057:             * @param name String - name of composite component
058:             * @param p HtmlPage - page the component is associated with
059:             */
060:            public HtmlComposite(String name, HtmlPage p) {
061:                super (name, p);
062:            }
063:
064:            /**
065:             * add
066:             *  DO NOT USE: HtmlComposite.add. Use addCompositeComponent instead
067:             * @param comp HtmlComponent
068:             */
069:            public void add(HtmlComponent comp) {
070:                try {
071:                    throw new Exception(
072:                            " DO NOT USE: HtmlComposite.add. Use addCompositeComponent instead");
073:                } catch (Exception e) {
074:                    MessageLog
075:                            .writeErrorMessage(
076:                                    " DO NOT USE: HtmlComposite.add. Use addCompositeComponent instead",
077:                                    e, this );
078:                }
079:            }
080:
081:            /**
082:             * This method adds a component and the associated information to a set of Vectors
083:             * it return and Object so you can keep a handle to the component for later use.
084:             * @return Object - reference to added component
085:             * @param comp HtmlComponent - component to add
086:             * @param dataType int - data type of component added
087:             * @param bound boolean - is the component bound to a datastore
088:             * @param table String - table the component is bound to
089:             * @param column String - column the component is bound to
090:             */
091:            public Object addCompositeComponent(HtmlComponent comp,
092:                    int dataType, boolean bound, String table, String column) {
093:                return addCompositeComponent(comp, dataType, bound, table,
094:                        column, 0);
095:            }
096:
097:            /**
098:             * This method adds a component and the associated information to a set of Vectors
099:             * it return and Object so you can keep a handle to the component for later use.
100:             * @return Object - reference to added component
101:             * @param comp HtmlComponent - component to add
102:             * @param dataType int - data type of component added
103:             * @param bound boolean - is the component bound to a datastore
104:             * @param table String - table the component is bound to
105:             * @param column String - column the component is bound to
106:             * @param flags int - flags to associate to this componet
107:             */
108:            public Object addCompositeComponent(HtmlComponent comp,
109:                    int dataType, boolean bound, String table, String column,
110:                    int flags) {
111:
112:                /** add componet contained */
113:                _componentsVec.addElement(comp);
114:                /** add the type for each comp ex. Datastore.DATA_TYPES integer values */
115:                _dataType.addElement(new Integer(dataType));
116:                /** is it bound to a column boolean values */
117:                _bound.addElement(new Boolean(bound));
118:                /** if yes which table.column */
119:                _tables.addElement(table);
120:                _columns.addElement(column);
121:                /** default value = 0 */
122:                _flags.addElement(new Integer(flags));
123:                comp.setParent(this );
124:                return comp;
125:            }
126:
127:            /**
128:             * This method returns a component by index
129:             * @return  HtmlComponent
130:             * @param index int
131:             */
132:            public HtmlComponent getComponent(int index) {
133:                return (HtmlComponent) _componentsVec.elementAt(index);
134:            }
135:
136:            /**
137:             * This method returns the column associated to this component.
138:             * @return String - column name
139:             * @param comp - HtmlComponent being searched for being searched for
140:             */
141:            public String getComponentColumn(HtmlComponent comp) {
142:                /** get index of comp */
143:                int index = _componentsVec.indexOf(comp);
144:                String returnVal = null;
145:                if (index == -1) {
146:                    return null;
147:                } else {
148:                    returnVal = (String) _columns.elementAt(index);
149:                    return returnVal;
150:                }
151:            }
152:
153:            /**
154:             * This method returns the data type associated to this component.
155:             * @return int - index value
156:             * @param comp - HtmlComponent being searched for
157:             */
158:            public int getComponentDataType(HtmlComponent comp) {
159:                /** get index of comp */
160:                int index = _componentsVec.indexOf(comp);
161:                int returnVal = -1;
162:                if (index == -1) {
163:                    return returnVal;
164:                } else {
165:                    returnVal = ((Integer) _dataType.elementAt(index))
166:                            .intValue();
167:                    return returnVal;
168:                }
169:            }
170:
171:            /**
172:             * This method returns the flags associated to this component.
173:             * @return int - flag values
174:             * @param comp - HtmlComponent being searched for
175:             */
176:            public int getComponentFlags(HtmlComponent comp) {
177:                /** get index of comp */
178:                int index = _componentsVec.indexOf(comp);
179:                int returnVal = -1;
180:                if (index == -1) {
181:                    return returnVal;
182:                } else {
183:                    returnVal = ((Integer) _flags.elementAt(index)).intValue();
184:                    return returnVal;
185:                }
186:            }
187:
188:            /**
189:             * Returns an enumeration of componets
190:             * @return - Enumeration
191:             */
192:            public Enumeration getComponents() {
193:                return _componentsVec.elements();
194:            }
195:
196:            /**
197:             * This method returns the table associated to this component.
198:             * @return String - table name
199:             * @param comp - HtmlComponent being searched for
200:             */
201:            public String getComponentTable(HtmlComponent comp) {
202:                /** get index of comp */
203:                int index = _componentsVec.indexOf(comp);
204:                String returnVal = null;
205:                if (index == -1) {
206:                    return null;
207:                } else {
208:                    returnVal = (String) _tables.elementAt(index);
209:                    return returnVal;
210:                }
211:            }
212:
213:            /**
214:             * This method returns the number of items in the composite component
215:             * @return int
216:             */
217:            public int getCompositeSize() {
218:                return _componentsVec.size();
219:            }
220:
221:            /**
222:             * This method returns the whether the component is bound to a DataStore
223:             * @return boolean
224:             * @param comp - HtmlComponent being searched for
225:             */
226:            public boolean getIsComponentBound(HtmlComponent comp) {
227:                /** get index of comp */
228:                int index = _componentsVec.indexOf(comp);
229:                boolean returnVal = false;
230:                if (index == -1) {
231:                    return false;
232:                } else {
233:                    returnVal = ((Boolean) _bound.elementAt(index))
234:                            .booleanValue();
235:                    return returnVal;
236:                }
237:            }
238:
239:            /**
240:             * This method inserts a component and the associated information in to a set of Vectors at a specified location.
241:             * It return and Object so you can keep a handle to the component for later use.
242:             * @return Object - reference to added component
243:             * @param comp HtmlComponent - component to insert
244:             * @param dataType int - data type of component inserted
245:             * @param bound boolean - is the component bound to a datastore
246:             * @param table String - table the component is bound to
247:             * @param column String - column the component is bound to
248:
249:             */
250:            public Object insertCompositeComponentAt(HtmlComponent comp,
251:                    int index, int dataType, boolean bound, String table,
252:                    String column) {
253:                return insertCompositeComponentAt(comp, index, dataType, bound,
254:                        table, column, 0);
255:            }
256:
257:            /**
258:             * This method inserts a component and the associated information in to a set of Vectors at a specified location.
259:             * It return and Object so you can keep a handle to the component for later use.
260:             * @return Object - reference to added component
261:             * @param comp HtmlComponent - component to insert
262:             * @param dataType int - data type of component added
263:             * @param bound boolean - is the component bound to a datastore
264:             * @param table String - table the component is bound to
265:             * @param column String - column the component is bound to
266:             * @param flags int - flags to associate to this componet
267:             */
268:            public Object insertCompositeComponentAt(HtmlComponent comp,
269:                    int index, int dataType, boolean bound, String table,
270:                    String column, int flags) {
271:                try {
272:                    if (_componentsVec.isEmpty()) {
273:
274:                        /** add componet contained */
275:                        _componentsVec.addElement(comp);
276:                        /** add the type for each comp ex. Datastore.DATA_TYPES integer values */
277:                        _dataType.addElement(new Integer(dataType));
278:                        /** is it bound to a column boolean values */
279:                        _bound.addElement(new Boolean(bound));
280:                        /** if yes which table.column */
281:                        _tables.addElement(table);
282:                        _columns.addElement(column);
283:                        _flags.addElement(new Integer(flags));
284:                    } else {
285:                        /** add componet contained */
286:                        _componentsVec.insertElementAt(comp, index);
287:                        /** add the type for each comp ex. Datastore.DATA_TYPES integer values */
288:                        _dataType.insertElementAt(new Integer(dataType), index);
289:                        /** is it bound to a column boolean values */
290:                        _bound.insertElementAt(new Boolean(bound), index);
291:                        /** if yes which table.column */
292:                        _tables.insertElementAt(table, index);
293:                        _columns.insertElementAt(column, index);
294:                        _flags.insertElementAt(new Integer(flags), index);
295:                    }
296:                    comp.setParent(this );
297:                } catch (Exception e) {
298:                    MessageLog.writeErrorMessage("insertCompositeComponentAt",
299:                            e, this );
300:                }
301:                return comp;
302:            }
303:
304:            /**
305:             * This method replaces a component and the associated information with a new passed in object.
306:             * It return and Object so you can keep a handle to the component for later use.
307:             * @return Object - reference to added component
308:             * @param comp HtmlComponent - component to replace
309:             * @param dataType int - data type of component added
310:             * @param bound boolean - is the component bound to a datastore
311:             * @param table String - table the component is bound to
312:             * @param column String - column the component is bound to
313:             */
314:            public Object replaceCompositeComponent(HtmlComponent comp,
315:                    Object compToReplace, int dataType, boolean bound,
316:                    String table, String column) {
317:                return replaceCompositeComponent(comp, compToReplace, dataType,
318:                        bound, table, column, 0);
319:            }
320:
321:            /**
322:             * This method replaces a component and the associated information with a new passed in object.
323:             * It return and Object so you can keep a handle to the component for later use.
324:             * @return Object - reference to added component
325:             * @param comp HtmlComponent - component to replace
326:             * @param compToReplace Object - reference of object to replace
327:             * @param dataType int - data type of component added
328:             * @param bound boolean - is the component bound to a datastore
329:             * @param table String - table the component is bound to
330:             * @param column String - column the component is bound to
331:             */
332:            public Object replaceCompositeComponent(HtmlComponent comp,
333:                    Object compToReplace, int dataType, boolean bound,
334:                    String table, String column, int flags) {
335:                try {
336:
337:                    /** get the index of the edit field so we can replace it */
338:                    int replaceIndex = _componentsVec.indexOf(compToReplace);
339:                    if (replaceIndex != -1) {
340:                        /** add componet contained */
341:                        _componentsVec.setElementAt(comp, replaceIndex);
342:                        /** add the type for each comp ex. Datastore.DATA_TYPES integer values */
343:                        _dataType.setElementAt(new Integer(dataType),
344:                                replaceIndex);
345:                        /** is it bound to a column boolean values */
346:                        _bound.setElementAt(new Boolean(bound), replaceIndex);
347:                        /** if yes which table.column */
348:                        _tables.setElementAt(table, replaceIndex);
349:                        _columns.setElementAt(column, replaceIndex);
350:
351:                        _flags.setElementAt(new Integer(flags), replaceIndex);
352:                        comp.setParent(this );
353:                    }
354:                } catch (Exception e) {
355:                    MessageLog.writeErrorMessage("replaceCompositeComponent",
356:                            e, this );
357:                }
358:                return comp;
359:            }
360:
361:            /**
362:             * This method sets the column the component is bound to in a DataStore
363:             * @param comp - HtmlComponent being searched for
364:             * @param column String - column name
365:             */
366:            public void setComponentColumn(HtmlComponent comp, String column) {
367:                /** get index of comp */
368:                int index = _componentsVec.indexOf(comp);
369:                if (index == -1) {
370:                    return;
371:                } else {
372:                    _columns.setElementAt(column, index);
373:                }
374:            }
375:
376:            /**
377:             * This method sets the data type of the column the component is bound to in a DataStore
378:             * @param comp - HtmlComponent being searched for
379:             * @param dataType int Please use the data types from DataStore.
380:             *  if you don't know what datatype use HtmlComposite.DATATYPE_ANY
381:             */
382:            public void setComponentDataType(HtmlComponent comp, int dataType) {
383:                int index = _componentsVec.indexOf(comp);
384:                if (index == -1) {
385:                    return;
386:                } else {
387:                    _dataType.setElementAt(new Integer(dataType), index);
388:                }
389:            }
390:
391:            /**
392:             * This method sets the flags the component is using if any.
393:             * @param comp - HtmlComponent to associate flags to
394:             * @param flags - flag values
395:             */
396:            public void setComponentFlags(HtmlComponent comp, int flags) {
397:                int index = _componentsVec.indexOf(comp);
398:                if (index == -1) {
399:                    return;
400:                } else {
401:                    _flags.setElementAt(new Integer(flags), index);
402:                }
403:            }
404:
405:            /**
406:             * This method sets the table the component is bound to in a DataStore
407:             * @param comp - HtmlComponent being searched for
408:             * @param table String
409:             */
410:            public void setComponentTable(HtmlComponent comp, String table) {
411:                /** get index of comp */
412:                int index = _componentsVec.indexOf(comp);
413:                if (index == -1) {
414:                    return;
415:                } else {
416:                    _tables.setElementAt(table, index);
417:                }
418:            }
419:
420:            /**
421:             * This method sets whether the component is bound to a table.column
422:             * @param comp - HtmlComponent being searched for
423:             * @param bound boolean
424:             */
425:            public void setIsComponentBound(HtmlComponent comp, boolean bound) {
426:                /** get index of comp */
427:                int index = _componentsVec.indexOf(comp);
428:                if (index == -1) {
429:                    return;
430:                } else {
431:                    _bound.setElementAt(new Boolean(bound), index);
432:                }
433:            }
434:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.