Source Code Cross Referenced for BeanTag.java in  » Portal » Open-Portal » com » sun » portal » wireless » taglibs » base » 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 » Portal » Open Portal » com.sun.portal.wireless.taglibs.base 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $Id: BeanTag.java,v 1.6 2005/09/21 10:50:24 dg154973 Exp $
003:         * Copyright 2002 Sun Microsystems, Inc. All
004:         * rights reserved. Use of this product is subject
005:         * to license terms. Federal Acquisitions:
006:         * Commercial Software -- Government Users
007:         * Subject to Standard License Terms and
008:         * Conditions.
009:         *
010:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011:         * are trademarks or registered trademarks of Sun Microsystems,
012:         * Inc. in the United States and other countries.
013:         */package com.sun.portal.wireless.taglibs.base;
014:
015:        import com.sun.portal.log.common.PortalLogger;
016:
017:        import javax.servlet.jsp.*;
018:        import javax.servlet.jsp.tagext.*;
019:        import java.util.logging.Logger;
020:        import java.util.logging.Level;
021:
022:        /**
023:         * BeanTag - tag that represents a bean
024:         * 
025:         * This tag encapsulates a bean or object for
026:         * use with other tags such as get and set.
027:         * 
028:         * Attributes:
029:         * 
030:         * id
031:         *   name to store the new bean in the page context
032:         * name
033:         *   name to use to find the bean in the page context
034:         * 
035:         * Either "id" or "name" attribute must be used.
036:         * Implementations of these attributes is inheirited
037:         * from the TagSupport class.
038:         * 
039:         * Subclasses must implement the newBean() method
040:         * which will be called to create a new bean.
041:         * Cooperative classes use the getBean() method to
042:         * get a handle on the bean when this tag is used
043:         * as a parent.
044:         * 
045:         * @author Robert O'Brien
046:         * @version 1.0
047:         * @see BeanGetTag
048:         * @see BeanSetTag
049:         */
050:        public abstract class BeanTag extends BaseTagSupport implements 
051:                BeanHolder {
052:            // Create a logger for this class
053:            private static Logger debugLogger = PortalLogger
054:                    .getLogger(BeanTag.class);
055:
056:            /**
057:             * The bean object this tag represents
058:             */
059:            protected Object bean;
060:
061:            /**
062:             * Get the bean object
063:             * 
064:             * @return the bean object
065:             */
066:            public Object getBean() {
067:                if (bean == null) {
068:                    try {
069:                        bean = findBean();
070:                    } catch (Exception e) {
071:                        debugLogger.log(Level.WARNING, "exception thrown on "
072:                                + this , e);
073:                        bean = null;
074:                    }
075:                }
076:                return bean;
077:            }
078:
079:            /**
080:             * Set the bean object
081:             * 
082:             * @param bean   the bean object
083:             */
084:            public void setBean(Object bean) {
085:                this .bean = bean;
086:            }
087:
088:            /**
089:             * Create a new bean
090:             * 
091:             * Subclasses must implement this method to
092:             * return the bean object that this tag represents.
093:             * 
094:             * @return the newly created bean
095:             */
096:            public abstract Object newBean() throws Exception;
097:
098:            /**
099:             * Find the bean
100:             * 
101:             * If the "name" attribute is specified the get
102:             * the bean from then page context.
103:             * 
104:             * Otherwise search for the bean elsewhere.
105:             * If there is a parent CollectionTag then use
106:             * it to get the current item. Otherwise call
107:             * newBean() to create a new object.
108:             * 
109:             * If the "id" attribute is specified then store
110:             * the bean into the page context using "id".
111:             * 
112:             * @return the found bean
113:             */
114:            public Object findBean() throws Exception {
115:                Object bean;
116:
117:                if (name != null) {
118:                    return pageContext.getAttribute(name);
119:                }
120:
121:                CollectionTag collection = (CollectionTag) TagSupport
122:                        .findAncestorWithClass(this , CollectionTag.class);
123:
124:                if (collection != null) {
125:                    bean = collection.getItem();
126:                } else {
127:                    bean = newBean();
128:                }
129:
130:                if (id != null) {
131:                    debugLogger
132:                            .log(Level.FINE, "About to set bean=" + bean
133:                                    + ", with id=" + id + ", on context="
134:                                    + pageContext);
135:                    pageContext.setAttribute(id, bean);
136:                }
137:
138:                return bean;
139:            }
140:
141:            /**
142:             * Make the bean available.
143:             * 
144:             * @return EVAL_BODY_INCLUDE
145:             * @exception JspException
146:             */
147:            public int doStartTag() throws JspException {
148:
149:                if (id != null && name != null) {
150:                    debugLogger.fine("PSMA_CSPWTB0011");
151:                    throw new JspException(
152:                            this .getClass().getName()
153:                                    + ".doStartTag(): Cannot use both 'id' and 'name' attributes");
154:                }
155:
156:                try {
157:                    bean = findBean();
158:                } catch (Exception e) {
159:                    debugLogger.log(Level.FINE, "PSMA_CSPWTB0001", e);
160:                    throw new JspException(this .getClass().getName()
161:                            + ".doStartTag():  " + e.getMessage());
162:                }
163:
164:                return EVAL_BODY_INCLUDE;
165:            }
166:
167:            /**
168:             * Continue evaluating the page
169:             * 
170:             * @return EVAL_PAGE
171:             * @exception JspException
172:             */
173:            public int doEndTag() throws JspException {
174:                return EVAL_PAGE;
175:            }
176:
177:            /**
178:             * Cleanup
179:             */
180:            public void release() {
181:                super.release();
182:                id = null;
183:                name = null;
184:                bean = null;
185:            }
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.