我已经使用JSF和PrimeFaces实现了一个登录表单.
我在PrimeFaces展示网站上使用了this example.
我在PrimeFaces展示网站上使用了this example.
我有一个Facelets页面来显示dataTable.现在我需要将上面的登录表单与此表页面集成.所以我在LoginBean.java中添加了几行来处理会话属性.
if (username.equals(getUsername_db()) && password.equals(getPassword_db())) {//valid user and paward
loggedIn = true;
msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Welcome", getUsername_db());
//new lines
FacesContext context2 = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) context2.getExternalContext().getSession(true);
session.setAttribute("user", username);
//end of new lines
...
如果用户未登录,我需要从dataTable中隐藏一列.
现在我的问题是,如何在Facelets页面中访问会话属性?