Source Code Cross Referenced for PortletComponent.java in  » Portal » Open-Portal » com » sun » faces » portlet » 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.faces.portlet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: PortletComponent.java,v 1.3 2005/07/08 08:40:56 dg154973 Exp $
003:         */
004:
005:        /*
006:         * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
007:         * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
008:         */
009:
010:        package com.sun.faces.portlet;
011:
012:        import org.apache.commons.logging.Log;
013:        import org.apache.commons.logging.LogFactory;
014:
015:        import javax.faces.context.FacesContext;
016:        import javax.faces.component.NamingContainer;
017:        import javax.faces.component.UIComponentBase;
018:        import javax.portlet.RenderResponse;
019:
020:        /**
021:         * <p><strong>PortletComponent</strong> is a {@link UIComponent} that 
022:         * acts as a container for all JSF components in a portlet page. This component
023:         * works around the problem of "id" clashes in a portal environment where same
024:         * portlet can be deployed multiple times.This component overrides the
025:         * <code>getClientId()</code> method to prepend a unique <code>id</code> 
026:         * everytime it is invoked, so that no two JSF components with in two
027:         * different portlets have the same <code>id</code>. If a <code>portletId</code>
028:         * is specified, it has to an EL expression and the application is responsible
029:         * for making sure that it is unique. If no <portletId> is specifed, 
030:         * <code>PortletComponent</code> guarantees <code>id</code> uniqueness. 
031:         */
032:
033:        public class PortletComponent extends UIComponentBase implements 
034:                NamingContainer {
035:
036:            // ------------------------------------------------------ Manifest Constants
037:
038:            /**
039:             * <p>The standard component type for this component.</p>
040:             */
041:            public static final String COMPONENT_TYPE = "PortletComponent";
042:
043:            /**
044:             * <p>The standard component family for this component.</p>
045:             */
046:            public static final String COMPONENT_FAMILY = "PortletComponent";
047:
048:            // ------------------------------------------------------------ Constructors
049:
050:            /**
051:             * <p>Create a new {@link PortletComponent} instance with default property
052:             * values.</p>
053:             */
054:            public PortletComponent() {
055:
056:                super ();
057:
058:            }
059:
060:            // ------------------------------------------------------ Instance Variables
061:
062:            // The Log instance for this class
063:            private static final Log log = LogFactory
064:                    .getLog(PortletComponent.class);
065:
066:            // -------------------------------------------------------------- Properties
067:
068:            public String getFamily() {
069:
070:                return (COMPONENT_FAMILY);
071:
072:            }
073:
074:            private String portletId = null;
075:
076:            // ----------------------------------------------------- UIComponent Methods
077:            public String getClientId(FacesContext context) {
078:                if (portletId == null) {
079:                    // generate a unique "id" 
080:                    portletId = createUniquePortletId(context);
081:                    if (log.isTraceEnabled()) {
082:                        log.trace("PortletId: " + portletId);
083:                    }
084:                }
085:                return portletId;
086:            }
087:
088:            /**
089:             * Returns a unique PortletId for the portlet.
090:             * The namespace obtained from RenderResponse of the Portlet is used as its
091:             * unique. 
092:             */
093:            private String createUniquePortletId(FacesContext context) {
094:                Object response = context.getExternalContext().getResponse();
095:                Class portletResponseClass = null;
096:                // Class.forName is used instead of instanceof to account for the case
097:                // where the porletPage tag is used in a webapp and portlet.jar is not
098:                // in classpath. In that scenario it will prevent ClassNotFoundException.
099:                try {
100:                    portletResponseClass = Class
101:                            .forName("javax.portlet.RenderResponse");
102:                } catch (ClassNotFoundException cnfe) {
103:                    System.err.println(cnfe);
104:                }
105:
106:                String portletId;
107:                if (portletResponseClass != null
108:                        && portletResponseClass.isInstance(response)) {
109:                    // Get the Namespace from Portlet RenderResponse as its
110:                    //  unique in the context of the portal page.
111:                    portletId = ((RenderResponse) response).getNamespace();
112:                } else {
113:                    // If the response is not of that of Portlet, use any value.
114:                    portletId = "dummy";
115:                }
116:                return portletId;
117:            }
118:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.