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

📄 basebindingtag.java

📁 这是一个轻便的j2ee的web应用框架,是一个在多个项目中运用的实际框架,采用struts,hebinate,xml等技术,有丰富的tag,role,navigation,session,dictio
💻 JAVA
字号:
/*
 * Created on 2004-8-22
 *
 */
package com.esimple.framework.web.taglib.database;

import java.util.List;

import javax.servlet.jsp.JspException;

import org.apache.struts.util.RequestUtils;

import com.esimple.framework.util.StringUtils;
import com.esimple.framework.web.taglib.html.BaseHandlerTag;
import com.esimple.framework.bean.BeanContainerFactory;
import com.esimple.framework.dao.ibatis.ISqlMapClientDao;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
 * @author steven
 *
 */
public class BaseBindingTag extends BaseHandlerTag {
	protected String statement = null;
	protected String daoName = null;
	protected String parameter= null;
	protected String defalutValue= null;
	protected String defalutBean= null;
	protected String[] defaults;
	protected String valueName= null;
	protected String labelName= null;	
	
	protected Log logger = LogFactory.getLog(this.getClass());	
			
	public String getStatement() {
		return (this.statement);
	}
	
	public void setStatement(String statement) {
		this.statement = statement;
	}	
	
	public String getParameter() {
		return (this.parameter);
	}
	
	public void setParameter(String parameter) {
		this.parameter = parameter;
	}	

	public String getDaoName() {
		return (this.daoName);
	}
	
	public void setDaoName(String daoName) {
		this.daoName = daoName;
	}

	public String getValueName() {
		return (this.valueName);
	}
	
	public void setValueName(String valueName) {
		this.valueName = valueName;
	}

	public String getLabelName() {
		return (this.labelName);
	}
	
	public void setLabelName(String labelName) {
		this.labelName = labelName;
	}
	
	public String getDefalutValue() {
		return (this.defalutValue);
	}
	
	public void setDefalutValue(String defalutValue) {
		this.defalutValue = defalutValue;
		if( defalutValue!= null ){
			defaults = StringUtils.split(defalutValue,",",true,true);
		}
	}
	
	public String getDefalutBean() {
		return (this.defalutBean);
	}
	
	public void setDefalutBean(String defalutBean) {
		this.defalutBean = defalutBean;
	}	
	
	protected String scope = null;

	public String getScope() {
		return (this.scope);
	}

	public void setScope(String scope) {
		this.scope = scope;
	}
	
	protected String name = null;

	public String getName() {
		return (this.name);
	}

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

		if( statement == null ) return null;
		
		Object value=null;
		try {
			if( parameter != null ){
				value =RequestUtils.lookup(pageContext, parameter,scope);
			}
		} catch (JspException e) {
			e.printStackTrace();
		}
        
        if( daoName == null ) daoName = ISqlMapClientDao.DEFAULT_DAO;
		
		ISqlMapClientDao dao = (ISqlMapClientDao)
			BeanContainerFactory.getBeanContainer()
				.getBean( daoName );
				
		if( dao == null )	{	
			logger.error("can not find dao with name:" + daoName);
			return null;	
		}
		return dao.query(statement,value);
	}
	
	protected boolean isDefault(String value){
		if ( defaults == null ) return false;
		for( int i=0;i< defaults.length;i++ ){
			if( defalutBean == null ){
				if( value.equals(defaults[i]) ) return true;
			}else{
				Object getValue=null;
				try {
					getValue = RequestUtils.lookup(pageContext, name, defaults[i], scope);
				} catch (JspException e) {
				}
				if( getValue == null ) return false;
				if( value.equals(getValue) ) return true;
			}
				
		}
		return false;
	}
}

⌨️ 快捷键说明

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