Introduction to JSF

What is JSF?

  • Java Server Faces (JSF)
  • It is an MVC web framework that simplifies the construction of user interfaces (UI).
  • It is a component-based framework.
  • It has three parts…
    • UI (User Interface) Components.
    • An Event-Driven Programming Model
    • A Component Model that enable third party developer
  • JSF reduces the effort in creating and maintaining applications.
  • JSF facilitates Web application development by
  • It is providing reusable UI components
  • It can make easy data transfer between UI components
  • It can manage UI state across multiple server requests
  • It is enabling implementation of custom components
  • It can wiring client-side event to server-side application code
  • Example:
    • Step 01: Create a Managed Bean

    • Step 02: Create a JSF page (.xhtml)
    • Step 03: Output
  • An Analysis of the Sample Application
    • A Simple application consists three things…
      • Bean file
        • A standard format java class file
        • @ManagedBean annotation that specifies the name by which an object of this class is referenced in the JSF page.
        • A java bean is a class that exposes properties and events to a framework such as JSF.
        • A property is name which categories as read (getxxxx) or write (setxxxx), also called as getter and setter methods.
        • Example: Step-01
        • What is Managed Bean?
          • A managed bean is a java bean that can be accessed from a JSF page. 
          • A managed bean must have a name and scope. 
          • Here, Session bean object is available for one user across multiple pages. 
          • Example: @ManagedBean(name = "user") @SessionScoped  
          • In JSF application, you use managed beans for all data that needs to be accessible from a page. 
      • XHTML page
        • A JSF code to access the data from bean
        • JSF application is deployed as a WAR file.
        • You need a JSF page for each browser screen. 
        • There are different mechanisms for authoring a JSF page. 
        • Example: 
          • JSF 1.x was based on JSP, 
          • Facelet has become a part of JSF 2.0. 
          • When you author a Facelet page, you add JSF tags to an XHTML page. 
          • An XHTML page is simply an HTML page that is also proper XML. 
        • We use the extension .xhtml for Facelet pages. 
      • Configuration file
        • Used to keep application server happy
        • When you deploy a JSF application inside an application server, you need to supply a configuration file named web.xml. 


Thanks a lot for query or your valuable suggestions related to the topic.

Previous Post Next Post

Contact Form