001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.taglib.ui;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.kernel.servlet.taglib.ui.AssetAddonEntry;
020    import com.liferay.portal.kernel.util.WebKeys;
021    import com.liferay.taglib.servlet.JspWriterHttpServletResponse;
022    import com.liferay.taglib.util.IncludeTag;
023    
024    import java.io.IOException;
025    
026    import java.util.List;
027    
028    import javax.servlet.http.HttpServletRequest;
029    import javax.servlet.http.HttpServletResponse;
030    import javax.servlet.jsp.JspException;
031    
032    /**
033     * @author Julio Camarero
034     */
035    public class AssetAddonEntryDisplayTag extends IncludeTag {
036    
037            @Override
038            public int doEndTag() throws JspException {
039                    for (AssetAddonEntry assetAddonEntry : _assetAddonEntries) {
040                            try {
041                                    assetAddonEntry.include(request, getResponse());
042                            }
043                            catch (IOException ioe) {
044                                    _log.error(ioe, ioe);
045                            }
046                    }
047    
048                    return super.doEndTag();
049            }
050    
051            public void setAssetAddonEntries(
052                    List<? extends AssetAddonEntry> assetAddonEntries) {
053    
054                    _assetAddonEntries = assetAddonEntries;
055            }
056    
057            @Override
058            protected void cleanUp() {
059                    _assetAddonEntries = null;
060            }
061    
062            protected HttpServletResponse getResponse() {
063                    return new JspWriterHttpServletResponse(pageContext);
064            }
065    
066            @Override
067            protected void setAttributes(HttpServletRequest request) {
068                    request.setAttribute(WebKeys.ASSET_ADDON_ENTRIES, _assetAddonEntries);
069            }
070    
071            private static final Log _log = LogFactoryUtil.getLog(
072                    AssetAddonEntryDisplayTag.class);
073    
074            private List<? extends AssetAddonEntry> _assetAddonEntries;
075    
076    }