[jboss-user] [JBoss Seam] - @In ? I don't get it ...
limousyf
do-not-reply at jboss.com
Thu May 31 07:53:49 EDT 2007
Hello,
I'm using a seam-gen generated application and I try to force the login when accessing the application because I always need a logged user in the session context (all data managed is linked to this logged user).
So I'm redirecting to login.seam instead of home.seam in index.xhtml but, when the login page is displayed I got this error:
javax.faces.el.EvaluationException: Cannot get value for expression '#{certificationList.firstResult}'
(...)
org.jboss.seam.RequiredException: In attribute requires non-null value: myCertifications.loggedCollaborateur
"certificationList" is the datamodel I'm using in another page in the application (not login.xhtml). It's used for a datatable.
In the factory method of this datamodel, I'm using the "loggedCollaborateur" to restrict the list so it cannot be null, seam is right.
But why is seam calling this "#{certificationList.firstResult}" before any login ?
By the way, here's my authenticator :
@Out(value="loggedCollaborateur", scope=ScopeType.SESSION)
Collaborateur loggedCollaborateur;
public boolean authenticate() {
log.info("authenticating #0", Identity.instance().getUsername());
if(em == null){log.error("Could not authenticate because EntityManager null."); return false;}
List users = em.createQuery("select u from User u where login_name=:username and password=:password")
.setParameter("username", Identity.instance().getUsername())
.setParameter("password", Identity.instance().getPassword())
.getResultList();
if(users.size() == 0) {
return false;
} else {
User user = users.get(0);
//fetch the collaborateur for this user
List colabs = em.createQuery("select c from Collaborateur where c.user_id=:userId")
.setParameter("userId", user.getUserId())
.getResultList();
loggedCollaborateur = colabs.get(0);
identity.addRole("admin");
}
return true;
}
And in the bean(s) using this outjected Collaborateur Object, I have:
@In(value="loggedCollaborateur")
Collaborateur loggedCollaborateur;
and then using this object to restrict my data.
Am I doing something wrong here ?
Lots of things wrong ?
Why is there this .firstResult call and how can I avoid the null value check before any login ?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4050106#4050106
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4050106
More information about the jboss-user
mailing list