I'd wrote a session scoped managed bean to cache the sesion user specific info in a domino xpages application,just like the following codes:
public class NBUserInfo {
private String fullUserName;
private String commonUserName;
private String displayName;
private String mailAddress;
private String themeType;
private String themeData;
private Session _session;
private Database _dbnames;
private Name _dominoName;
public NBUserInfo(){
System.out.println("初始化Managed Bean:NBUserInfo...");
_session = ExtLibUtil.getCurrentSession();
try {
System.out.println(_session.getEffectiveUserName());
_dbnames = _session.getDatabase(_session.getCurrentDatabase().getServer(), "names.nsf",false);
_dominoName = _session.createName(_session.getEffectiveUserName());
} catch (NotesException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
public String getFullUserName() {
if(fullUserName==null)
try {
fullUserName = _dominoName.getCanonical();
} catch (NotesException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
return fullUserName;
}
then, i declared it in the faces-config to make it a session scoped bean:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config>
<!--注册受管Beans-->
<managed-bean>
<managed-bean-name>NBUser</managed-bean-name>
<managed-bean-class>com.nbhdtech.common.NBUserInfo</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<!--注册自定义XPAGES根渲染器-->
<render-kit>
<renderer>
<component-family>javax.faces.ViewRoot</component-family>
<renderer-type>com.ibm.xsp.ViewRootEx</renderer-type>
<renderer-class>com.nbhdtech.xsp.CustomViewRootRenderer</renderer-class>
</renderer>
</render-kit>
<!--AUTOGEN-START-BUILDER:由 IBM Domino Designer 自动生成。请勿修改。-->
<!--AUTOGEN-END-BUILDER:自动生成的区段的末尾-->
</faces-config>
when testing the bean , I used it through #{NBUser.fullUserName}, it does not always return the user of the current domino http session context,for examples, I get logged in first by user "user1" and logged off,then logged in by user2, the bean seems to not recreated for the new user2 session,just still user1's session info .
is there some work around about this? my domino have been configed to LTPAToken SSO config. thanks a lot if any answers about it