Jsf java server faces

Introduction to Javaserver Faces — What is JSF?

JavaServer Faces (JSF) is a new standard Java framework for building Web applications. It simplifies development by providing a component-centric approach to developing Java Web user interfaces. JavaServer Faces also appeals to a diverse audience of Java/Web developers. «Corporate developers» and Web designers will find that JSF development can be as simple as dragging and dropping user interface (UI) components onto a page, while «systems developers» will find that the rich and robust JSF API offers them unsurpassed power and programming flexibility. JSF also ensures that applications are well designed with greater maintainability by integrating the well established Model-View-Controller (MVC) design pattern into it’s architecture. Finally, since JSF is a Java standard developed through Java Community Process (JCP), development tools vendors are fully empowered to provide easy to use, visual, and productive develop environments for JavaServer Faces.

JSF Architecture

JavaServer Faces’ Implementation of MVC

One of the key advantages of JSF is that it is both a Java Web user-interface standard as well as a framework that firmly follows the Model-View-Controller(MVC) design pattern. This makes JSF applications much more manageable because the user-interface code ( View) is cleanly separated from the application data and logic ( Model). To prepare the JSF context, which provides application data access to the pages, and to guard against unauthorized or improper access of the pages, all user interactions with the application are handled by a front-end «Faces» servlet ( Controller).

Figure 1: JavaServer Faces Implementation of MVC

The JSF Lifecycle

The Faces Controller servlet serves as the link between the user and the JSF application. It operates within the confines of a well defined JSF Lifecycle which dictates the entire flow of events between user requests. For example, upon an initial Web request to access a JSF application, the Faces controller servlet handles the request by first preparing the JSF context, which is a Java object that holds all application data. The controller then routes the user to the requested page. The page usually renders application data from the JSF context using a simple Expression Language. Upon subsequent requests, the controller updates any Model data, providing any new input has been entered. JSF developers have programmatic access to the entire JSF lifecycle at any time during its execution thus affording a high degree of control over the application’s behavior at all times.

JavaServer Faces’ User-Interface Components

The true power of JavaServer Faces lies in its user-interface component model where applications are merely built from collections of components that can render themselves in diverse ways for multiple client types. Vaguely similar to other proprietary technologies such ASP.Net, JSF’s UI Component model technology offers unprecendented productivity by allowing the developer to construct Web user interfaces using pre-built user-interface (UI) Components as opposed to having to construct the user interface entirely from scratch. JSF UI Components come in many forms and can be as simple as an outputLabel which simply displays text or as complex as a dataTable which can represent a tabular data from collections of data such as from a database table.

The JavaServer Faces specification provides a set of base UI Components in its Reference Implementation which are very useful on their own. These include two libraries of components such as the «HTML» component library which largely mirrors the standard HTML input elements along with a «Core» library which aids in common application development tasks such as internationalization, and validating/converting input data. In addition to providing a base library of UI Components, the JSF API offers the ability to extend and create custom JSF UI Components providing additional functionality above and beyond the base components.

Читайте также:  Все шрифты python tkinter

Additional User-Interface Component Libraries

Because of the richness and flexibility of the JSF API, many Java developers are beginning to create new JSF Component libraries and implementations. Oracle’s ADF Faces is a fully compliant JSF component library which offers a broad set of enhanced UI Components for JSF application development. These include multiple renderers per client type, advanced tables, color and date pickers along with a host of general components such as menus, command buttons, shuttle choosers and progress meters.

Figure 2: Oracle’s ADF Faces JSF UI Components

In addition to Oracle’s ADF Faces there are other new JSF Component Libraries beginning to appear from both the Open Source and software vendor communities. MyFaces is an example of a new JSF UI Component Library being offered as an Open Source project through Apache. Myfaces also serves as an enhancement to the JSF base UI components in that they also have more extensive UI capabilities such as integrated Tiles support, Javascript enabled menus and Tree controls.

Figure 3: The Open Source MyFaces Implementation and UI Component Library

JSF UI Components’ Pluggable Rendering Technology

One of the most compelling aspects of JSF’s UI Component technology is it’s pluggable rendering capability. JSF UI Components have the ability to render themselves differently depending on the client type viewing the component. For example a HTML browser will view an «HTML Browser Friendly» version of a particular UI Component whereas a Wireless or WAP enabled micro-device would view a «WML friendly» version of the same UI component! JSF makes this possible by de-coupling the UI Component from its rendering logic making it possible to create multiple renderers for the same UI Component. Different renders can be associated with the UI Component and at runtime the UI component can decide which renderer to use based on the requesting client type.

Figure 5: A Single ADF Faces Table Component Rendering Differently for Wireless and HTML Clients

It should also be pointed out that because of JSF’s pluggable rendering capability it is possible for JSF UI Components to render any kind of data be it markup, such as HTML, XML, WML etc. or binary data. For example UI Components can also render binary data such as an image streams or different document types such as SVG, PDF and Word.

Читайте также:  Blender auto run python script

A New Community of JSF Component Developers

As the community of JSF developers and enthusiasts continues to grow, there are now several Websites dedicated to further empowering independent JSF development.. JSFCentral is an example of a new Website solely dedicated to the JSF development community. It contains JSF technical information, product/component information as well as a vast listing of numerous JSF related articles.

JSF Development Tools

Because JavaServer Faces is a standard Java technology, software development tools are fully empowered to offer advanced integrated development tools support for JavaServer Faces. This greatly enhances JSF’s ease of use and power in that multiple vendors are now supporting JSF development to varying degrees. Oracle, Sun , Borland and IBM each offer development environments for JavaServer Faces. Since development tools vendors are competing at providing better, easier and more development environments, the future of IDE based JSF development looks great!

Figure 6: Oracle’s JDeveloper Offers a Productive, Visual JSF Development Experience

Summary

JavaServer Faces solves many of the historical problems of Java Web development by providing a clean implementation of the Model-View-Controller design pattern while providing a productive, component-centric development without sacrificing development power and flexibility. Additionally since JSF is a Java standard, multiple software vendors will continue to provide evermore productive and efficient development environments which will no doubt rival and most probably surpass proprietary visual development environments. Stay tuned!

Источник

JSF | Java Server Faces

JSF technology includes a set of APIs, which represent different UI components and helps in managing their states. These APIs further help in handling events on the UI components and validate user inputs through the UI components. JSF framework provides the flexibility of creating simple as well as complex applications as this technology uses the most popular Java server technologies (Servlet and Java Server Page) and does not limit a developer to a specific markup language or client device. The UI component classes bundled with JSF APIs contain logic implementation for various component functionalities and do not have any client-specific presentation logic therefore, the JSF UI components can be rendered for different client devices. Currently, SF provides a custom renderer and Java Server Page(JSP) custom tag for rendering UI components for an HTML client.

JSF is robust Web application framework that implements an event programming model to handle different events and actions performed by the client on different UI components. To handle each event, a listener should be registered on server side. While developing a Web application, a developer has to write navigation rules inside the source code to navigate from one Web page to another. JSF provides a simple way to define navigation rules in a configuration file and display different error messages showing the real cause of errors to clients. These messages are generated while validating user inputs against some validation rule and can be displayed on the same page that contains the UI components.

There are different Web application frameworks that implement one or more of MVC design pattern. JSF is based on MVC2 pattern and this pattern is based on component type development. In this pattern, the developers have to concentrate only on their respective component introduces separate layers, such as model view and controller and helps the developer to concentrate on a single type of component by making a Web application easy to maintain. The different categories of components, such as model view, and controller are created for different functionalities, such as use of Text Field, Dialog Box Simple Label and Color Chooser and can be used separately

Читайте также:  Сервера на css v34 вход

Explaining the Features of JSF

Java technology provides various frameworks to develop a Web application Some of these frameworks, such as Struts, are more popular than JSF, but the rich yet simple features of JSF make it one of the preferred choices for designing and managing UI components in a Web application.

The following are the various features of JSF:

  • Provides an easy to use environment that is integrated Development Environment (IDE) for developing Web applications with JSF UI components. It has extensive tool support from the companies, such as Sun, IBM, and Oracle.
  • Facilitates creating complex UI components in a Web page through its own set of tags which are provided as JSP custom tag library. Designing a UI component is easy with JSF as it is based on MVC design pattern, which clearly separates presentation and business logic.
  • Provides a way to manage all UI components in a Web page. Managing UI components includes validation of user input, state of component, page navigation and event handling.
  • Provides extensible architecture, which means that you can add other functionalities over JSF and can easily customize and reuse JSF UI components.
  • Supports multiple client devices. There are different renderers to make similar UI components to be rendered or displayed for different client devices. Various component classes can be extended to create custom component tag libraries to support a particular type of client.
  • Contains components that support internationalization and enable displaying localized messages according to the specified Locale.
  • Supports a standard Rapid Application Development (RAD) Java Web application framework which enables fast development of a powerful application with a set of reusable components
  • Provides the developer with a way to link visual components to the controller or model components without breaking the layer.
  • Provides Expression Language (EL) for a JSF page. As JSF pages use JSP tags, it is difficult to embed separate ELs into one JSF page. One of the key concerns of Java EE specification is to keep its different Web tier technologies, such as ISP, JSF, and JSP Standard Tag Library(JSTL) aligned. This alignment resulted in the creation of a Unified EL, which integrates JSP 2.0 EL and JSF 1.1 EL. JSP 2.1 and JSF 1.2 support this Unified EL. In other words, you can use the JSTL tags with JSF components.
  • Helps in building Web 20 applications that use Asynchronous JavaScript and XML technology (AJAX) and further reduces the complexities involved in creating UI components.
  • Allows the configuration of application wide ResourceBundle to EL using element in the faces-config.xml file.

Источник

Оцените статью