📄 dictwritetag.java
字号:
/*
* Created on 2004-3-25
*
*/
package com.esimple.service.dict.taglib;
import com.esimple.service.dict.*;
import javax.servlet.jsp.JspException;
import com.esimple.framework.web.init.ESimplePlugIn;
import org.springframework.beans.factory.*;
import org.apache.struts.util.RequestUtils;
import org.apache.struts.util.ResponseUtils;
import com.esimple.framework.web.taglib.bean.WriteTag;
/**
* @author steven
*
*/
public class DictWriteTag extends WriteTag {
private BeanFactory factory;
private DictManager dicM;
private String dictType;
private String value;
private void init(){
factory =(BeanFactory) pageContext.getServletContext()
.getAttribute(ESimplePlugIn.BEAN_FACTORY);
dicM = (DictManager)factory.getBean(DictManager.BEAN_CONFIG_NAME);
}
public void setDictType(String dictType){
this.dictType = dictType;
}
public String getDictType(){
return this.dictType;
}
public void setValue(String value){
this.value = value;
}
public String getValue(){
return this.value;
}
public int doStartTag() throws JspException {
if( property != null ){
try{
if ( ignore && name!= null ) {
if (RequestUtils.lookup(pageContext, name, scope) == null)
return (SKIP_BODY); // Nothing to output
}
Object pvalue =
RequestUtils.lookup(pageContext, name, property, scope);
if ( pvalue == null) return (SKIP_BODY);
value = pvalue.toString() ;
}catch(JspException e){
if( value == null )throw e;
}
}else if( value == null){
return (SKIP_BODY);
}
String output = formatValue( value );
ResponseUtils.write(pageContext, output);
return (SKIP_BODY);
}
protected String formatValue(Object valueToFormat) throws JspException {
String value =valueToFormat.toString() ;
if( dicM == null )init();
if( dicM == null) return value;
String result = dicM.getDictContent(dictType,value);
if( result == null ) return value;
else return result;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -