Source Code Cross Referenced for IFrameGenericPortlet.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » 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 » jetspeed 2.1.3 » org.apache.jetspeed.portlet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.jetspeed.portlet;
018:
019:        import java.io.IOException;
020:        import java.util.HashMap;
021:        import java.util.Map;
022:
023:        import javax.portlet.ActionRequest;
024:        import javax.portlet.ActionResponse;
025:        import javax.portlet.PortletConfig;
026:        import javax.portlet.PortletException;
027:        import javax.portlet.PortletPreferences;
028:        import javax.portlet.RenderRequest;
029:        import javax.portlet.RenderResponse;
030:        import javax.portlet.WindowState;
031:
032:        import org.apache.portals.bridges.velocity.GenericVelocityPortlet;
033:
034:        /**
035:         * IFrameGenericPortlet
036:         * 
037:         * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
038:         * @version $Id: IFrameGenericPortlet.java 578925 2007-09-24 19:22:58Z smilek $
039:         */
040:        public class IFrameGenericPortlet extends GenericVelocityPortlet {
041:
042:            private Map attributes = new HashMap();
043:
044:            private Map maxAttributes = new HashMap();
045:
046:            public void init(PortletConfig config) throws PortletException {
047:                super .init(config);
048:                attributes.put("SRC", "http://www.apache.org");
049:                attributes.put("ALIGN", "BOTTOM");
050:                attributes.put("CLASS", "");
051:                attributes.put("FRAMEBORDER", "0");
052:                attributes.put("ID", "");
053:                attributes.put("MARGINHEIGHT", "0");
054:                attributes.put("MARGINWIDTH", "0");
055:                attributes.put("NAME", "");
056:
057:                attributes.put("HEIGHT", "");
058:                attributes.put("WIDTH", "100%");
059:                attributes.put("SCROLLING", "NO");
060:                attributes.put("STYLE", "");
061:
062:                maxAttributes.put("HEIGHT", "800");
063:                maxAttributes.put("WIDTH", "100%");
064:                maxAttributes.put("SCROLLING", "AUTO");
065:                maxAttributes.put("STYLE", "");
066:            }
067:
068:            private String getAttributePreference(PortletPreferences prefs,
069:                    String attribute) {
070:                return this .getMappedAttributePreference(prefs, attribute,
071:                        attributes);
072:            }
073:
074:            private String getMaxAttributePreference(PortletPreferences prefs,
075:                    String attribute) {
076:                return this .getMappedAttributePreference(prefs, "MAX-"
077:                        + attribute, maxAttributes);
078:            }
079:
080:            private String getMappedAttributePreference(
081:                    PortletPreferences prefs, String attribute, Map map) {
082:                return prefs.getValue(attribute, (String) map.get(attribute));
083:            }
084:
085:            private void appendAttribute(PortletPreferences prefs,
086:                    StringBuffer content, String attribute, Map map) {
087:                String value;
088:
089:                if (map == maxAttributes)
090:                    value = getMaxAttributePreference(prefs, attribute);
091:                else
092:                    value = getAttributePreference(prefs, attribute);
093:
094:                if (value == null || value.length() == 0) {
095:                    return;
096:                }
097:                content.append(" ").append(attribute).append("=\"").append(
098:                        value).append("\"");
099:            }
100:
101:            private void appendAttribute(PortletPreferences prefs,
102:                    StringBuffer content, String attribute) {
103:                appendAttribute(prefs, content, attribute, attributes);
104:            }
105:
106:            private void appendMaxAttribute(PortletPreferences prefs,
107:                    StringBuffer content, String attribute) {
108:                appendAttribute(prefs, content, attribute, maxAttributes);
109:            }
110:
111:            public void doView(RenderRequest request, RenderResponse response)
112:                    throws PortletException, IOException {
113:                String viewPage = (String) request
114:                        .getAttribute(PARAM_VIEW_PAGE);
115:                if (viewPage != null) {
116:                    super .doView(request, response);
117:                } else {
118:                    doIFrame(request, response);
119:                }
120:            }
121:
122:            public void doEdit(RenderRequest request, RenderResponse response)
123:                    throws PortletException, IOException {
124:                response.setContentType("text/html");
125:                doPreferencesEdit(request, response);
126:            }
127:
128:            /**
129:             * Render IFRAME content
130:             */
131:            protected void doIFrame(RenderRequest request,
132:                    RenderResponse response) throws IOException {
133:                PortletPreferences prefs = request.getPreferences();
134:                String source = getURLSource(request, response, prefs);
135:                // generate HTML IFRAME content
136:                StringBuffer content = new StringBuffer(4096);
137:
138:                // fix JS2-349
139:                content
140:                        .append("<TABLE CLASS='iframePortletTableContainer' WIDTH='100%'><TBODY CLASS='iframePortletTbodyContainer'><TR><TD>");
141:
142:                content.append("<IFRAME");
143:
144:                // special case source
145:                content.append(" ").append("SRC").append("=\"").append(source)
146:                        .append("\"");
147:
148:                appendAttribute(prefs, content, "ALIGN");
149:                appendAttribute(prefs, content, "CLASS");
150:                appendAttribute(prefs, content, "FRAMEBORDER");
151:                appendAttribute(prefs, content, "ID");
152:                appendAttribute(prefs, content, "MARGINHEIGHT");
153:                appendAttribute(prefs, content, "MARGINWIDTH");
154:                appendAttribute(prefs, content, "NAME");
155:                if (request.getWindowState().equals(WindowState.MAXIMIZED)) {
156:                    appendMaxAttribute(prefs, content, "HEIGHT");
157:                    appendMaxAttribute(prefs, content, "WIDTH");
158:                    appendMaxAttribute(prefs, content, "SCROLLING");
159:                    appendMaxAttribute(prefs, content, "STYLE");
160:                } else {
161:                    appendAttribute(prefs, content, "HEIGHT");
162:                    appendAttribute(prefs, content, "WIDTH");
163:                    appendAttribute(prefs, content, "SCROLLING");
164:                    appendAttribute(prefs, content, "STYLE");
165:                }
166:                content.append(">");
167:                content.append("<P STYLE=\"textAlign:center\"><A HREF=\"")
168:                        .append(source).append("\">").append(source).append(
169:                                "</A></P>");
170:                content.append("</IFRAME>");
171:
172:                // end fix JS2-349
173:                content.append("</TD></TR></TBODY></TABLE>");
174:
175:                // set required content type and write HTML IFRAME content
176:                response.setContentType("text/html");
177:                response.getWriter().print(content.toString());
178:            }
179:
180:            public String getURLSource(RenderRequest request,
181:                    RenderResponse response, PortletPreferences prefs) {
182:                String source = getAttributePreference(prefs, "SRC");
183:                if (source == null)
184:                    source = "";
185:                return source;
186:            }
187:
188:            /**
189:             * Save the prefs
190:             */
191:            public void processAction(ActionRequest request,
192:                    ActionResponse actionResponse) throws PortletException,
193:                    IOException {
194:                processPreferencesAction(request, actionResponse);
195:            }
196:
197:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.