session-scoped managed bean appears to be not session scoped in an xpages application

∥☆過路亽.° 提交于 2019-12-04 14:54:00

As Mark Leusink mentions, sessionScope in XPages is linked to the browser session and not the (logged in) user session.

So you need a way to check if the current user matches the user tied to your user bean. One way to do this is to call a "verify" method in your user bean on each request. The "verify" method could look like this:

public void verify() {
    // retrieve the username of the current user
    String currentUser = ExtLibUtil.getCurrentSession().getEffectiveUserName();

    // (re-)init the user bean if another user logged in
    if (!currentUser.equals(getFullUserName())) {
        // Call your constructor logic here
    }
}

You can call this "verify" method in the beforePageLoadevent of one of your central custom controls (such as a custom control for your layout):

<xp:this.beforePageLoad><![CDATA[#{javascript:
    // (re-)init the userbean if another user logged in
    NBUser.verify();
}]]></xp:this.beforePageLoad>

--

Also, you should not store Domino specific objects in a bean.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!