Source Code Cross Referenced for RegionTagHandler.java in  » Portal » jboss-portal-2.6.4 » org » jboss » portal » theme » tag » 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 » jboss portal 2.6.4 » org.jboss.portal.theme.tag 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /******************************************************************************
002:         * JBoss, a division of Red Hat                                               *
003:         * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
004:         * contributors as indicated by the @authors tag. See the                     *
005:         * copyright.txt in the distribution for a full listing of                    *
006:         * individual contributors.                                                   *
007:         *                                                                            *
008:         * This is free software; you can redistribute it and/or modify it            *
009:         * under the terms of the GNU Lesser General Public License as                *
010:         * published by the Free Software Foundation; either version 2.1 of           *
011:         * the License, or (at your option) any later version.                        *
012:         *                                                                            *
013:         * This software is distributed in the hope that it will be useful,           *
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
016:         * Lesser General Public License for more details.                            *
017:         *                                                                            *
018:         * You should have received a copy of the GNU Lesser General Public           *
019:         * License along with this software; if not, write to the Free                *
020:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
021:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
022:         ******************************************************************************/package org.jboss.portal.theme.tag;
023:
024:        import org.jboss.logging.Logger;
025:        import org.jboss.portal.theme.LayoutConstants;
026:        import org.jboss.portal.theme.Orientation;
027:        import org.jboss.portal.theme.impl.JSPRendererContext;
028:        import org.jboss.portal.theme.render.RenderException;
029:        import org.jboss.portal.theme.render.renderer.PageRendererContext;
030:        import org.jboss.portal.theme.render.renderer.RegionRendererContext;
031:
032:        import javax.servlet.http.HttpServletRequest;
033:        import javax.servlet.jsp.JspException;
034:        import javax.servlet.jsp.JspWriter;
035:        import javax.servlet.jsp.PageContext;
036:        import javax.servlet.jsp.tagext.SimpleTagSupport;
037:        import java.io.IOException;
038:        import java.io.PrintWriter;
039:        import java.util.Collection;
040:        import java.util.Collections;
041:        import java.util.Map;
042:
043:        /**
044:         * Tag handler for the region tag. <p>A region represents a subsection of a portal page. A region can host several
045:         * portlets. The portlets can be arranged horizontally or vertically. The region tag utilizes a render set to create the
046:         * markup around the individual portlets.</p>
047:         *
048:         * @author <a href="mailto:mholzner@novell.com>Martin Holzner</a>
049:         * @author <a href="mailto:roy@jboss.org>Roy Russo</a>
050:         * @version $LastChangedRevision: 8784 $, $LastChangedDate: 2007-10-27 19:01:46 -0400 (Sat, 27 Oct 2007) $
051:         * @see org.jboss.portal.theme.PortalRenderSet
052:         */
053:        public class RegionTagHandler extends SimpleTagSupport {
054:            private static Logger log = Logger
055:                    .getLogger(RegionTagHandler.class);
056:            //default to vertical
057:
058:            private Orientation regionOrientation;
059:            private String regionName = null;
060:            private String regionCssId = null;
061:
062:            /**
063:             * create the markup of this tag
064:             *
065:             * @throws JspException
066:             * @throws IOException
067:             */
068:            public void doTag() throws JspException, IOException {
069:                if (regionCssId == null) {
070:                    regionCssId = regionName;
071:                }
072:                log.debug("rendering " + regionName + " [" + regionOrientation
073:                        + "]  cssId[" + regionCssId + "]");
074:
075:                // get page and region
076:                PageContext app = (PageContext) getJspContext();
077:                HttpServletRequest request = (HttpServletRequest) app
078:                        .getRequest();
079:
080:                PageRendererContext page = (PageRendererContext) request
081:                        .getAttribute(LayoutConstants.ATTR_PAGE);
082:                JspWriter out = this .getJspContext().getOut();
083:                if (page == null) {
084:                    out.write("<p bgcolor='red'>No page to render!</p>");
085:                    out
086:                            .write("<p bgcolor='red'>The page to render (PageResult) must be set in the request attribute '"
087:                                    + LayoutConstants.ATTR_PAGE + "'</p>");
088:                    out.flush();
089:                    return;
090:                }
091:
092:                final String cssId = regionCssId == null ? regionName
093:                        : regionCssId;
094:                final Orientation orientation = this .regionOrientation == null ? Orientation.DEFAULT
095:                        : this .regionOrientation;
096:
097:                if (page.getRegion(regionName) == null) // non-window display of content
098:                {
099:                    // Create a dummy region obj, based on region name
100:                    RegionRendererContext rrc = new RegionRendererContext() {
101:                        public String getId() {
102:                            return regionName;
103:                        }
104:
105:                        public Collection getWindows() {
106:                            return Collections.EMPTY_LIST;
107:                        }
108:
109:                        public PageRendererContext getPage() {
110:                            return null;
111:                        }
112:
113:                        public Orientation getOrientation() {
114:                            return orientation;
115:                        }
116:
117:                        public String getCSSId() {
118:                            return cssId;
119:                        }
120:
121:                        public String getProperty(String name) {
122:                            return null;
123:                        }
124:
125:                        public Map getProperties() {
126:                            return Collections.EMPTY_MAP;
127:                        }
128:                    };
129:
130:                    JSPRendererContext renderContext = (JSPRendererContext) request
131:                            .getAttribute(LayoutConstants.ATTR_RENDERCONTEXT);
132:                    try {
133:                        PrintWriter pw = new PrintWriter(out);
134:                        renderContext.setWriter(pw);
135:                        renderContext.render(rrc);
136:                        pw.flush();
137:                    } catch (RenderException e) {
138:                        throw new JspException(e);
139:                    }
140:                } else {
141:                    // window-centric display of content
142:                    JSPRendererContext renderContext = (JSPRendererContext) request
143:                            .getAttribute(LayoutConstants.ATTR_RENDERCONTEXT);
144:                    if (renderContext == null) {
145:                        log.debug("no render context available in request");
146:                        return;
147:                    }
148:
149:                    final RegionRendererContext region = page
150:                            .getRegion(regionName);
151:                    RegionRendererContext rrc = new RegionRendererContext() {
152:                        public String getId() {
153:                            return region.getId();
154:                        }
155:
156:                        public Collection getWindows() {
157:                            return region.getWindows();
158:                        }
159:
160:                        public Orientation getOrientation() {
161:                            return orientation;
162:                        }
163:
164:                        public String getCSSId() {
165:                            return cssId;
166:                        }
167:
168:                        public String getProperty(String name) {
169:                            return region.getProperty(name);
170:                        }
171:
172:                        public Map getProperties() {
173:                            return region.getProperties();
174:                        }
175:                    };
176:                    try {
177:                        PrintWriter pw = new PrintWriter(out);
178:                        renderContext.setWriter(pw);
179:                        renderContext.render(rrc);
180:                        pw.flush();
181:                    } catch (RenderException e) {
182:                        throw new JspException(e);
183:                    }
184:
185:                    log
186:                            .debug("done rendering page region [" + regionName
187:                                    + "]");
188:                }
189:            }
190:
191:            // ------ attribute handlers
192:
193:            /**
194:             * Attribute handler for the orientation attribute of this tag
195:             *
196:             * @param orientation the orientation attribute value set in the hosting jsp
197:             */
198:            public void setOrientation(String orientation) {
199:                if (orientation == null) {
200:                    log.error("no null value allowed");
201:                }
202:
203:                try {
204:                    this .regionOrientation = Orientation.parse(orientation);
205:                } catch (IllegalArgumentException e) {
206:                    log.error(e);
207:                    this .regionOrientation = Orientation.DEFAULT;
208:                }
209:            }
210:
211:            /**
212:             * Attribute handler for the region name attribute of this tag
213:             *
214:             * @param regionName the name of the region this tag should render the markup for
215:             */
216:            public void setRegionName(String regionName) {
217:                this .regionName = regionName;
218:            }
219:
220:            /**
221:             * Attribute handler for the region id attribute of this tag <p>The region Id can be used as the value of the id
222:             * attribute of the region container tag. In case of the DivRenderer render set, this is the id attribute of the div
223:             * tag that represents this region on the page.</p>
224:             *
225:             * @param regionID the id attribute value to set for this tag
226:             */
227:            public void setRegionID(String regionID) {
228:                this.regionCssId = regionID;
229:            }
230:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.