Source Code Cross Referenced for JSPSingleRenderingContainerProvider.java in  » Portal » Open-Portal » com » sun » portal » wireless » providers » containers » jsp » rendering » single » 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.providers.containers.jsp.rendering.single 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $Id: JSPSingleRenderingContainerProvider.java,v 1.7 2005/09/21 10:48:40 dg154973 Exp $
003:         * Copyright 2003 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 iPlanet
011:         * are trademarks or registered trademarks of Sun Microsystems,
012:         * Inc. in the United States and other countries.
013:         */package com.sun.portal.wireless.providers.containers.jsp.rendering.single;
014:
015:        import com.sun.portal.log.common.PortalLogger;
016:        import com.sun.portal.providers.containers.jsp.single.JSPSingleContainerProvider;
017:        import com.sun.portal.wireless.providers.rendering.RenderingUtil;
018:        import com.sun.portal.wireless.providers.containers.rendering.RenderingContainerProvider;
019:        import com.sun.portal.wireless.providers.containers.template.WirelessContainerProviderAdapter;
020:        import com.sun.portal.providers.context.ProviderContext;
021:        import com.sun.portal.providers.context.ContainerProviderContext;
022:        import com.sun.portal.providers.ProviderException;
023:        import com.sun.portal.providers.context.ProviderContextException;
024:        import javax.servlet.http.HttpServletRequest;
025:        import javax.servlet.http.HttpServletResponse;
026:
027:        import java.io.File;
028:        import java.util.ResourceBundle;
029:        import java.util.MissingResourceException;
030:        import java.util.logging.Level;
031:        import java.util.logging.Logger;
032:
033:        /**   
034:         * The <code>JSPSingleRenderingContainerProvider</code> class extends from 
035:         * the <code>JSPSingleContainerProvider</code> and overrides the 
036:         * <code>getContent, getEdit</code> and <code>getMostSpecificPath</code> 
037:         * methods of <code>JSPSingleContainerProvider</code>. This is a public class 
038:         * and can be extended to add more functionality to the provider if needed.
039:         * While creating container channels using 
040:         * <code>JSPSingleRenderingContainerProvider</code>, the channel developer has
041:         * to write a contentPage.jsp and editPage.jsp which would 
042:         * get the content from AML JSPs it has.<p>
043:         * All JSPs created for the channel should be valid AML documents.
044:         */
045:
046:        public class JSPSingleRenderingContainerProvider extends
047:                JSPSingleContainerProvider implements 
048:                RenderingContainerProvider {
049:
050:            public final static String ERROR_CHANNEL = "errorChannel";
051:            private ResourceBundle bundle = null;
052:
053:            private static Logger logger = PortalLogger
054:                    .getLogger(JSPSingleRenderingContainerProvider.class);
055:
056:            public void init(String name, HttpServletRequest req)
057:                    throws ProviderException {
058:                super .init(name, req);
059:                //Get the provider resource bundle
060:                if (bundle == null) {
061:                    bundle = getResourceBundle();
062:                }
063:            }
064:
065:            public StringBuffer getContent(HttpServletRequest req,
066:                    HttpServletResponse res) throws ProviderException {
067:                StringBuffer sb = null;
068:                try {
069:                    sb = super .getContent(req, res);
070:                    sb = renderContent(req, sb);
071:                } catch (Throwable t) {
072:                    logger.log(Level.INFO, "", t);
073:                    return handleException(req, res);
074:                }
075:                return sb;
076:            }
077:
078:            public StringBuffer getEdit(HttpServletRequest req,
079:                    HttpServletResponse res) throws ProviderException {
080:                // Set  shouldRender and isTopLevel as false for children
081:                req.setAttribute(getName() + ".shouldRender", Boolean.FALSE);
082:                req.setAttribute(getName() + ".isTopLevel", Boolean.FALSE);
083:                StringBuffer sb = null;
084:                try {
085:                    sb = super .getEdit(req, res);
086:                    sb = renderContent(req, sb);
087:                } catch (Throwable t) {
088:                    logger.log(Level.INFO, "", t);
089:                    return handleException(req, res);
090:                }
091:                return sb;
092:            }
093:
094:            /**
095:             * Exception handling method for the Rendering Container. This method 
096:             * reads the error page and passes it through the rendering engine 
097:             * and returns the resulting stringbuffer to the caller.
098:             * 
099:             * @return StringBuffer holding the channel content that is markup
100:             *         specific or AML.
101:             *
102:             * @param req  An HttpServletRequest that contains information related
103:             *             to this request for content.
104:             * @param res  An HttpServletResponse that allows the provider to
105:             *             influence the overall response for desktop page 
106:             **/
107:
108:            protected StringBuffer handleException(HttpServletRequest req,
109:                    HttpServletResponse res) {
110:
111:                StringBuffer sb = null;
112:                ContainerProviderContext cpc = (ContainerProviderContext) getProviderContext();
113:                String defErrMsg = getClass().getName()
114:                        + ".handleException(): Error while reading error page."
115:                        + " Defaulting to base error page";
116:                String defErrPg = null;
117:                try {
118:                    defErrPg = bundle.getString("defaultError");
119:                } catch (MissingResourceException mre) {
120:                    defErrPg = "";
121:                }
122:                if (defErrPg == null) {
123:                    defErrPg = "";
124:                }
125:                try {
126:                    String errorCh = getStringProperty(ERROR_CHANNEL);
127:                    if ((errorCh != null) && (errorCh.length() != 0)) {
128:                        sb = cpc.getContent(req, res, null, errorCh);
129:                    } else {
130:                        logger.info("PSMA_CSPWPCJRS0002");
131:                        // Default error page
132:                        sb = new StringBuffer(defErrPg);
133:                        sb = RenderingUtil.doRender(req, cpc, getName(), sb,
134:                                true, false);
135:                    }
136:                } catch (Throwable t) {
137:                    logger.log(Level.INFO, "PSMA_CSPWPCJRS0002", t);
138:                    // Default error page
139:                    sb = new StringBuffer(defErrPg);
140:                    try {
141:                        sb = RenderingUtil.doRender(req, cpc, getName(), sb,
142:                                true, false);
143:                    } catch (Throwable t1) {
144:                        logger.log(Level.INFO, "PSMA_CSPWPCJRS0003", t);
145:                        // Rendering is failing. Cannot do much. Return original 
146:                        //  string buffer. Device will get a compile error.
147:                        return sb;
148:                    }
149:                }
150:
151:                // Content coming back is rendered content as getContent which doesnt  
152:                //  set the parent is called. Thus error channel renders itself. 
153:                return sb;
154:            }
155:
156:            protected StringBuffer renderContent(HttpServletRequest req,
157:                    StringBuffer sb) throws ProviderException {
158:                ContainerProviderContext cpc = (ContainerProviderContext) getProviderContext();
159:                return RenderingUtil.renderContent(req, cpc, getName(), sb);
160:            }
161:
162:            protected StringBuffer renderEditContent(HttpServletRequest req,
163:                    StringBuffer sb) throws ProviderException {
164:                ContainerProviderContext cpc = (ContainerProviderContext) getProviderContext();
165:                // This is a top level container.. so shouldRender and isTopLevel 
166:                // should be true.
167:                req.setAttribute(getName() + ".shouldRender", Boolean.TRUE);
168:                req.setAttribute(getName() + ".isTopLevel", Boolean.TRUE);
169:                return RenderingUtil.renderEditContent(req, cpc, getName(), sb);
170:            }
171:
172:            /**
173:             * Gets the most specific template path for the given channel name,  
174:             * the given template name and the given filepath. The file returned may
175:             * not exist at all. If non-null, the key returned by this method will map
176:             * to the most specific template file. The file may or may not exist. It 
177:             * internally calls ProviderContext.getTemplateMostSpecificPath to get
178:             * the template path. 
179:             * 
180:             * @param pc - ProviderContext of the calling provider
181:             * @param name - Channel name
182:             * @param file - Template name
183:             * 
184:             * @return Path key to access the template
185:             */
186:            protected File getMostSpecificJSPPath(ProviderContext pc,
187:                    String name, String file) throws ProviderException {
188:                File jspPath = null;
189:                try {
190:                    jspPath = RenderingUtil.getTemplateMostSpecificPath(
191:                            (ContainerProviderContext) pc, name, file);
192:                } catch (ProviderContextException e) {
193:                    throw new ProviderException(e.getMessage());
194:                }
195:
196:                return jspPath;
197:            }
198:
199:            /**
200:             * Gets the template path for the given channel name, the given template 
201:             * name and the given filepath. If non-null, the key returned by this 
202:             * method will map to a valid template file. It internally calls 
203:             * ProviderContext.getTemplateMostSpecificPath to get the template path. 
204:             * 
205:             * @param pc - ProviderContext of the calling provider
206:             * @param name - Channel name
207:             * @param file - Template name
208:             * 
209:             * @return Path key to access the template
210:             */
211:
212:            public File getExistingJSPPath(ProviderContext pc, String name,
213:                    String file) throws ProviderException {
214:                File jspPath = null;
215:                try {
216:                    jspPath = RenderingUtil.getTemplatePath(
217:                            (ContainerProviderContext) pc, name, file);
218:                } catch (ProviderContextException e) {
219:                    throw new ProviderException(e.getMessage());
220:                }
221:
222:                return jspPath;
223:            }
224:
225:        }
w__ww_.j__a___va_2s.__c___o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.