I have implemented a login form using JSF and PrimeFaces. I used this example in the PrimeFaces showcase website.
I have a Facelets page to show a dataTable. Now I need to integrate the above login form with this table page. So I added few lines in to LoginBean.java to handle session attribute.
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
...
I need to hide a column from the dataTable, if the user is not logged in. Now my problem is, how can I access session attribute inside my Facelets page?