No you can't. To add PropertyChangeSupport
to the @SessionScoped
bean, you need to call
propertyChangeSupport.addPropertyChangeListener("instanceofViewScopedBean")
at a convenient spot (preferably the @PostConstructor
). Note that you require an actual instance of the target bean (implementing PropertyChangeListener
) to pass to the addPropertyChangeListener
. As far as I can tell, You cannot get this from within the session bean, especially at bean initialization. Why? well it's viewscoped, it only lives as long as a page is being viewed.
Related to this restriction is the JSF policy that Managed Beans can only be injected into other beans of a narrower scope (using your case, only the session bean can be injected into the viewscoped bean). What you're looking to do amounts to pretty much the opposite, tying a viewscoped bean to a session scoped variable.
I presume you're trying to achieve a low-cost server-side push mechanism. Well, I don't know of another means to get this done apart from good ol' polling or comet pushing.