1
我的JSF支持bean是ViewScoped
。
由於我添加了另一個動作偵聽器,即使視圖沒有改變,也可以重新創建bean。`ViewScoped` bean在`<f:actionListener>`添加後重新創建?
@ManagedBean (name="EncryptionBean")
@ViewScoped
public class EncryptionBean extends ClientBeanBase implements Serializable, ActionListener
{
.
.
.
@Override
public void processAction(ActionEvent arg0) throws AbortProcessingException
{
refresh();
}
}
HTML
<p:commandButton value="OK" type="submit" actionListener="#{FileSelectBean.actionOk}" oncomplete="dlgFileSelect.hide();" update=":formEncryptionDialog,:formTranscodingPage:streamInfoId" styleClass="buttonOK">
<f:actionListener type="com.company.rews.webclient.beans.EncryptionBean" />
</p:commandButton>
當我按下按鈕OK
,我不會想到的是,綠豆再次創建,因爲它是ViewScoped
,但它被重新創建(稱爲構造函數)和我鬆動一些變量。當我刪除<f:actionListener>
行時,不會在OK
上重新創建。
我該怎麼辦?