I want to fill a selectonemenu but always I have this error :
java.lang.String cannot be cast to javax.faces.model.SelectItem
this is the code:
public class ToolsJIRA implements Serializable{
private String myChoicePeriod;
//getters and setters
}
JSF:
<h:selectOneMenu value="#{ToolsJIRA.myChoicePeriod}">
<f:selectItem itemValue="Month" value="Month"/>
<f:selectItem itemValue="Week" value="Week"/>
<f:selectItem itemValue="Year" value="Year"/>
</h:selectOneMenu>
I have found that I should write a converter but I don't Know why? beacause I have seen some example work without a converter??
thank you
Try this code in in your webpage
<h:selectOneMenu value="#{checkBoxBean.myChoicePeriod}">
<f:selectItem itemValue="Month" />
<f:selectItem itemValue="Week" />
<f:selectItem itemValue="Year" />
</h:selectOneMenu>
Do not use value attribute its inteded for different purpose
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With