Source Code Cross Referenced for WingSPortlet.java in  » Swing-Library » wings3 » org » wings » 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 » Swing Library » wings3 » org.wings.portlet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.wings.portlet;
002:
003:        import java.io.IOException;
004:        import java.util.HashMap;
005:        import java.util.Map;
006:
007:        import javax.portlet.ActionRequest;
008:        import javax.portlet.ActionResponse;
009:        import javax.portlet.GenericPortlet;
010:        import javax.portlet.PortletConfig;
011:        import javax.portlet.PortletContext;
012:        import javax.portlet.PortletException;
013:        import javax.portlet.PortletMode;
014:        import javax.portlet.PortletRequestDispatcher;
015:        import javax.portlet.PortletSession;
016:        import javax.portlet.RenderRequest;
017:        import javax.portlet.RenderResponse;
018:
019:        import org.apache.commons.logging.Log;
020:        import org.apache.commons.logging.LogFactory;
021:
022:        /**
023:         * 
024:         * @author <a href="mailto:marc.musch@mercatis.com">Marc Musch</a>
025:         */
026:        public class WingSPortlet extends GenericPortlet {
027:
028:            private final transient static Log log = LogFactory
029:                    .getLog(WingSPortlet.class);
030:
031:            private static final String CONFIG_WINGS_SERVLET_URL = "WingSServletURL";
032:
033:            private static final String CONFIG_VIEW_CLASS = "ViewClass";
034:
035:            private static final String CONFIG_EDIT_CLASS = "EditClass";
036:
037:            private static final String CONFIG_HELP_CLASS = "HelpClass";
038:
039:            private String wingSServletURL;
040:
041:            private String viewClass;
042:
043:            private String editClass;
044:
045:            private String helpClass;
046:
047:            public void init(PortletConfig config) throws PortletException {
048:
049:                log
050:                        .debug("WingS-Portlet-Bridge: start init(PortletConfig) for Portlet "
051:                                + config.getPortletName());
052:                super .init(config);
053:
054:                wingSServletURL = config
055:                        .getInitParameter(CONFIG_WINGS_SERVLET_URL);
056:                viewClass = config.getInitParameter(CONFIG_VIEW_CLASS);
057:                editClass = config.getInitParameter(CONFIG_EDIT_CLASS);
058:                helpClass = config.getInitParameter(CONFIG_HELP_CLASS);
059:
060:                if (viewClass == null) {
061:                    log
062:                            .error("WingS-Portlet-Bridge: the viewClass is null. Must be set in the portlet.xml");
063:                    throw new PortletException(
064:                            "WingS-Portlet-Bridge: wings-class for the view mode is null.");
065:                }
066:
067:                if (wingSServletURL == null) {
068:                    log
069:                            .error("WingS-Portlet-Bridge: the wingServletURL is null. Must be set in the portlet.xml");
070:                    throw new PortletException(
071:                            "WingS-Portlet-Bridge: wingSServletURL is null.");
072:                }
073:
074:                log.debug("WingS-Portlet-Bridge: using the url "
075:                        + wingSServletURL + " for wingSServletURL");
076:                log.debug("WingS-Portlet-Bridge: using the class " + viewClass
077:                        + " for view-mode");
078:                log.debug("WingS-Portlet-Bridge: using the class " + editClass
079:                        + " for edit-mode");
080:                log.debug("WingS-Portlet-Bridge: using the class " + helpClass
081:                        + " for help-mode");
082:                log.debug("WingS-Portlet-Bridge: ended init(PortletConfig)");
083:            }
084:
085:            protected void doEdit(RenderRequest request, RenderResponse response)
086:                    throws PortletException, IOException {
087:
088:                log.debug("WingS-Portlet-Bridge: start doEdit() "
089:                        + response.getNamespace());
090:
091:                processRendering(request, response);
092:
093:                log.debug("WingS-Portlet-Bridge: ended doEdit() "
094:                        + response.getNamespace());
095:
096:            }
097:
098:            protected void doHelp(RenderRequest request, RenderResponse response)
099:                    throws PortletException, IOException {
100:
101:                log.debug("WingS-Portlet-Bridge: start doHelp() "
102:                        + response.getNamespace());
103:
104:                processRendering(request, response);
105:
106:                log.debug("WingS-Portlet-Bridge: ended doHelp() "
107:                        + response.getNamespace());
108:
109:            }
110:
111:            protected void doView(RenderRequest request, RenderResponse response)
112:                    throws PortletException, IOException {
113:
114:                log.debug("WingS-Portlet-Bridge: start doView() "
115:                        + response.getNamespace());
116:
117:                processRendering(request, response);
118:
119:                log.debug("WingS-Portlet-Bridge: ended doView() "
120:                        + response.getNamespace());
121:
122:            }
123:
124:            public void processAction(ActionRequest request,
125:                    ActionResponse response) throws PortletException,
126:                    IOException {
127:
128:                log.debug("WingS-Portlet-Bridge: start with processAction()");
129:
130:                // store the parameters
131:                PortletSession portletSession = request.getPortletSession();
132:                Map parameters = request.getParameterMap();
133:                String portletMode = request.getPortletMode().toString();
134:                portletSession.setAttribute(portletMode + ":"
135:                        + Const.SESSION_ATTR_PARAMETERS, parameters,
136:                        PortletSession.PORTLET_SCOPE);
137:                log
138:                        .debug("WingS-Portlet-Bridge: stored parameters in sesseion under "
139:                                + portletMode
140:                                + ":"
141:                                + Const.SESSION_ATTR_PARAMETERS);
142:
143:                log.debug("WingS-Portlet-Bridge: ended processAction()");
144:            }
145:
146:            protected void processRendering(RenderRequest request,
147:                    RenderResponse response) throws PortletException,
148:                    IOException {
149:
150:                // get the parameters out of the session
151:                // parameters are set into the session through the processAction
152:                // TODO: maybe get the params directly out of the session in the servlet
153:                PortletSession portletSession = request.getPortletSession();
154:                String portletMode = request.getPortletMode().toString();
155:                String parameterAttrName = portletMode + ":"
156:                        + Const.SESSION_ATTR_PARAMETERS;
157:                Map sessionParameters = (Map) portletSession.getAttribute(
158:                        parameterAttrName, PortletSession.PORTLET_SCOPE);
159:                log
160:                        .debug("WingS-Portlet-Bridge: loaded parameters in session from "
161:                                + portletMode
162:                                + ":"
163:                                + Const.SESSION_ATTR_PARAMETERS);
164:                portletSession.removeAttribute(parameterAttrName,
165:                        PortletSession.PORTLET_SCOPE);
166:
167:                // and get the Parameters directly from the request
168:                Map requestParameters = request.getParameterMap();
169:
170:                // store all parameters in the request for the PortletSessionServlet
171:                Map allParameters = new HashMap();
172:                if (sessionParameters != null) {
173:                    allParameters.putAll(sessionParameters);
174:                }
175:                if (requestParameters != null) {
176:                    allParameters.putAll(requestParameters);
177:                }
178:                request.setAttribute(
179:                        Const.REQUEST_ATTR_PARAMETERS_FROM_ACTION_MAP,
180:                        allParameters);
181:
182:                // set the request and the response for the filter and the wings
183:                // servlets
184:                request
185:                        .setAttribute(Const.REQUEST_ATTR_RENDER_REQUEST,
186:                                request);
187:                request.setAttribute(Const.REQUEST_ATTR_RENDER_RESPONSE,
188:                        response);
189:
190:                // set the url of the wings servlet for the filter
191:                request.setAttribute(Const.REQUEST_ATTR_WINGS_SERVLET_URL,
192:                        wingSServletURL);
193:
194:                selectWingSClass(request);
195:
196:                // dispatch to the wings servlet
197:                PortletContext portletContext;
198:                PortletRequestDispatcher requestDispatcher;
199:
200:                portletContext = getPortletContext();
201:                requestDispatcher = portletContext
202:                        .getRequestDispatcher(wingSServletURL);
203:                requestDispatcher.include(request, response);
204:
205:            }
206:
207:            protected void selectWingSClass(RenderRequest request) {
208:
209:                String portletMode = request.getPortletMode().toString();
210:
211:                if (portletMode.equals(PortletMode.EDIT.toString())
212:                        && editClass != null)
213:                    request.setAttribute(Const.REQUEST_ATTR_WINGS_CLASS,
214:                            editClass);
215:                else if (portletMode.equals(PortletMode.HELP.toString())
216:                        && helpClass != null)
217:                    request.setAttribute(Const.REQUEST_ATTR_WINGS_CLASS,
218:                            helpClass);
219:                else
220:                    request.setAttribute(Const.REQUEST_ATTR_WINGS_CLASS,
221:                            viewClass);
222:            }
223:
224:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.