This content has been marked as final.
Show 2 replies
-
1. Re: struggling to get user family name and role into jsp fil
apemberton Mar 19, 2009 8:17 AM (in response to jncrisp)What version of JBoss Portal are you using? In Portal 2.6, your PageCustomizerInterceptor stores the userProfile as a request attribute:
Controller controller = controllerCtx.getController(); Map userProfile = controllerCtx.getUserProfile(); request.setAttribute("org.jboss.portal.header.USER_PROFILE", userProfile);
You can then access attributes from the user profile in your header.jsp:<c:out value="${requestScope['org.jboss.portal.header.USER_PROFILE']['user.name.family']}" />
If you're on Portal 2.7, the process should be about the same. Check the reference docs for info on accessing the UserProfile in 2.7: http://docs.jboss.org/jbportal/v2.7.1/referenceGuide/html/identity.html -
2. Re: struggling to get user family name and role into jsp fil
jncrisp Mar 24, 2009 4:37 PM (in response to jncrisp)Thanks apemberton for pointing me in the right direction!
In Portal 2.7 it changed a little bit. Here is what I did inside the jsp to get the first and last name:<% UserProfileModule userProfileModule = (UserProfileModule) new InitialContext().lookup("java:portal/UserProfileModule"); UserModule userModule = (UserModule) new InitialContext().lookup("java:portal/UserModule"); User user = userModule.findUserByUserName(principal.getName()); String lastName = (String) userProfileModule.getProperty(user, User.INFO_USER_NAME_FAMILY); String firstName = (String) userProfileModule.getProperty(user, User.INFO_USER_NAME_GIVEN); %>