java.lang.ClassCastException:java.lang.String无法强制转换为javax.faces.model.SelectItem

时间:2017-11-06 17:09:29

标签: java jsf primefaces

我正在尝试从oneSelectMenu获取itemValue,但此异常已返回。 有谁可以帮助我?

<p:outputLabel for="tipo" value="Tipo "/>
                    <p:selectOneMenu id="tipo" value="#{pessoaBean.pessoa.tipo}">
                        <f:selectItem itemLabel="Cliente" itemValue="Cliente"/>
                        <f:selectItem itemLabel="Funcionário" itemValue="Funcionário"/>
                    </p:selectOneMenu>

1 个答案:

答案 0 :(得分:0)

也许您必须实现javax.faces.Converter并将属性converter="..."添加到p:selectOneMenu

请参阅示例How to inject @EJB, @PersistenceContext, @Inject, @Autowired, etc in @FacesConverter?