0

i'm not sure if what i want is possible, but still... i want to share a data among users, like done here. however, unlike this example, which uses ApplicationScope to share the data, i want the data to be shared not among all users, but only for groups of users (something like private chat rooms, and not a public space as in that example). currently i use ViewScope but in order to update the display of the participants, use the hack i found here, but this solution isn't very stable, as it throws JS error occasionally. is there any sort of reasonable solution for my problem? cheers, eRez

Community
  • 1
  • 1
eRez
  • 257
  • 8
  • 24

1 Answers1

2

Hold them in a Map in an application scoped bean where the map key is the group identifier.

E.g.

@ManagedBean
@ApplicationScoped
public class ChatManager {

    private Map<Group, Room> rooms;

    // ...
}

with

@ManagedBean
@ViewScoped
public class GroupChat {

    @ManagedProperty("#{chatManager.rooms[user.group]}")
    private Room room;

    // ...
}
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555