1

I tried to develop a simple authentification application based on BaluC's answer in JSF HTTP Session Login, but the problem is that my session scoped bean UserManager is not stored in the user session, so when the LoginFilter checks if the user is logged in,

UserManager userManager=(UserManager)req.getSession().getAttribute("userManager");

it returns null !

Any Idea on how to fix this problem ?

Community
  • 1
  • 1
ThunderPhoenix
  • 1,649
  • 4
  • 20
  • 47
  • 1
    In that example he has given name of the bean as `user`. Try to get like `UserManager userManager=(UserManager)req.getSession().getAttribute("user");` – SRy Aug 01 '13 at 13:54
  • And If you are new to JSF first go through some tutorials. http://www.mkyong.com/tutorials/jsf-2-0-tutorials/ – SRy Aug 01 '13 at 13:57
  • I fixed the answer over there. – BalusC Aug 01 '13 at 15:07
  • @BalusC the problem is not resolved yet ! the `SessionScoped Bean` `userManager` is created several times ! Indeed, the `init` function which is declared `@PostConstruct` is executed many times ! so the `loggedin` property is reinitialized ! – ThunderPhoenix Aug 14 '13 at 15:54
  • Apparently you used the wrong annotation package. – BalusC Aug 14 '13 at 15:59

1 Answers1

0

You can try to get it from the context like :

FacesContext context = FacesContext.getCurrentInstance();

UserManager userManager = context.getApplication().evaluateExpressionGet(context, "#{userManager}", UserManager.class);
faissal
  • 261
  • 5
  • 20