CDI ViewScoped Bean 未按预期工作

问题描述

我最近从 JSF Managed Beans 升级到 CDI Managed Beans。

SessionScoped Bean 看起来像:

import javax.enterprise.context.SessionScoped;
import javax.inject.Named;

@Lazy
@Named("sessionScpdBean")
@SessionScoped
public class sessionScpdBean implements Serializable {
   ........
   public string soSomeAction(Menu menu){
     ......
     ......
     return "/pages/app/one.xhtml";
       }
  }

ViewScoped Bean 看起来像:

import javax.faces.view.ViewScoped;
import javax.inject.Named;

@Lazy
@Named("viewScpBean")
@ViewScoped
public class viewScpBean implements Serializable {
   ........
   public String someHeaderValue="Header Name";

    }

View(JSF) one.xhtml 有:

<p:commandLink value="#{node.menuName}"
    title="#{node.menuName}"
    action="#{sessionScpdBean.doSomeAction(node)}" ajax="true"
    partialSubmit="true" update="treeNode"
    process="@this,treeNode"
    >
</p:commandLink>

<p:panel >
    <h:panelGroup id="displayPanel">
        <ui:include src="/pages/app/two.xhtml" />
    </h:panelGroup>
</p:panel>

View(JSF) two.xhtml 有:

<p:panel header="#{viewScpBean.someHeaderValue}"
        headerClass="pageheader" width="100%" id="reportheader">
</p:panel>

现在的问题是,在早期的 JSF Managed ViewScoped 中,单击 one.xhtml 中的 commandLink,ViewScoped bean 将重新初始化并再次调用 init()。 但是升级到 CDI Managed ViewScoped 后,只有在加载页面 (one.xhtml) 时,ViewScoped bean 才会被初始化;但不会在每次 commandLink 单击时再次初始化。

在这里遗漏了什么吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)