When I set the variable in my bean, the conversion is OK. Look the variables in the Image:
When I use xhtml to set a variable, UI:repeat + p:selectCheckboxMenu I received this error:
/* Caused by: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.util.List */
Look the variables:
In my JSF I have:
<ui:repeat var="q" value="#{bean.questions}">
<p:selectCheckboxMenu converter="javax.faces.Integer" filter="true"
value="#{bean.selectedDinamicRoadmap[q.id]}">
<f:selectItems value="#{bean.roadmaps}" var="roadm" itemLabel="#{roadm.description} " itemValue="#{roadm.id}" />
</p:selectCheckboxMenu>
</ui:repeat>
And in my bean I need save a selectedDinamicRoadmap[] And look my code for this:
private Map<Integer, List<Integer>> selectedDinamicRoadmap = new HashMap<Integer, List<Integer>>();
//gets and sets
public void save() {
for (Entry<Integer, List<Integer>> ee : selectedDinamicRoadmap.entrySet()) {
Integer key = ee.getKey();
List<Integer> values = ee.getValue(); /* Caused by: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.util.List */
for (Integer id : values) {
//saveData
}
}
}
how could I fix this? Or what`s the best solution for this?
I have tried:
List<Integer> values = ee.getValue();
List<String> values = ee.getValue();
Integer[] values = ee.getValue();
String[] values = ee.getValue();
Object[] values = ee.getValue();// <- It is working : WHY?
of course changing the necessary code.