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.language.LanguageUtil;
018    import com.liferay.portal.kernel.util.StringUtil;
019    import com.liferay.taglib.FileAvailabilityUtil;
020    import com.liferay.taglib.util.TagResourceBundleUtil;
021    
022    import java.util.ResourceBundle;
023    
024    import javax.servlet.http.HttpServletRequest;
025    
026    /**
027     * @author Scott Lee
028     * @author Shuyang Zhou
029     */
030    public class IconHelpTag extends IconTag {
031    
032            @Override
033            protected String getPage() {
034                    if (FileAvailabilityUtil.isAvailable(servletContext, _PAGE)) {
035                            return _PAGE;
036                    }
037                    else {
038                            return null;
039                    }
040            }
041    
042            @Override
043            protected void setAttributes(HttpServletRequest request) {
044                    request.setAttribute("liferay-ui:icon-help:id", StringUtil.randomId());
045    
046                    ResourceBundle resourceBundle = TagResourceBundleUtil.getResourceBundle(
047                            pageContext);
048    
049                    String message = LanguageUtil.get(resourceBundle, getMessage());
050    
051                    request.setAttribute("liferay-ui:icon-help:message", message);
052    
053                    super.setAttributes(request);
054            }
055    
056            private static final String _PAGE = "/html/taglib/ui/icon_help/page.jsp";
057    
058    }