Java Server Faces Introduction to JSF 1 04

  • Slides: 14
Download presentation
Java Server Faces Introduction to JSF 1 04 -Feb-22

Java Server Faces Introduction to JSF 1 04 -Feb-22

Topics in This Section Introduction to JSF Why JSF? What is JSF? How JSF

Topics in This Section Introduction to JSF Why JSF? What is JSF? How JSF Fits For Web Applications? JSF Architecture 2

Introduction to JSF Java Server Faces or JSF for short, is the standard framework

Introduction to JSF Java Server Faces or JSF for short, is the standard framework to simplify the process of developing web application in java. It is a robust component framework, event driven programming model. It offers a set of UI components, extensible architecture, supports multiple client devices etc. Extensible means additional functionality can be given on the top of JSF core i. e. we can customize the functionality. JSF is vendor independent technology that is a standard to be supported by whole software industry. 3

Why JSF? Java Server Faces or JSF for short is another new exciting technology

Why JSF? Java Server Faces or JSF for short is another new exciting technology for developing web applications based on Java technologies Let's first understand the reasons that initiated the JSF project and why JSF is so hot these days. There are reasons for development of new framework in-spite of many already existing technologies like JSP, Servlets, Struts etc. . . If you have developed complex web based applications in jsp then you must be knowing the problem faced with those technologies. Here are the list of some of the problems faced with the previous technologies like JSP and Servlets: 4

Why JSF? Tedious and repetitive coding Previous technologies like JSP make programmer to do

Why JSF? Tedious and repetitive coding Previous technologies like JSP make programmer to do a lot of tedious and repetitive coding. Directly working with HTTP request and response Using these technologies programmers directly work with HTTP request and response objects and manipulates the data. For example if user submits the registration form then programmer writes the code to get the values of each element in the form into a variable for further processing. When there is a need to retrieve the data from database and then show on the form for editing, then in this case programmer writes the code to retrieve the code from database and then set the values in the forms. Non availability of IDE 5 Non availability of IDE is another major drawback which affects the programmers productivity and development cost of the projects increases.

 JSF changes all that by giving intuitive framework to the developers. Furthermore, JSP

JSF changes all that by giving intuitive framework to the developers. Furthermore, JSP is specification and many vendors are developing their own implementations. Both free and commercial implementations of JSF are available these days. You can choose any one of them based on your requirement and budget. Now a days software vendors are developing IDE for developing JSF based applications which is another good news for the learners of JSF framework. Once you are familiar with the core concepts of the JSF you can kick start the development of software projects using any IDE available in the market. These changes in the programming world makes the life of programmer much easier. Java Server Faces is a component oriented and event driven framework for web applications. JSF eases the development of GUI for web applications. JSF allows the programmers to work with extensible user interfaces like buttons, text boxes, check boxes etc. . . Programmer writes the code for particular event such as button clicked. This makes programming much easier and now there is no need to write request and response processing logic. 6

 In the past many web development frameworks came into existence founded on servlet

In the past many web development frameworks came into existence founded on servlet and jsp. Struts emerged as a standard web application framework. It became framework of choice because it came early in the market and provided necessary features at the time but competitors continued providing additional features that struts lacks. So it became necessary for java to advent new standard framework with a powerful component model. This was the reason for developing JSF technology. So main purpose of developing JSF was to create a collection of APIs for the UI components with the capacity to manage their states, handle events and validation. Struts has an option to migrate to JSF. The simplest option is to use JSF components and rest as usual. This will enable them to take advantage of third party JSF components. Main feature of JSF is ease of use. Developing web applications is easier and faster than other frameworks like struts because JSF supports UI components and easy event handling. Taking advantages of third party components can reduce the cost of 7 rewriting existing elements, minimize the time of development.

What is JSF? JSF is new standard framework, developed through Java Community Process (JCP),

What is JSF? JSF is new standard framework, developed through Java Community Process (JCP), that makes it easy to build user interfaces for java web applications by assembling reusable components in a page. You can think of JSF framework as a toolbox that is full of ready to use components where you can quickly and easily add and reuse these components many times in a page and capture events generated by actions on these components. So JSF applications are event driven. You typically embed components in a jsp page using custom tags defined by JSF technology and use the framework to handle navigation from one page to another. Components can be nested within another component , for example, input box, button in a form. JSF is based on well established Model-View-Controller (MVC) design pattern. Applications developed using JSF frameworks are well designed and easy to maintain than any other applications developed in JSP and Servlets. 8

What is JSF? JSF eases the development of web applications based on Java technologies.

What is JSF? JSF eases the development of web applications based on Java technologies. Here are some of benefits of using JSF: JSF provides standard, reusable components for creating user interfaces for web applications. JSF provides many tag libraries for accessing and manipulating the components. It automatically saves the form data and repopulates the form when it is displayed at client side. JSF encapsulates the event handling and component rendering logic from programmers, programmers just use the custom components. JSF is a specification and vendors can develop the implementations for JSF. There are many GUIs available these days to simplify the development of web based application based on JSF framework. 9

How JSF Fits For Web Applications? JSF best suits in to the java web

How JSF Fits For Web Applications? JSF best suits in to the java web development environment because of reasons below : JSF has many advantages over other existing frameworks that makes it a better choice for web application development. Some of the reasons are below: Easy creation of UI: It makes easier to create complex UI for an application using jsf tags. Its APIs are layered directly on top of servlet APIs that enables us to use presentation technology other than JSP, creating your own custom components and rendering output for various client devices. Capacity to handle complexities of UI management: It handles cleanly the complexities of UI management like input validation, component-state management, page navigation, and event handling. Clean separation between presentation and logic: One of the greatest advantage of jsf is to clearly separate behaviour and presentation in an application. JSF is based on the Model View Controller (MVC) architecture. Shorter development cycle: This separation between logic and presentation enables a wide range of users( from webpage designers to component developers). It allows members of team to focus on their own work only , resulting in division of labour and shorter development cycle. Standard Java framework: 10 JSF is a Java standard which is being developed through Java Community Process (JCP). Several prominent tool vendors are members of the group and are committed to provide easy to use, visual, and productive develop environments for Java. Server Faces.

How JSF Fits For Web Applications? An extensible architecture: JSF architecture has been designed

How JSF Fits For Web Applications? An extensible architecture: JSF architecture has been designed to be extensible. Extensible means additional functionality can be given on the top of JSF core i. e. we can customize the functionality. JSF UI components are customizable and reusable elements. You can extend standard components and create your own complex components like stylish calendar, menu bar etc. Support for multiple client devices: Component developers can extend the component classes to generate their own component tag libraries to support specific client. JSF flexible and extensible architecture allows developers to do so. Flexible rendering model: Renderer separates the functionality and view of the component. So we can create multiple renderers and give them different functionality to get different appearance of the same component for the same client or different. International language support: Java has excellent support for internationalization. It allows you to localize messages with user specific locale. A locale is a combination of a country, a language, and a variant code. Java Server Faces adopts this property and lets you specify which locale your application supports. So you can display your messages in different languages. Robust tool support: 11 There are several standard tool vendors like Sun Java Studio Creator who provide robust tools that take advantages of JSF to create server side UI easily.

JSF Architecture JSF was developed integrating MVC design pattern so that applications can be

JSF Architecture JSF was developed integrating MVC design pattern so that applications can be designed well with greater maintainability. To understand this fact we need to understand what is MVC design pattern, how MVC helps to design an application well and how can we make our web application easy to maintain. The MVC design pattern splits an application design into three separate parts: Model : View : Controller: 12 handles data and business logic. handles output (presentation logic) handles processing of an application.

JSF Architecture MVC model’s purpose is to separate model and presentation to enable developers

JSF Architecture MVC model’s purpose is to separate model and presentation to enable developers to set focus on their core skills and collaborate more clearly. If you have to create many pages for presentation then you have to concentrate only on view layer rather than model and controller layer because you can reuse code for controller and model. In the same way if you want to change the code for model then you typically need not to change view layer. Controllers are used to process user actions. In this process layer model and views may be changed. The best advantages of JSF is that it is both a Java Web user-interface standard and a framework that fits well with the Model-View-Controller (MVC) design pattern. It offers a clean separation between presentation and behaviour. MVC pattern helps persons of different skill sets to work separately so tasks can be completed in parallel. UI can be created by page author using reusable UI components and business logic part can be implemented using managed beans. 13

THANK YOU… 14

THANK YOU… 14