您的位置:首页 > 产品设计 > UI/UE

<html:optionsCollection />标签与LabelValueBean使用方法

2013-12-28 19:35 1296 查看
1,在jsp页面上引用:

<html:select property="bankno" styleId="bankno" styleClass="nputstyle2" onchange="doChgBankNo(this);" alt="search">

<html:optionsCollection name="bnDictionary" property="bankNoList"/>

</html:select>

这段引用的(<html:optionsCollection name="bnDictionary" property="bankNoList"/>)name=bnDictionary是通过userBean进行定义的

<jsp:useBean id="bnDictionary" class="com.myself.fund.bean.DictionaryBean" scope="application"></jsp:useBean>

2,后台java代码

bankNoList 为DictionaryBean 这个类下面的属性,返回的结果为list,list里面的值为LabelValueBean

public List getBankNoList(){

Map childMap = getChildDicMap(parentKey);

List values;

if (childMap == null){

values = new ArrayList();

}else {

values = new ArrayList(childMap.size()-1);

}

List set = Utils.getOrderedList(childMap, new Dictionary.DictionaryComporator());

values.add(new LabelValueBean(DictionaryConstants.PLEASE_SELECT, ""));

for (Iterator it = set.iterator(); it.hasNext();) {

Dictionary dictionary = (Dictionary)it.next();

String value = dictionary.getKeyValue();

if ("#".equals(value)) continue;

String label = dictionary.getKeyCaption();

values.add(new LabelValueBean(label, value));

}

return values;

}

3,在js中获取这个html:optionsCollection 里面的值

function doChgBankNo(obj) {

var selectText = obj.options[obj.selectedIndex].text;//获取lable

var selectValue = obj.options[obj.selectedIndex].value;//获取value

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐