001: /*
002: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions
006: * are met:
007: *
008: * - Redistributions of source code must retain the above copyright
009: * notice, this list of conditions and the following disclaimer.
010: *
011: * - Redistribution in binary form must reproduce the above copyright
012: * notice, this list of conditions and the following disclaimer in
013: * the documentation and/or other materials provided with the
014: * distribution.
015: *
016: * Neither the name of Sun Microsystems, Inc. or the names of
017: * contributors may be used to endorse or promote products derived
018: * from this software without specific prior written permission.
019: *
020: * This software is provided "AS IS," without a warranty of any
021: * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
022: * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
023: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
024: * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
025: * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
026: * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
027: * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
028: * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
029: * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
030: * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
031: * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
032: *
033: * You acknowledge that Software is not designed, licensed or intended
034: * any nuclear facility.
035: */
036:
037: package com.sun.portal.app.communityportlets.faces;
038:
039: import com.sun.faces.portlet.FacesPortlet;
040: import com.sun.portal.portlet.impl.PortletRequestConstants;
041: import java.io.IOException;
042: import java.net.URL;
043: import javax.portlet.ActionRequest;
044: import javax.portlet.ActionResponse;
045: import javax.portlet.Portlet;
046: import javax.portlet.PortletConfig;
047: import javax.portlet.PortletException;
048: import javax.portlet.RenderRequest;
049: import javax.portlet.RenderResponse;
050: import javax.servlet.http.HttpServletRequest;
051:
052: /**
053: *
054: * @author #ac120954
055: */
056: public class CommunityInfoFacesPortlet implements Portlet {
057: private Portlet _facesPortlet;
058: public static final String searchRequestID = "SearchResultSurveyID";
059: public static final String redirectUrl = "RedirectUrl";
060: public static final String searchRequestUrl = "SearchRequestUrl";
061:
062: /** Creates a new instance of SurveysPortlet */
063: public CommunityInfoFacesPortlet() {
064: _facesPortlet = new FacesPortlet();
065: }
066:
067: /**
068: * Initializes the survey portlet by reading any init parameters.
069: * @param portletConfig the portlet configuration
070: */
071: public void init(PortletConfig portletConfig)
072: throws PortletException {
073: _facesPortlet.init(portletConfig);
074: }
075:
076: public void processAction(ActionRequest req, ActionResponse res)
077: throws PortletException, IOException {
078: String requestUrl = req.getParameter(searchRequestUrl);
079: String redirectURL = req.getParameter(redirectUrl);
080: HttpServletRequest httpReq = (HttpServletRequest) req
081: .getAttribute(PortletRequestConstants.HTTP_SERVLET_REQUEST);
082:
083: if (requestUrl != null) {
084: req.getPortletSession().setAttribute(searchRequestUrl,
085: requestUrl);
086: if (redirectURL != null) {
087: try {
088: URL url = new URL(redirectURL);
089: res.sendRedirect(redirectURL);
090: } catch (Exception e) {
091: res.sendRedirect(httpReq.getRequestURI()
092: + redirectURL);
093: }
094:
095: }
096: return;
097: }
098: _facesPortlet.processAction(req, res);
099: }
100:
101: public void render(RenderRequest renderRequest,
102: RenderResponse renderResponse) throws PortletException,
103: IOException {
104: _facesPortlet.render(renderRequest, renderResponse);
105: }
106:
107: public void destroy() {
108: _facesPortlet = null;
109: }
110:
111: }
|