我想在中使用枚举值<h:selectManyCheckbox>。复选框已正确填充,但是,选择一些值并提交时,其运行时类型为String,而不是枚举。我的代码:
<h:selectManyCheckbox value="#{userController.roles}" layout="pageDirection">
<f:selectItems value="#{userController.rolesSelectMany}" />
</h:selectManyCheckbox>
UserController类(SecurityRole是枚举类型):
public SelectItem[] getRolesSelectMany() {
SelectItem[] items = new SelectItem[SecurityRole.values().length];
int i = 0;
for (SecurityRole role : SecurityRole.values()) {
items[i++] = new SelectItem(role, role.toString());
}
return items;
}
public List<SecurityRole> getRoles() {
getCurrent().getRoles();
}
public void setRoles(List<SecurityRole> roles) {
getCurrent().setRoles(roles);
}
当JSF调用setRoles方法时,它包含String类型的列表,而不是enum类型的列表。有任何想法吗?谢谢!
潇潇雨雨
相关分类