有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

添加了`<f:actionListener>`之后,java`ViewScoped` bean会被重新创建吗?

我的JSF支持bean是ViewScoped
因为我添加了另一个动作监听器,所以即使视图没有改变,bean也会被重新创建

@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按钮时,我不会期望bean再次被创建,因为它是ViewScoped,但是它被重新创建(构造函数被调用),并且我丢失了一些变量。当我删除<f:actionListener>行时,不会在OK上重新创建BE

我该怎么办


共 (1) 个答案