我试图从另一个bean设置托管属性值。
faces-config.xml中
<managed-bean>
<managed-bean-name>beanA</managed-bean-name>
<managed-bean-class>com.project.BeanA</managed-bean-class>
<managed-bean-scope>view</managed-bean-scope>
<managed-property>
<property-name>value</property-name>
<value>#{sessionBean.currentValue}</value>
</managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>sessionBean</managed-bean-name>
<managed-bean-class>com.project.SessionBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
SessionBean.java
和BeanA.java
class SessionBean {
private Object currentValue; // getter+setter
}
class BeanA {
private Object value; // getter+setter
}
我了解sessionBean.currentValue
中的值会被转储到beanA.value
,但在设置任何值(来自beanA
)beanA.setValue(x)
时,sessionBean.currentValue
仍然存在没改变 - 这是预期的吗?如果是,如何启用此双向性?