0

我在bean中创建了一个方法

public void checkSessionLife() {
        if (FacesContext.getCurrentInstance().getExternalContext().getSession(false)==null) {
            System.out.println("*\n");
            System.out.println("destroyed");
            FacesContext.getCurrentInstance().addMessage("sessiongr", new FacesMessage(FacesMessage.SEVERITY_INFO, "erer", "errrrrrrrrr"));
            RequestContext requestContext = RequestContext.getCurrentInstance();
            requestContext.update(Arrays.asList("hreaderForm:sessiongr"));
        }
    }

在我的PgTemlate.xhtml我添加一个<p:poll>来更新一个<p:growl>

<p:poll interval="5" listener="#{accessBean.checkSessionLife()}" process="@this" global="false"/>
                <p:growl id="sessiongr" showDetail="true" sticky="true"/>

问题是活动被视为<p:poll>活动会话 他有另一种方法来通知用户吗?

4

1 回答 1

0

accessBean 的范围是什么?如果它小于应用程序范围,我相信该函数将无法运行,因为 JSF 找不到 bean。

尽管如此,这不是处理会话到期的推荐方法。对于首选的方法,请参阅BalusC 的方法

于 2013-09-27T20:43:27.173 回答