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

📄 tabhreftag.java

📁 struts+spring+hibernate自创框架
💻 JAVA
字号:
package com.pegasus.framework.component.taglib.html.tabs;

import javax.servlet.jsp.JspException;

import org.apache.struts.Globals;

import com.pegasus.framework.component.taglib.util.BaseBodySupportTag;
import com.pegasus.framework.component.taglib.util.JspResponseWriter;
import com.pegasus.framework.component.taglib.xml.Xhtml;

/**
 * CHIIC SYSTEMS, INC.
 * Author: RoyZ
 * Date: 2007-7-24
 * Time: 11:50:48
 */
public class TabHrefTag extends BaseBodySupportTag {

	private String id;
	private String url;
	private String target;
	private String isFrameInParentWindow = "true";
	private String bundle = Globals.MESSAGES_KEY;
	private String key = null;
	private String imgSrc = null;
	private String imgPosition = null;

	private String tabTitle;
	private TabsContainerTag tabContainer;
	private JspResponseWriter out = new JspResponseWriter();


	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getTarget() {
		return target;
	}

	public void setTarget(String target) {
		this.target = target;
	}

	public String getBundle() {
		return bundle;
	}

	public void setBundle(String bundle) {
		this.bundle = bundle;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getImgSrc() {
		return imgSrc;
	}

	public void setImgSrc(String imgSrc) {
		this.imgSrc = imgSrc;
	}

	public String getImgPosition() {
		return imgPosition;
	}

	public void setImgPosition(String imgPosition) {
		this.imgPosition = imgPosition;
	}

//	public String getFrameInParentWindow() {
//		return isFrameInParentWindow;
//	}
//
//	public void setFrameInParentWindow(String frameInParentWindow) {
//		isFrameInParentWindow = frameInParentWindow;
//	}


	public String getIsFrameInParentWindow() {
		return isFrameInParentWindow;
	}

	public void setIsFrameInParentWindow(String frameInParentWindow) {
		isFrameInParentWindow = frameInParentWindow;
	}

	public void setId(final String id) {
		this.id = id;
	}

	public String getId() {
		return id;
	}

	public void setTabTitle(final String tabTitle) {
		this.tabTitle = tabTitle;
	}

	public String getTabTitle() {
		return tabTitle;
	}

	private void addToContainerString() {
//		System.out.println("addToContainer: " + getTabsContainer() + "this : " + this.getTabTitle());


		getTabsContainer().setChildIndex(getTabsContainer().getChildIndex() + 1);
		if(this.getId().equals(getTabsContainer().getSelectedTabPaneId()))
		{
			getTabsContainer().setSelectedIndex(getTabsContainer().getChildIndex() + 1);
		}
		StringBuffer sb = getTabsContainer().getChildTab();

		JspResponseWriter outTmp = new JspResponseWriter();
		outTmp.startElement(Xhtml.Html.DIV);
		outTmp.attribute(Xhtml.Attr.ID, this.getId() + TabsContainerTag.TAB_ID_SUFFIX);
		outTmp.attribute(Xhtml.Attr.NAME, TabsContainerTag.TAB_LABLE_NAME);

		if (null != getTabsContainer().getJsTabListener() && getTabsContainer().getJsTabListener().length() > 0) {
			outTmp.attribute(Xhtml.Attr.ONCLICK,
					"tabLinkShow('" + this.getId() + "','" + getTabsContainer().TABS_NAME + "','" + this
							.getId() + TabsContainerTag.TAB_ID_SUFFIX + "','" + TabsContainerTag.TAB_LABLE_NAME + "','" + this
							.getUrl() + "','" + this.getTarget() + "','" + this
							.getIsFrameInParentWindow() + "');" + getTabsContainer().getJsTabListener().trim() + "();");
		}
		else {
			outTmp.attribute(Xhtml.Attr.ONCLICK,
					"tabLinkShow('" + this.getId() + "','" + getTabsContainer().TABS_NAME + "','" + this
							.getId() + TabsContainerTag.TAB_ID_SUFFIX + "','" + TabsContainerTag.TAB_LABLE_NAME + "','" + this
							.getUrl() + "','" + this.getTarget() + "','" + this.getIsFrameInParentWindow() + "');");
		}
		if (isSelectedTab()) {
			outTmp.attribute(Xhtml.Attr.CLASS, TabsContainerTag.TAB_CLASS_NAME + " " +
					TabsContainerTag.FOCUSED_CLASS_NAME);
		}
		else {
			outTmp.attribute(Xhtml.Attr.CLASS, TabsContainerTag.TAB_CLASS_NAME + " " +
					TabsContainerTag.UNFOCUSED_CLASS_NAME);
		}
		outTmp.startElement(Xhtml.Html.SPAN);
		outTmp.attribute(Xhtml.Attr.CLASS, TabsContainerTag.TAB_BG_LEFT_CLASS_NAME);
		outTmp.text(" ");
		outTmp.endElement(Xhtml.Html.SPAN);

		if(null!=this.getImgSrc())
		{
			outTmp.startElement(Xhtml.Html.IMG);
			outTmp.attribute(Xhtml.Attr.SRC, this.getImgSrc());
			outTmp.text(" ");
			outTmp.endElement(Xhtml.Html.IMG);
		}
		if("up".equals(this.getImgPosition()))
		{
			outTmp.startElement(Xhtml.Html.BR);
			outTmp.endElement(Xhtml.Html.BR);
		}

		if (null != this.getKey() &&
				0 < this.getKey().length()) {
			outTmp.text(getMessage(this.getKey(), true, getBundle()));
		}
		else if (null != this.getTabTitle() &&
				0 < this.getTabTitle().length()) {
			outTmp.text(this.getTabTitle());
		}
		outTmp.endElement(Xhtml.Html.DIV);
		sb.append(outTmp.getBuffer());

	}

	public int doEndTag() throws JspException {

		addToContainerString();
//		renderComponent();

		out = new JspResponseWriter();
		return EVAL_BODY_INCLUDE;
	}


	public void release() {
		tabTitle = null;
		tabContainer = null;
		out = new JspResponseWriter();
		super.release();
	}

	private boolean isSelectedTab() {
		return getTabsContainer().getChildIndex() == getTabsContainer().getSelectedIndex();
	}

	public TabsContainerTag getTabsContainer() {
		if (null == tabContainer) {
			tabContainer = (TabsContainerTag)
					findAncestorWithClass(this, TabsContainerTag.class);
		}
		return tabContainer;
	}

	public static final String PARAM_NAME_TAB_PANE_ID 
		= "orgDitchnetTabPaneId";

}

⌨️ 快捷键说明

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