Take the 2-minute tour ×

I've stumbled upon a problem I don't seem to be able to solve on my own with my basic knowledge of jsf.

I have a session scoped object which is referenced by userSession.

So if I want to get the property loginTimestamp I just call userSession.loginTimestamp which is no problem and works perfectly fine.

Now I also have a method getLoggedInUser which gives me an Object of the type user. On that object I can call a method getNickname which should give me a string.

The problem is that I want to call something like

<div id="login">
    <h:outputText value="Welcome #{userSession.getLoggedInUser.getNickname}" />
    <h:form id="logoutForm">
        <h:commandButton class="Submit" value="logout"
            action="#{Logout.logout}" />

No the method getLoggedInUser has no property loggedInUser. But how do I just call that method within the value-attribute and call a method on that return type?

Maybe it is not even possible and I missed something crucial here. But wouldn't it be really annoying to always set a property for anything you want to use instead of being able of breaking it down this way?

Thanks already for your help!

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted


public String getLoggedUserNickname(){
   return getLoggedInUser().getNickname();


<h:outputText value="Welcome #{userSession.loggedUserNickname}" />

Or just

<h:outputText value="Welcome #{userSession.loggedInUser.nickname}" />


Whenever you call for property for example myProp like userSession.myProp it will look for getMyProp() function. case-sensitive

share|improve this answer
Thanks this was very helpful! –  saenridanra Jun 21 '12 at 18:17
add comment

Lose the get prefixes. This should work:

share|improve this answer
add comment

Your Answer


