xhtml
<h:outputLabel for="desc" value="Tipo do Insumo:"/>
<p:selectOneMenu id="desc" style="margin-left: 10px"
value="#{InsumoBean.descricao}"
converter="">
<f:selectItem itemLabel="Selecione" itemValue="Nenhum" />
<f:selectItems value="#{InsumoBean.descrInsumo}" var="item"
itemValue="#{item}"/>
</p:selectOneMenu>
Bean
public List<SelectItem> getDescrInsumo() {
List<SelectItem> insumo = new ArrayList<SelectItem>();
List<Insumo> list = new ArrayList<Insumo>();
InsumoPG iDao = new InsumoPG();
list = iDao.listInsumoDesc();
for (int i = 0; i < list.size(); i++) {
insumo.add(new SelectItem(list.get(i).getIdInsumo(), list.get(i).getDescr()));
}
return insumo;
}
public List<SelectItem> getDescricao() {
return descricao;
}
conversor ??
package conversor;
import entidades.Insumo;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
@FacesConverter(value = "converteGrupoInsumo", forClass = Insumo.class)
public class ConverterGrupoInsumo implements Converter{
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
throw new UnsupportedOperationException("Not supported yet.");
}
}