Hi, i'm new to jsf (and jsp). This is my first app using eclipse 3.4, tomcat6, and jsf1.2.12. Although there has been a learning curve, but I've been picking up new knowledge everyday.
I was trying to create a check box list binding to an array of strings as data source in a jsf page, this code seems to work, but eclipse kept complain about:
"Cannot coerce type java.lang.String[] to java.lang.String, java.lang.Short,
java.lang.Character, java.lang.Boolean, java.lang.Double, java.lang.Byte, java.lang.Long,
java.lang.Float, java.lang.Integer"
the following are my codes:
test.jsf
<h:selectManyCheckbox id="chboxlist" value="#{myBean.selectedItems}">
<f:selectItems value="#{myBean.myList}"/>
</h:selectManyCheckbox>
<h:commandButton value="submit" action="#{myBean.action}" />
myBean.java
private List<SelectItem> myList; //with getter/setter
private String[] selectedItems; //with getter/setter
public MyBean(){
//pre-populate checkbox/radio/menu list
myList = new ArrayList<SelectItem>();
myList.add(new SelectItem("one", "one"));
myList.add(new SelectItem("two", "two"));
myList.add(new SelectItem("three", "three"));
}//constructor
public void action(){
for(String value : selectedItems){
System.out.println(" I picked: " + value;)
}
}//action
since eclipse complained, I must did something wrong, even hough the code above works. What else am I missing?
Thank you.