Java Technologies Lab 4
Java Server Faces Setup
● NetBeans Maven Project - Project Properties / Frameworks / Add JSF ● pom.xml remains the same, JSF is part of Java EE specifications
● register JSF FrontController servlet, called FacesServlet ● map the URL pattern /faces/*
web.xml in a JSF Project
...
Checking your setup
● Create new JSF page: index.xhtml
● Run: http://localhost:8080/HelloWorld/faces/index.xhtml
XHTML represents "XML well-formed" HTML documents. "Rich" JSF implementations
● PrimeFaces, IceFaces, RichFaces, HighFaces, BootsFaces, etc.
● Components: "PrimeFaces is a popular open source framework for JavaServer Faces featuring over 100 components, touch optimized mobilekit, client side validation, theme engine and more."
● Productivity: "Allocate your valuable time to business logic rather than dealing with the complex user interface requirements."
● Responsive
How to use PrimeFaces https://www.primefaces.org/showcase
● pom.xml
● "Enhance" your previous page
faces-config.xml
● Messages, supported locales, listeners, navigation rules (page flow), etc. ● To create it: "New JSF Configuration"
...
Messages.properties
● Create this file in src/main/resources ● Add key=value pairs greeting = Hello from Facelets app.name = My First JSF Application
● Use the messages in your pages
Web Pages
● /admin ● /config ● /pages /edit /view ● /resources ● main.xhtml, error.xhtml, forbidden.xhtml ● WEB-INF: decorators/ report-templates/
Source Packages
● ro.uaic.info.app ● .model (entity) ● .dao (repo) ● .service ● .edit ● .view ● .reports ● .converters, .validators, .exception
Next steps...
● Create two pages and navigate between them ● Create a backing bean ● Use validators and converters ● Use templates ● Create custom components ● ...