You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Ron McNulty <rm...@clear.net.nz> on 2012/11/04 09:55:47 UTC

Getting user principal attributes in header.vm

Hi All

I am setting up some new themes for our applications, which means creating new files for header.vm and footer.vm. Unfortunately I am not a Velocity expert :)

I would like to put something like "Logged in as jsmith: Joe Smith" in the header.  The jsmith loginId is easy (principal.getName()), but I can't seem to pull the user.name.family and user.name.given attributes from the attributes map structure - either I get an empty string, or the line of velocity code appears verbatim. The attributes are present, as I can access them from portlet Java code.

Can some Velocity guru point me in the right direction?

Regards

Ron


Re: Getting user principal attributes in header.vm

Posted by Ron McNulty <rm...@clear.net.nz>.
Thanks David

Worked like a charm.

Regards

Ron

----- Original Message ----- 
From: "David Sean Taylor" <da...@gmail.com>
To: "Jetspeed Users List" <je...@portals.apache.org>
Sent: Monday, November 05, 2012 5:00 PM
Subject: Re: Getting user principal attributes in header.vm


>
> On 11/4/12 1:55 AM, Ron McNulty wrote:
>> Hi All
>>
>> I am setting up some new themes for our applications, which means 
>> creating new files for header.vm and footer.vm. Unfortunately I am not a 
>> Velocity expert :)
>>
>> I would like to put something like "Logged in as jsmith: Joe Smith" in 
>> the header.  The jsmith loginId is easy (principal.getName()), but I 
>> can't seem to pull the user.name.family and user.name.given attributes 
>> from the attributes map structure - either I get an empty string, or the 
>> line of velocity code appears verbatim. The attributes are present, as I 
>> can access them from portlet Java code.
>>
>> Can some Velocity guru point me in the right direction?
>>
>> Regards
>>
>> Ron
>>
> How about this:
>
> #if ($request.getUserPrincipal())
> <span 
> class="layout-statusarea"><b>$jetspeed.getUserAttribute("user.name.given","") 
> $jetspeed.getUserAttribute("user.name.family", 
> ${request.userPrincipal.name})</b> | <a href="#BaseHref()login/logout">Log 
> out</a></span>
> #end
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: Getting user principal attributes in header.vm

Posted by David Sean Taylor <da...@gmail.com>.
On 11/4/12 1:55 AM, Ron McNulty wrote:
> Hi All
>
> I am setting up some new themes for our applications, which means creating new files for header.vm and footer.vm. Unfortunately I am not a Velocity expert :)
>
> I would like to put something like "Logged in as jsmith: Joe Smith" in the header.  The jsmith loginId is easy (principal.getName()), but I can't seem to pull the user.name.family and user.name.given attributes from the attributes map structure - either I get an empty string, or the line of velocity code appears verbatim. The attributes are present, as I can access them from portlet Java code.
>
> Can some Velocity guru point me in the right direction?
>
> Regards
>
> Ron
>
How about this:

#if ($request.getUserPrincipal())
<span 
class="layout-statusarea"><b>$jetspeed.getUserAttribute("user.name.given","") 
$jetspeed.getUserAttribute("user.name.family", 
${request.userPrincipal.name})</b> | <a 
href="#BaseHref()login/logout">Log out</a></span>
#end



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org