我想在将第一页加载到会话之前设置我的数据。
我的XHTML:
<f:event listener="#{beforeLogin.setup}" type="preRenderView"></f:event>
My Managed Bean:
@ManagedBean(name="beforeLogin")
@RequestScoped
public class BeforeLogin {
public void setup()
{
.....
FacesContext context = FacesContext.getCurrentInstance();
context.getExternalContext().getSessionMap().put("Key1", "Value1");
....
ConfigurableNavigationHandler nav = (ConfigurableNavigationHandler) context
.getApplication().getNavigationHandler();
nav.performNavigation("LoginPage");
}
}
}
现在在我的LoginPage
PostConstruct
方法下,我从会话中获得Key1
值null
。任何人都可以建议我在做错的地方吗?注意:我甚至尝试使用SessionScope
用于BeforeLogin
bean。