001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.kernel.dao.search;
016    
017    import com.liferay.portal.kernel.servlet.PipingServletResponse;
018    
019    import javax.servlet.RequestDispatcher;
020    import javax.servlet.ServletContext;
021    import javax.servlet.http.HttpServletRequest;
022    import javax.servlet.http.HttpServletResponse;
023    import javax.servlet.jsp.PageContext;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     */
028    public class JSPSearchEntry extends SearchEntry {
029    
030            public JSPSearchEntry(String align, String valign, String path) {
031                    this(align, valign, DEFAULT_COLSPAN, path, null, null, null);
032            }
033    
034            public JSPSearchEntry(
035                    String align, String valign, int colspan, String path) {
036    
037                    this(align, valign, colspan, path, null, null, null);
038            }
039    
040            public JSPSearchEntry(
041                    String align, String valign, int colspan, String path,
042                    ServletContext servletContext, HttpServletRequest request,
043                    HttpServletResponse response) {
044    
045                    super(align, valign, colspan);
046    
047                    _path = path;
048                    _servletContext = servletContext;
049                    _request = request;
050                    _response = response;
051            }
052    
053            public String getPath() {
054                    return _path;
055            }
056    
057            public void setPath(String path) {
058                    _path = path;
059            }
060    
061            public void print(PageContext pageContext) throws Exception {
062                    if (_servletContext != null) {
063                            RequestDispatcher requestDispatcher =
064                                    _servletContext.getRequestDispatcher(_path);
065    
066                            requestDispatcher.include(
067                                    _request, new PipingServletResponse(pageContext));
068                    }
069                    else {
070                            pageContext.include(_path);
071                    }
072            }
073    
074            public Object clone() {
075                    return new JSPSearchEntry(
076                            getAlign(), getValign(), getColspan(), getPath(), _servletContext,
077                            _request, _response);
078            }
079    
080            private String _path;
081            private ServletContext _servletContext;
082            private HttpServletRequest _request;
083            private HttpServletResponse _response;
084    
085    }