A lot of best practices have been discussed throughout this book. However, some best practices didn’t fit into one of the chapters. These are collected in this chapter.
After reading this chapter, you will be able to:
Prevent direct access to page definitions, bypassing the Faces Servlet
Enable container-based security in your JSF application
Create a login page with JSF components
Use component bindings wisely
Save the state of request-scoped components in an elegant way
A common problem with JSF applications is that the JSP or Facelets files that the Faces Servlet uses to render the pages are also accessible via the ‘normal’ web server process, bypassing the Faces Servlet. This can lead to unexpected errors, probably something like:
java.lang.RuntimeException: Cannot find FacesContext
This section presents a simple solution to this problem. A pretty straightforward solution is to implement a Filter
that redirects requests...