Struts2

<s:select>태그 사용

gilnet 2010. 8. 27. 10:19
--java
private List<Map<String, String>> parentList = new ArrayList<Map<String, String>>();


HashMap<String, String> map;
for (int i = 0; i < objectList.size(); i++) {
        JSONObject categoryInfo = objectList.getJSONObject(i);
        map = new HashMap<String, String>();
        map.put("id", categoryInfo.getString("categoryId"));
        map.put("name", categoryInfo.getString("categoryName"));
        categoryMapList.add(map);
}

--jsp
<s:select name="parentId" id="parentId" list="parentList"  cssClass="DropDownList" listKey="%{id}" listValue="%{name}"
 headerKey="" headerValue="%{getText('common.dropdown.select')}" value="%{parentId}" required="true" />