mirror of
https://github.com/apache/struts.git
synced 2026-08-07 23:57:03 +00:00
WW-3912 adds proper support for checked attribute
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@1436650 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
+15
-1
@@ -68,7 +68,7 @@ public class CheckboxListHandler extends AbstractTagHandler implements TagGenera
|
||||
a.add("type", "checkbox")
|
||||
.add("name", name)
|
||||
.add("value", itemKeyStr)
|
||||
.addIfTrue("checked", params.get("nameValue"))
|
||||
.addIfTrue("checked", isChecked(params, itemKeyStr))
|
||||
.addIfTrue("readonly", params.get("readonly"))
|
||||
.addIfTrue("disabled", disabled)
|
||||
.addIfExists("tabindex", params.get("tabindex"))
|
||||
@@ -101,4 +101,18 @@ public class CheckboxListHandler extends AbstractTagHandler implements TagGenera
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean isChecked(Map<String, Object> params, String itemKeyStr) {
|
||||
Boolean checked = false;
|
||||
if (itemKeyStr != null) {
|
||||
String[] nameValues = (String[]) params.get("nameValue");
|
||||
for (String value : nameValues) {
|
||||
if (checked = value.equalsIgnoreCase(itemKeyStr)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return checked;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user