powered by Jive Software

How to get name in RosterEntry?

The “User Summary” page of the “Jive Messenger Admin Console” displays a “Name” for each user. How can I grab that name from a RosterEntry?

Hi rkrikorian,

RosterEntry.getName() should do the trick.

Hope that helps,

Ryan

RosterEntry.getName() returns null; however, I can see that the name is set in the Jive Messenger Admin screen.

Hi rkrikorian,

Have you tried RosterEntry.getUser()?

I mispoke before when I suggested using getName(); getName() “Returns the name associated with this entry”, while getUser() returns “Returns the JID of the user associated with this entry” which is what you are seeing the Messenger Admin Console.

You can look at the Smack API url=http://jivesoftware.org/builds/smack/docs/latest/javadoc/Javadocs[/url] for more info.

Hope that helps,

Ryan

I’'m not looking for the JID, I want a name that can be displayed on the screen. Following is how I create an account:

Map attributes = new HashMap();

attributes.put(“name”,“John Smith”);

con.getAccountManager().createAccount(“agent12345”,“MyPassword”,attributes);

How do I retrieve “John Smith” from the roster?

Hi rkrikorian,

Ah, that would explain the confusion. What you are looking for isn’'t accessed via the RosterEntry. You need to use the AccountManager.getAccountAttributes() which you can then iterate through until you find the name field.

Hope that helps,

Ryan

But that only helps for the account that I’'m logged into. I want to get the name attribute of all the people on my roster.

Hey Raffi,

As Ryan properly said RosterEntry#getName will return the name that you set to your contact when you add it to your roster. If you want to find out the name of other users to use it as your contact name, you can use vCard to get that information. vCard support was added to Smack but that functionality is only available in the nightly build version. Take a look at the vCard test cases to see a running example of vCards usage.

Regards,

– Gato