我已经采取了Collection<Edition> selectedEditions;
。当我这样迭代时:
Collection<Edition> edlist=(java.util.Collection)selectedEditions;
for(Edition ed:edlist){ // error at this line
EditionID=ed.getEditionID();
NewspaperID=ed.getNewspaper().getNewspaperID();
StateID=ed.getCity().getState().getStateID();
System.out.print("nid..........."+NewspaperID);
System.out.print("sid..........."+StateID);
}
然后它给出如下错误:java.lang.ClassCastException: java.lang.String cannot be cast to entity.Edition
my getter setter:
public Collection<Edition> getSelectedEditions() {
return selectedEditions;
}
public void setSelectedEditions(Collection<Edition> selectedEditions) {
this.selectedEditions = selectedEditions;
}
和
</h:selectManyCheckbox>
<h:dataTable id="dt1" value="#{adcreateBean.selectedEditions}" var="it" styleClass="nostyle" width="100%">
<f:facet name="header">
<h:outputText value="You have selected :" />
</f:facet>
<h:column>
<h:outputText value="#{it}" />
</h:column>
</h:dataTable>
那么,我怎样才能转换为 entity.Edition?正如在回答这个问题时所说的([我如何在 jsf 中获得多选复选框值?),我该如何转换?