我有两个ManagedBeans
(@SessionScoped
和@ViewScoped
):
@ManagedBean(name="sessionController")
@SessionScoped
public class SessionController implements Serializable{
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
public void addPropertyChangeListener(PropertyChangeListener listener) {
propertyChangeSupport.addPropertyChangeListener(listener);
}
...
}
@ManagedBean(name="viewController")
@ViewScoped
public class ViewController implements Serializable, PropertyChangeListener{
@ManagedProperty(value="#{sessionController}")
private SessionController sessionController ;
...
@PostConstruct
public void init() {
sessionController.addPropertyChangeListener(this);
}
@Override
public void propertyChange(PropertyChangeEvent evt) {
...
}
}
我可以用PropertyChangeListener
inViewController
来了解 的变化SessionController
吗?会不会有什么问题?