001: /*
002: * Copyright 2003 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: * for use in the design, construction, operation or maintenance of
035: * any nuclear facility.
036: */
037:
038: package com.sun.portal.portlet.ipc2;
039:
040: import com.sun.portal.portletappengine.ipc.PortletEvent;
041: import com.sun.portal.portletappengine.ipc.PortletEventBroker;
042:
043: import javax.portlet.ActionRequest;
044: import javax.portlet.ActionResponse;
045: import javax.portlet.GenericPortlet;
046: import javax.portlet.PortletConfig;
047: import javax.portlet.PortletContext;
048: import javax.portlet.PortletException;
049: import javax.portlet.PortletRequestDispatcher;
050: import javax.portlet.RenderRequest;
051: import javax.portlet.RenderResponse;
052: import java.io.IOException;
053:
054: /**
055: * The SearchPortlet participates in the InterPortletCommunication.
056: * This generates the event that is consumed by the ListPortlet which is in a
057: * different web application.
058: */
059: public class SearchPortlet extends GenericPortlet {
060: private PortletContext pContext;
061:
062: public void init(PortletConfig config) throws PortletException {
063: super .init(config);
064: pContext = config.getPortletContext();
065: }
066:
067: public void doView(RenderRequest request, RenderResponse response)
068: throws PortletException, IOException {
069: String contentPage = "/searchportlet/content.jsp";
070:
071: response.setContentType(request.getResponseContentType());
072: if (contentPage != null && contentPage.length() != 0) {
073: try {
074: PortletRequestDispatcher dispatcher = pContext
075: .getRequestDispatcher(contentPage);
076: dispatcher.include(request, response);
077: } catch (IOException e) {
078: throw new PortletException(
079: "JSPPortlet.doView exception", e);
080: }
081: }
082: }
083:
084: public void processAction(ActionRequest request,
085: ActionResponse actionResponse) throws PortletException,
086: java.io.IOException {
087: PortletEventBroker peb = new PortletEventBroker(request);
088: String search = null;
089: try {
090: PortletEvent pe = peb.createEvent("searchClicked");
091: Object obj = request.getParameter("search");
092: if (obj != null) {
093: search = (String) obj;
094: }
095: pe.setEventData(search);
096: pe.fire();
097: } catch (Exception e) {
098: //Do nothing!
099: }
100: actionResponse.setRenderParameter("search", search);
101: }
102: //
103: }
|