⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tabheadingstag.java

📁 这是linux下ssl vpn的实现程序
💻 JAVA
字号:
/*
 *  SSL-Explorer
 *
 *  Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2 of
 *  the License, or (at your option) any later version.
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public
 *  License along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
			
package com.sslexplorer.tabs.tags;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;

import org.apache.struts.taglib.TagUtils;

import com.sslexplorer.tabs.TabModel;

/**
 * Custom tag to render HTML that displays a row of tabs retrieved from
 * a {@link com.sslexplorer.tabs.TabModel}.
 * <p>
 * This tag takes no attributes as it derives all of its attributes from
 * the &lt;tabSet&gt; tag that is must be insed.
 * 
 * @author Brett Smith <a href="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
 * @version $Revision: 1.9 $
 * @see com.sslexplorer.tabs.tags.TabSetTag
 */
public class TabHeadingsTag extends BodyTagSupport {
    
    // Protected instance variables
    
    protected String text;

    /* (non-Javadoc)
     * @see org.apache.struts.taglib.html.BaseFieldTag#doStartTag()
     */
    public int doStartTag() throws JspException {
        Object value = findAncestorWithClass(this, TabSetTag.class);
        if (value == null) {
            throw new JspException("TabHeadingsTag must be contained in a TabSetTag");
        }
        TabModel model = ((TabSetTag)value).getModel();
        String bundle = ((TabSetTag)value).getBundle();
        String locale = ((TabSetTag)value).getLocale();
        String selectedTab = model.getSelectedTab();
        String resourcePrefix =  ((TabSetTag)value).getResourcePrefix();
        StringBuffer buf = new StringBuffer();
        buf.append("<div class=\"tabHeadings\"><ul>");
        for(int i = 0 ; i < model.getTabCount(); i++) {
            String tabName = model.getTabName(i);
            String tabTitle = model.getTabTitle(i);
            String tabBundle = model.getTabBundle(i);
            buf.append("<li id=\"tab_item_");
            buf.append(tabName);
            buf.append("\" class=\"");
            if(selectedTab == null) {
                buf.append(i == 0 ? "selectedTab" : "hiddenTab");
            }
            else {
                buf.append(selectedTab.equals(tabName) ? "selectedTab" : "hiddenTab");
            }
            buf.append("\"><a id=\"tab_link_");
            buf.append(tabName);
            buf.append("\" ");
            if(selectedTab == null) {
                buf.append(i == 0 ? "class=\"currentTab\" " : "");
            }
            else {
                buf.append(selectedTab.equals(tabName) ? "class=\"currentTab\" " : "");                
            }
            int idx = 0;
            buf.append("onclick=\"javascript: var deselect = new Array();");
            for(int j = 0 ; j < model.getTabCount(); j++) {
                String tn = model.getTabName(j);
                boolean s =  tabName.equals(tn);
                if(!s) {
                    buf.append("deselect[");
                    buf.append(idx++);
                    buf.append("]='");
                    buf.append(tn);
                    buf.append("';");
                }
            }
            buf.append("setSelectedTab('");
            buf.append(tabName);
            buf.append("',deselect);\" href=\"#\">");
            if(tabTitle == null) {
                tabTitle = 
                    TagUtils.getInstance().message(
                        pageContext,
                        tabBundle == null ? bundle : tabBundle,
                        locale,
                        resourcePrefix + "." + tabName + ".title",
                        new String[] { });
            }
            buf.append(tabTitle == null? tabName : tabTitle);
            buf.append("</a></li>");
        }
        buf.append("</ul></div>");
        text = buf.toString();
        return (SKIP_BODY);
    }

    /* (non-Javadoc)
     * @see javax.servlet.jsp.tagext.BodyTagSupport#doEndTag()
     */
    public int doEndTag() throws JspException {
        TagUtils.getInstance().write(this.pageContext, text);        
        return EVAL_PAGE;
    }
    

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -