Software Development

JSF – Check If User is Logged In with preRenderView

This post demonstrates how to check if user is logged in before a restricted page is displayed to the user.

[wp_ad_camp_1]

Requirements

Stuff used in this post.

  • JSF 2.2
    • javax.faces-2.2.8.jar
  • JDK 8

Using Event preRenderView

preRenderView is a system event that can be used to perform pre-processing before the a JSF page is displayed. For example, the following codes use preRenderView and invokes a managed bean method to perform a simple validation check.

[wp_ad_camp_2]

myBean.isLoggedIn method has these codes:

[wp_ad_camp_3]

ConfigurableNavigationHandler is used to “forward” the user to another page.

[wp_ad_camp_4]

Download the codes

https://github.com/Turreta/JSF-Check-If-User-is-Logged-In-with-preRenderView

Loading

Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.


You Might Also Like