XPages: How to acces an application scope bean from a session scope bean

℡╲_俬逩灬. 提交于 2019-12-08 13:38:29

The VariableResolver goes through all implicit variables (e.g. session, database) as well as scoped variables (e.g. applicationScope.myVar). Your bean is also accessed from SSJS via the VariableResolver.

So you can use:

ExtLibUtil.resolveVariable(FacesContext.getCurrentInstance(), "myAppScopeBean");

This is not a direct answer to your question...

An alternative would be to set the value you want in applicationScope and then access it this way from your bean. To access the entire bean directly is a different answer.

You use this code get a handle to your applicationScope.

FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
Map<String, Object> applicationScope = externalContext.getApplicationMap();

Then to use this you have code like this:

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