1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.kernel.dao.search;
16  
17  import com.liferay.portal.kernel.servlet.StringServletResponse;
18  
19  import javax.servlet.RequestDispatcher;
20  import javax.servlet.ServletContext;
21  import javax.servlet.http.HttpServletRequest;
22  import javax.servlet.http.HttpServletResponse;
23  import javax.servlet.jsp.PageContext;
24  
25  /**
26   * <a href="JSPSearchEntry.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   */
30  public class JSPSearchEntry extends SearchEntry {
31  
32      public JSPSearchEntry(String align, String valign, String path) {
33          this(align, valign, DEFAULT_COLSPAN, path, null, null, null);
34      }
35  
36      public JSPSearchEntry(
37          String align, String valign, int colspan, String path) {
38  
39          this(align, valign, colspan, path, null, null, null);
40      }
41  
42      public JSPSearchEntry(
43          String align, String valign, int colspan, String path,
44          ServletContext servletContext, HttpServletRequest request,
45          HttpServletResponse response) {
46  
47          super(align, valign, colspan);
48  
49          _path = path;
50          _servletContext = servletContext;
51          _request = request;
52          _response = response;
53      }
54  
55      public String getPath() {
56          return _path;
57      }
58  
59      public void setPath(String path) {
60          _path = path;
61      }
62  
63      public void print(PageContext pageContext) throws Exception {
64          if (_servletContext != null) {
65              RequestDispatcher requestDispatcher =
66                  _servletContext.getRequestDispatcher(_path);
67  
68              StringServletResponse stringResponse = new StringServletResponse(
69                  _response);
70  
71              requestDispatcher.include(_request, stringResponse);
72  
73              pageContext.getOut().print(stringResponse.getString());
74          }
75          else {
76              pageContext.include(_path);
77          }
78      }
79  
80      public Object clone() {
81          return new JSPSearchEntry(
82              getAlign(), getValign(), getColspan(), getPath(), _servletContext,
83              _request, _response);
84      }
85  
86      private String _path;
87      private ServletContext _servletContext;
88      private HttpServletRequest _request;
89      private HttpServletResponse _response;
90  
91  }