Return to site

🧩🌐 JAKARTA FACES (JSF): SERVER-SIDE UI FOR JAVA WEB APPS

· jakartaee

🔸 TLDR

JSF/Jakarta Faces is a component-based, server-side UI framework for Java web apps, powered by Facelets (XHTML templates) + managed beans + a strong lifecycle for forms/validation.

Section image

🔸 WHAT IS JSF (JAKARTA FACES)?

JSF (today called Jakarta Faces) is a server-side Java web framework for building UIs using component-based views, EL (Expression Language), and a managed bean model.

▪️ You write views in XHTML

▪️ JSF builds a component tree, runs a request lifecycle (convert/validate/update/invoke/render)

▪️ Great fit for form-heavy, enterprise web apps with strong validation + state handling ✅

🔸 WHAT ARE FACELETS?

Facelets is JSF’s view technology (the “templating + page” layer).

▪️ Views are .xhtml files (not JSP)

▪️ You get templating (ui:composition, ui:define)

▪️ You use JSF component tags (h:*) + EL bindings (#{bean.value})

▪️ Easy to compose pages with reusable layouts and fragments 🧱

🔸 MINI JSF APP SNIPPET

Here’s a tiny “Hello JSF” with a form + backing bean.

▪️ index.xhtml

<!DOCTYPE html>
<html xmlns="https://lnkd.in/e5vsAmTu"
 xmlns:h="https://lnkd.in/e8pGhMpU">
<h:head>
 <title>JSF Hello</title>
</h:head>
<h:body>
 <h:form>
 <h:outputLabel value="Your name: " for="name" />
 <h:inputText id="name" value="#{helloBean.name}" />
 <h:commandButton value="Say hi 👋" action="#{helloBean.sayHi}" />
 <h:messages />
 </h:form>
 <h:panelGroup rendered="#{not empty helloBean.message}">
 <h:outputText value="#{helloBean.message}" />
 </h:panelGroup>
</h:body>
</html>

▪️ HelloBean.java

import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Named;
@Named
@RequestScoped
public class HelloBean {
 private String name;
 private String message;
 public void sayHi() {
 this.message = "Hello " + (name == null ? "world" : name) + " 🚀";
 }
 public String getName() { return name; }
 public void setName(String name) { this.name = name; }
 public String getMessage() { return message; }
}

🔸 TAKEAWAYS

▪️ JSF shines for enterprise CRUD + complex forms ✅

▪️ Facelets makes templating and reuse straightforward 🧱

▪️ The JSF lifecycle is a superpower… and the main thing to learn 🧠

▪️ If you want richer components, ecosystems like PrimeFaces can level it up ⚡

#Java #JakartaEE #JSF #JakartaFaces #Facelets #EnterpriseJava #JavaWeb #CDI #PrimeFaces #WebDevelopment