This is the set-up: a document belongs to a category. Category is a class with an ID (Integer - auto generated), a name and a description. One category can have many documents.
A data table of documents is displayed. The category is in a selectOne and the name is displayed. This is what it looks like in the view:
<h:selectOneMenu id="category" value="#{document.category.categoryID}" required="true">
<f:selectItems value="#{categorySessionBean.categoryList}" />
</h:selectOneMenu>
categoryList = new SelectItem[categories.size()];
int i=0;
for(Category cat:categories){
categoryList(i)=new SelectItem(cat.getCategoryID(), cat.getName());
i++;
}
Take a look at the ui example