selectmanycheckbox

UISelectMany on a List<T> causes java.lang.ClassCastException: java.lang.String cannot be cast to T

孤人 提交于 2019-11-26 08:35:52
问题 I am using <p:selectCheckboxMenu> on a List<Long> : <p:selectCheckboxMenu value=\"#{bean.selectedItems}\"> <f:selectItems value=\"#{bean.availableItems}\" /> </p:selectCheckboxMenu> private List<Long> selectedItems; private Map<String, Long> availableItems; When submitting the form and looping over the selected items as below, for (int i = 0; i < selectedItems.size(); i++) { Long id = selectedItems.get(i); // ... } Then I get a class cast exception: java.lang.ClassCastException: java.lang

Use enum in h:selectManyCheckbox

别说谁变了你拦得住时间么 提交于 2019-11-26 05:54:00
问题 I want to use enum values in a <h:selectManyCheckbox> . The checkboxes get populated correctly, however, when selecting some values and submitting them, their runtime type is String , and not enum. My code: <h:selectManyCheckbox value=\"#{userController.roles}\" layout=\"pageDirection\"> <f:selectItems value=\"#{userController.rolesSelectMany}\" /> </h:selectManyCheckbox> UserController class (SecurityRole is an enum type): public SelectItem[] getRolesSelectMany() { SelectItem[] items = new