Hi
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?
thx
e07
Hi
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?
thx
e07
Sure you can
RosterGroup#addEntry(RosterEntry entry)
/code
if you want to remove someone from a group then there is also
RosterGroup#removeEntry(RosterEntry entry);
/code
hth
Jon
Hi,
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?
thx
e07
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?
thx
e07
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…
e07
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()):
}
}
/code
Thx Jon, that’'s helpful…
I’'ll try this and tell you…
e07
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…
e07
forgot “answered flag”…