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

📄 tagdictionary.java

📁 数据字典 TAG标签 用于支持数据对照 支持各种radio check list显示
💻 JAVA
字号:
package com.beiktech.tag;

import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;
import com.beiktech.hib.po.SjzdPo;

public class TagDictionary extends TagSupport{
	
	private String type;						 //输出内容的显示格式
	private String value;						 //输入选项
	private String name;						 //输出选项名称
	private String body;						 //页面显示的内容
	private String checked;						 // 是否选中
	private String root;	
	
	

	public int doStartTag(){	
		try{
			JspWriter out = pageContext.getOut();
			SjzdPo sp = null;
			if(root == null){
				sp =(SjzdPo)TagLoad.getInstance().getObTh().get(name+"_ROOT");
			}else{
				sp =(SjzdPo)TagLoad.getInstance().getObTh().get(name+"_"+root);
			}
			
			List obList=sp.getChildList();
			System.out.println(obList);
			Iterator obi = obList.iterator();
			if(type.equalsIgnoreCase("SELECT")){
				this.selectShow(obi, out);
			}else if(type.equalsIgnoreCase("SELECTED")){
				this.selectCheckedShow(obi, out);
			}else if(type.equalsIgnoreCase("OPTION")){
				this.optionShow(obi, out);
			}else if(type.equalsIgnoreCase("OPTIONED")){
					this.optionCheckedShow(obi, out);
			}else if(type.equalsIgnoreCase("RADIO")){
				this.radioShow(obi, out);
			}else if(type.equalsIgnoreCase("RADIOED")){
				this.radioCheckedShow(obi, out);
			}else if(type.equalsIgnoreCase("CHECKBOX")){
				this.checkBoxShow(obi, out);
			}else if(type.equalsIgnoreCase("CHECKBOXED")){
					this.checkBoxCheckedShow(obi, out);
			}else if(type.equalsIgnoreCase("NORMAL")){
				this.normalShow(obi, out);
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		 return SKIP_BODY;
	}
	
	public int doEndTag(){
		try{
			
		}catch(Exception e){
			e.printStackTrace();
		}
		 return SKIP_BODY;
	}
	
	public void normalShow(Iterator  obi,JspWriter out){   //普通格式1
		try {
			while(obi.hasNext()){
				SjzdPo sp = (SjzdPo)obi.next();
				if(value.equalsIgnoreCase(sp.getCode())){
					out.println(sp.getName());
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	public void selectCheckedShow(Iterator  obi,JspWriter out){    //下拉列表格式(有选中项的)2
		try {
			out.println("<select name='"+name+"'>");
			while(obi.hasNext()){
				SjzdPo sp = (SjzdPo)obi.next();
				if(checked.equalsIgnoreCase(sp.getCode())){
					out.println("<option value='"+sp.getCode()+"' checked>"+sp.getName()+"</option>");
				}else{
					out.println("<option value='"+sp.getCode()+"'>"+sp.getName()+"</option>");;
				}
			}
			out.println("</select>");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public void selectShow(Iterator  obi,JspWriter out){    //下拉列表格式3
		try {
			out.println("<select name='"+name+"'>");
			out.println("<option value=''>请选择</option>");
			while(obi.hasNext()){
				SjzdPo sp = (SjzdPo)obi.next();
				out.println("<option value='"+sp.getCode()+"'>"+sp.getName()+"</option>");
			}
			out.println("</select>");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	public void radioCheckedShow(Iterator  obi,JspWriter out){     //单选格式(有选中项的)4
		try {
			while(obi.hasNext()){
				SjzdPo tp = (SjzdPo)obi.next();
				if(checked.equalsIgnoreCase(tp.getCode())){
					out.println("<input type='radio' name='"+name+"'value='"+tp.getCode()+"' checked/>"+tp.getName());
				}else{
					out.println("<input type='radio' name='"+name+"'value='"+tp.getCode()+"'/>"+tp.getName());
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	public void radioShow(Iterator  obi,JspWriter out){     //单选格式5
		try {
			while(obi.hasNext()){
				SjzdPo tp = (SjzdPo)obi.next();
				out.println("<input type='radio' name='"+name+"'value='"+tp.getCode()+"'/>"+tp.getName());
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public void checkBoxCheckedShow(Iterator  obi,JspWriter out){     //复选格式(有选中项的)6
		try {
			while(obi.hasNext()){
				SjzdPo sp = (SjzdPo)obi.next();
				//BJS,HUBEI
				if(checked.toUpperCase().indexOf(sp.getCode().toUpperCase())!=-1){   ;//checked.equalsIgnoreCase(sp.getCode())){
					out.println("<input type='checkbox' name='"+name+"'value='"+sp.getCode()+"' checked/>"+sp.getName());
				}else{
					out.println("<input type='checkbox' name='"+name+"'value='"+sp.getCode()+"'/>"+sp.getName());
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public void checkBoxShow(Iterator  obi,JspWriter out){     //复选格式7
		try {
			while(obi.hasNext()){
				SjzdPo tp = (SjzdPo)obi.next();
				out.println("<input type='checkbox' name='"+name+"'value='"+tp.getCode()+"'/>"+tp.getName());
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	public void optionCheckedShow(Iterator  obi,JspWriter out){        //下拉列表选项格式(有选中项的)8
		try {
			while(obi.hasNext()){
				SjzdPo sp = (SjzdPo)obi.next();
//				BJS,HUBEI
				if(checked.toUpperCase().indexOf(sp.getCode().toUpperCase())!=-1){   ;//checked.equalsIgnoreCase(sp.getCode())){
					out.println("<option value='"+sp.getCode()+"' checked>"+sp.getName()+"</option>");
				}else{
					out.println("<option value='"+sp.getCode()+"'>"+sp.getName()+"</option>");;
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public void optionShow(Iterator  obi,JspWriter out){        //下拉列表选项格式9
		try {
			out.println("<option value=''>请选择</option>");
			while(obi.hasNext()){
				SjzdPo tp = (SjzdPo)obi.next();
				out.println("<option value='"+tp.getCode()+"'>"+tp.getName()+"</option>");
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public String getBody() {
		return body;
	}

	public void setBody(String body) {
		this.body = body;
	}

	public String getChecked() {
		return checked;
	}

	public void setChecked(String checked) {
		this.checked = checked;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getRoot() {
		return root;
	}

	public void setRoot(String root) {
		this.root = root;
	}
	
}

⌨️ 快捷键说明

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