powered by Jive Software

Change contact group?


Is it possible to change the group of a contact, I mean:

if first contact1 belongs to groupA, is it possible to make contact1 to belong to groupB?



Sure you can

RosterGroup#addEntry(RosterEntry entry)


if you want to remove someone from a group then there is also

RosterGroup#removeEntry(RosterEntry entry);





first, thx for reply…

Does use of removeEntry and addEntry method on RosterGroup object lead to remove totally contact from the roster and then re add it as if it were a new contact?

I mean, does it cause new subscription as if the contact were added for the first time in the roster?



not as far as I’'m aware of. Roster#removeEntry(RosterEntry entry) would remove the contact from your Roster but RosterGroup#removeEntry(RosterEntry entry) would simply remove that contact from the specified group.

ok, thx for reply…

that mean that method of the RosterListener are not called when you manipulate RosterEntries at RosterGroup level?

I mean, if you change group for a contact using RosterGroup methods like removeEntry() or addEntry() (as told before); the entriesAdded() and entriesDeleted() method of the RosterListener wont be call?



As far as I know they wont be called, but I could be wrong.

To update your gui with the correct display after you have added/removed an entry from a group you could simply call a method to redraw your roster. As long as your roster drawing code included pulling groups and their members then it should show the updated list

Hi thx for reply…

I’'m french and I dont understand what means the following:

"As long as your roster drawing code included pulling groups and their members then it should show the updated list "[/i]

Could you explain me what does mean “roster drawing code” and “pulling groups”?

thx for help…


So something like this could be called after you have either added or deleted a RosterEntry from a RosterGroup.

Roster roster;

// Get all RosterGroups from your Roster

Iterator groupsIter = roster.getGroups();

// Loop through each group and display its members

while(groupsIter.hasNext()) {

RosterGroup rosterGroup = (RosterGroup)groupsIter.next();

System.out.println("Group: " + rosterGroup.getName());

// Get the members of each group.

Iterator groupEntries = rosterGroup.getEntries();

while(groupEntries.hasNext()) {

RosterEntry rosterEntry = (RosterEntry)groupEntries.next();

System.out.println("Contact: " + rosterEntry.getUser()):




Thx Jon, that’'s helpful…

I’'ll try this and tell you…


Problem solved:

Moving RosterEntries from group A to group B, using RosterGroup methods does not call RosterListener methods…

thx for snippet code and for all…


forgot “answered flag”…