You can't use a custom type on the <h:selectOneMenu/> component (or any of the <h:selectXXXX/>) without creating a JSF Converter. Converters exist in JSF to assist with translating essentially custom or sever-side items/constructs into web page friendly/human readable formats and also to be able to save selections from the client side back to the server side. So what the error message is essentially telling you there is that it cannot make sense enough of the value 52 submitted from the client side to save it to the server side as a Category object/type
So what you're required to do is to create an implementation of a JSF converter that essentially helps JSF make sense of your Category object.
Here's a rough estimation of what you need to do:
Implement a converter for your Category type:
// You must annotate the converter as a managed bean, if you want to inject
// anything into it, like your persistence unit for example.
@ManagedBean(name = "categoryConverterBean")
@FacesConverter(value = "categoryConverter")
public class CategoryConverter implements Converter {
@PersistenceContext(unitName = "luavipuPU")
// I include this because you will need to
// lookup your entities based on submitted values
private transient EntityManager em;
@Override
public Object getAsObject(FacesContext ctx, UIComponent component,
String value) {
// This will return the actual object representation
// of your Category using the value (in your case 52)
// returned from the client side
return em.find(Category.class, new BigInteger(value));
}
@Override
public String getAsString(FacesContext fc, UIComponent uic, Object o) {
//This will return view-friendly output for the dropdown menu
return ((Category) o).getId().toString();
}
}
Reference your new converter in your <h:selectOneMenu/>
<h:selectOneMenu id="category_fk"
converter="#{categoryConverterBean}"
value="#productController.product.category_fk}"
title="Category_fk" >
<!-- DONE: update below reference to list of available items-->
<f:selectItems value="#{productController.categoryList}"
var="prodCat" itemValue="#{prodCat.category_id}"
itemLabel="#{prodCat.name}"/>
</h:selectOneMenu>
We're using the name categoryConverterBean because we want to take advantage of the entity manager trick you pulled in the converter. Any other case, you would've used the name you set on the converter annotation.