JSF 2: sharing scope among specific users

127 Views Asked by At

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

1

There are 1 best solutions below

0
On

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;

    // ...
}