bonjour un autre problem:
<x:selectOneMenu id="menu_roles" >
<f:selectItems value="#{userForm.roles}" />
</x:selectOneMenu>
my userForm.roles get his data from an Hibernate session.
...
public List getRoles() {
List roles = null;
System.out.println("userForm.getRoles");
try {
Session session =
HibernateSessionFactory.currentSession();
roles = session.find("from Role");
} catch (HibernateException e) {
e.printStackTrace();
}
return roles;
}
I get this exception
javax.faces.FacesException: Collection referenced by UISelectItems with
binding '#{userForm.roles}' and Component-Path : {Component-Path :
[Class: javax.faces.component.UIViewRoot,ViewId: /role.jsp][Class:
org.apache.myfaces.component.html.ext.HtmlSelectOneMenu,Id:
menu_roles][Class: javax.faces.component.UISelectItems,Id: _id0]} does
not contain Objects of type SelectItem
1)I need translate Hibernate List get from session.find in
[]SelectItem?
2) When I use Hibernate with jsf what it is the better session strategy
(ex. close, open). In my getRoles method I must close hibernate
session?
Partager