gfs.tld
1.0
1.1
hyt
http://jakarta.apache.org/struts/tags-html
optionDict
com.alipay.gfs.web.jsptag.OptionDictValue
JSP
codeId
true
true
subcodeId
false
true
subsubcodeId
false
true
optionEaccount
com.alipay.gfs.web.jsptag.OptionEaccountValue
JSP
3.再次新建OptionDictValue
package com.alipay.gfs.web.jsptag;
import java.util.List;
import javax.servlet.jsp.JspException;
import org.apache.struts.taglib.html.Constants;
import org.apache.struts.taglib.html.OptionsCollectionTag;
import org.apache.struts.taglib.html.SelectTag;
import org.apache.struts.util.RequestUtils;
import org.apache.struts.util.ResponseUtils;
import com.alipay.gfs.common.GlobalVar;
import com.alipay.gfs.dao.DictDao;
import com.alipay.gfs.domain.Dict;
public class OptionDictValue extends OptionsCollectionTag {
protected String codeId = "";
protected String subcodeId = null;
protected String subsubcodeId = null;
public String getCodeId() {
return codeId;
}
public void setCodeId(String codeId) {
this.codeId = codeId;
}
public String getSubcodeId() {
return subcodeId;
}
public void setSubcodeId(String subcodeId) {
this.subcodeId = subcodeId;
}
public String getSubsubcodeId() {
return subsubcodeId;
}
public void setSubsubcodeId(String subsubcodeId) {
this.subsubcodeId = subsubcodeId;
}
public int doStartTag() throws JspException {
// Acquire the select tag we are associated with
SelectTag selectTag = (SelectTag) pageContext
.getAttribute(Constants.SELECT_KEY);
if (selectTag == null) {
JspException e = new JspException(messages
.getMessage("optionsCollectionTag.select"));
RequestUtils.saveException(pageContext, e);
throw e;
}
DictDao dao = (DictDao)GlobalVar.wac.getBean("dictDao");
Dict dict = new Dict();
dict.setCodeId(codeId);
dict.setSubcodeId(subcodeId);
dict.setSubsubcodeId(subsubcodeId);
List lstCode = dao.getCodes(dict);
StringBuffer sb = new StringBuffer();
for(int i=0; i
{
Dict dct = (Dict)lstCode.get(i);
addOption(sb, dct.getCodeName(), dct.getCodeValue(), selectTag
.isMatched(dct.getCodeValue()));
}
ResponseUtils.write(pageContext, sb.toString());
return SKIP_BODY;
}
}
4.使用标签
请选择