This content has been marked as final.
Show 2 replies
-
1. Re: Getting FirstName from identity, extend Identity?
cash1981 Jul 29, 2009 4:07 PM (in response to mrlueck)There are many ways to do this.
First of all you need to get the current logged in user. I am not sure how you have solved your solution, but if you have something like this, then you can just get the currentUser and in your User table you can create a@Transient public String getName() { return this.firstname + " " + this.lastname; }
and then in your menu.xhtml you can just write
#{currentUser.getName()}
or if you only want firstname
#{currentUser.firstName}
Hope this helps
-
2. Re: Getting FirstName from identity, extend Identity?
jeanluc Jul 29, 2009 4:26 PM (in response to mrlueck)Or you can have a session-scoped component that keeps your User entity. To load it, define a
@AutoCreate @Scope(ScopeType.SESSION) @Startup ... private User user; @Observer("org.jboss.seam.security.postAuthenticate") public void loadUser(){ String username = ((Identity)Component.getInstance(Identity.class)).getPrincipal().getName(); //load the User entity here and store it in the user variable }
Also make sure you clear the user when listening to org.jboss.seam.security.preAuthenticate and org.jboss.seam.security.loggedOut.