Source Code Cross Referenced for TilesUtilStrutsModulesImpl.java in  » Web-Framework » struts-1.3.8 » org » apache » struts » tiles » 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 » Web Framework » struts 1.3.8 » org.apache.struts.tiles 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: TilesUtilStrutsModulesImpl.java 471754 2006-11-06 14:55:09Z husted $
003:         *
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *  http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:
022:        package org.apache.struts.tiles;
023:
024:        import java.io.IOException;
025:
026:        import javax.servlet.ServletContext;
027:        import javax.servlet.ServletException;
028:        import javax.servlet.ServletRequest;
029:        import javax.servlet.http.HttpServletRequest;
030:        import javax.servlet.http.HttpServletResponse;
031:
032:        import org.apache.struts.Globals;
033:        import org.apache.struts.config.ModuleConfig;
034:        import org.apache.struts.util.ModuleUtils;
035:
036:        /**
037:         * Implementation of TilesUtil for Struts multi modules.
038:         * Methods in this implementation are aware of the Struts module context.
039:         * <br>
040:         * <ul>
041:         * <li>The method getFactory(...) returns the factory for the current Struts
042:         * module.</li>
043:         * <li>Methods doForward() and doInclude() use their counterparts in the
044:         * current RequestProcessor (todo).</li>
045:         * <li>The method createFactory(...) creates a factory for the current module and
046:         * stores it under the appropriate property name.</li>
047:         * </ul>
048:         */
049:        public class TilesUtilStrutsModulesImpl extends TilesUtilStrutsImpl {
050:
051:            /**
052:             * Do a forward using request dispatcher.
053:             *
054:             * This method is used by the Tiles package anytime a forward is required.
055:             * @param uri Uri or Definition name to forward.
056:             * @param request Current page request.
057:             * @param response Current page response.
058:             * @param servletContext Current servlet context.
059:             */
060:            public void doForward(String uri, HttpServletRequest request,
061:                    HttpServletResponse response, ServletContext servletContext)
062:                    throws IOException, ServletException {
063:
064:                request.getRequestDispatcher(uri).forward(request, response);
065:            }
066:
067:            /**
068:             * Do an include using request dispatcher.
069:             *
070:             * This method is used by the Tiles package anytime an include is required.
071:             * @param uri Uri or Definition name to forward.
072:             * @param request Current page request.
073:             * @param response Current page response.
074:             * @param servletContext Current servlet context.
075:             */
076:            public void doInclude(String uri, HttpServletRequest request,
077:                    HttpServletResponse response, ServletContext servletContext)
078:                    throws IOException, ServletException {
079:
080:                request.getRequestDispatcher(uri).include(request, response);
081:            }
082:
083:            /**
084:             * Get the definition factory from appropriate servlet context.
085:             * @param request Current request.
086:             * @param servletContext Current servlet context.
087:             * @return Definitions factory or null if not found.
088:             */
089:            public DefinitionsFactory getDefinitionsFactory(
090:                    ServletRequest request, ServletContext servletContext) {
091:
092:                return getDefinitionsFactory(servletContext, getModuleConfig(
093:                        (HttpServletRequest) request, servletContext));
094:            }
095:
096:            /**
097:             * Get definition factory for the module attached to specified moduleConfig.
098:             * @param servletContext Current servlet context.
099:             * @param moduleConfig Module config of the module for which the factory is requested.
100:             * @return Definitions factory or null if not found.
101:             */
102:            public DefinitionsFactory getDefinitionsFactory(
103:                    ServletContext servletContext, ModuleConfig moduleConfig) {
104:
105:                return (DefinitionsFactory) servletContext
106:                        .getAttribute(DEFINITIONS_FACTORY
107:                                + moduleConfig.getPrefix());
108:            }
109:
110:            /**
111:             * Make definition factory accessible to tags.
112:             * Factory is stored in servlet context.
113:             * @param factory Factory to be made accessible.
114:             * @param servletContext Current servlet context.
115:             */
116:            protected void makeDefinitionsFactoryAccessible(
117:                    DefinitionsFactory factory, ServletContext servletContext) {
118:
119:                String prefix = factory.getConfig().getFactoryName();
120:                servletContext.setAttribute(DEFINITIONS_FACTORY + prefix,
121:                        factory);
122:            }
123:
124:            /**
125:             * Get Tiles RequestProcessor associated to the current module.
126:             * @param request Current request.
127:             * @param servletContext Current servlet context.
128:             * @return The {@link TilesRequestProcessor} for the current request.
129:             */
130:            protected TilesRequestProcessor getRequestProcessor(
131:                    HttpServletRequest request, ServletContext servletContext) {
132:
133:                ModuleConfig moduleConfig = getModuleConfig(request,
134:                        servletContext);
135:
136:                return (TilesRequestProcessor) servletContext
137:                        .getAttribute(Globals.REQUEST_PROCESSOR_KEY
138:                                + moduleConfig.getPrefix());
139:            }
140:
141:            /**
142:             * Get the current ModuleConfig.
143:             * <br>
144:             * Lookup in the request and do selectModule if not found. The side effect
145:             * is, that the ModuleConfig object is set in the request if it was not present.
146:             * @param request Current request.
147:             * @param servletContext Current servlet context*.
148:             * @return The ModuleConfig for current request.
149:             */
150:            protected ModuleConfig getModuleConfig(HttpServletRequest request,
151:                    ServletContext servletContext) {
152:
153:                ModuleConfig moduleConfig = ModuleUtils.getInstance()
154:                        .getModuleConfig(request);
155:
156:                if (moduleConfig == null) {
157:                    // ModuleConfig not found in current request. Select it.
158:                    ModuleUtils.getInstance().selectModule(request,
159:                            servletContext);
160:                    moduleConfig = ModuleUtils.getInstance().getModuleConfig(
161:                            request);
162:                }
163:
164:                return moduleConfig;
165:            }
166:
167:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.