java messagetag_Struts自定义标签tag

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.使用标签

请选择

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值