JSF2 Page Navigation using PrettyFaces
Pretty Faces is an open source solution to rewrite URL in JSF and J2EE frameworks. It makes the URL pretty and SEO-friendly. As an example, We could replace our JSF URLs from /faces/* to /* in 2 minutes. In this section, we have mentioned how to rewrite URL in JSF using Pretty Faces
Simple JSF Page Redirect
Explicit navigation in JSF is setting the navigation rule in the JSF-CONFIG.xml. We have described an example below to describe the explicit navigation. We created a landing page called index.xhtml which has two buttons, home and dashboard as shown below. When a user clicks the button home, the page moves to home.xhtml and when a user clicks the button dashboard, the page moves to dashboard page using the navigation rules mentioned in the faces-config.xml.
This section, we walk through creating a simple JSF page navigation using managed bean. I have used two XHTML pages in this example; that is index page and home page. When a user clicks a button on the index page, the page moves to the home page.
Managed bean is similar to java bean class contains setter & getter methods and business logic. We can use the managed bean class property directly in the JSF pages. A normal java bean can be a managed bean by mentioned annotation @managedbean on top of the class. This section we have described an example of creating a simple managed bean with property and use the property in the XHTML file.
In this section, we have described an example of a simple JSF page navigation. We have used two XHTML pages, that is index.xhtml and home.xhtml. When a user clicks the button in the index.Xhtml, the page move into home.xhtml. Here below the page flow
In this section, we describe about adding the JSTL jar files in Eclipse Project. The Following two section covered in this section
install wtp in eclipse WTP tool in Eclipse provides efficient way to develop JSF project in eclipse The WTP plugin must be installed to visually editing the JSF pages. Below two items are covered in this section 1. Installing WTP 2. Enable Visual Editor for JSF Install WTP Tool 1. Open Eclipse >> Help >> Install New Software [...]
We walk through creating JSF project in eclipse. We create the web project, add JSF libraries, deploy it in Tomcat and test it in the browser.