001    /**
002     * Copyright (c) 2000-2012 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.taglib.ui;
016    
017    import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
018    
019    import javax.servlet.http.HttpServletRequest;
020    
021    /**
022     * @author Brian Wing Shun Chan
023     */
024    public class SearchIteratorTag<R> extends SearchPaginatorTag<R> {
025    
026            public void setPaginate(boolean paginate) {
027                    _paginate = paginate;
028            }
029    
030            @Override
031            protected void cleanUp() {
032                    super.cleanUp();
033    
034                    _paginate = true;
035            }
036    
037            @Override
038            protected String getPage() {
039                    return _PAGE;
040            }
041    
042            @Override
043            protected void include(String page) throws Exception {
044                    Thread currentThread = Thread.currentThread();
045    
046                    ClassLoader contextClassLoader = currentThread.getContextClassLoader();
047    
048                    try {
049                            currentThread.setContextClassLoader(
050                                    PortalClassLoaderUtil.getClassLoader());
051    
052                            super.include(page);
053                    }
054                    finally {
055                            currentThread.setContextClassLoader(contextClassLoader);
056                    }
057            }
058    
059            @Override
060            protected void setAttributes(HttpServletRequest request) {
061                    super.setAttributes(request);
062    
063                    request.setAttribute(
064                            "liferay-ui:search-iterator:paginate", String.valueOf(_paginate));
065            }
066    
067            private static final String _PAGE =
068                    "/html/taglib/ui/search_iterator/page.jsp";
069    
070            private boolean _paginate = true;
071    
072    }