I know about the function FacesContext.addMessage(). However, what happens if I am currently in a diffent faces context, like being in a different window.
Is there some way to get a reference to the other FacesContext objects stored in the current session?
Basically, I want to send message from a popup window to the parent, however, I don't have a reference to the parents' FacesContext object.
It doesn't exactly work like that. A FacesContext is not something that normally actively sits there waiting inside a window that has already been rendered.
The FacesContext for a specific "window" is only available to the thread that handles the request that ultimately sends the response containing HTML. When this HTML response is received, the browser is just displaying it. At that moment there is no notion of any server-side FacesContext still associated with that HTML.
With reverse AJAX (comet) though it is possible to push content from the server to a particular client. A backing bean associated with such a server side push can be suspended and you can let it wait for some server-side event. The CDI bus would be most convenient here, but basically an old fashioned notify on an object shared via the HTTP session would work too.
The backing bean associated with the popup or any other window for that matter could trigger this event.