Perfect Combination of JSF and web to improve development efficiency

Source: Internet
Author: User
Tags manual writing

And Microsoft Visual Studio. compared with visual tools, Java-based Web user interfaces still require manual writing of a large number of labels, at the same time, we also need to consider the storage of page status information, client event processing, and other issues. The development is difficult, inefficient, and reusable. Java Server faces (JSF) is designed to solve this problem. One of its most striking features is that it has nothing to do with markup language, protocol, and client devices. With the reusable, scalable, and component-based user interface framework provided by JSF, visual development is implemented with the support of the Rapid Development Tool rad. Currently, JSF technology has been supported by many major vendors, such as Sun's JSF web UI, IBM's JSF extension, and Oracle's ADF faces, many open-source projects also provide support for JSF technology. Oracle, sun, Borland, IBM, and other companies provide development environments for JSF.

Problems in traditional JSP development

Separating the presentation layer from the business layer has always been an ideal practice for J2EE Web applications. Unfortunately, JSP has not truly achieved this goal. JSP is a Java-based standard Web user interface development technology, is a "script-based" development web technology, the JSP page obfuscated a large number of HTML for displaying logic and Java code for business logic, making it impossible to separate page design and program development. Another major defect of JSP is that scripts cannot be reused, this often causes developers to have to copy and paste between JSP pages, which leads to multiple versions of the same Code, making debugging and design of the program extremely complicated. As a supplement to JSP, The taglib library of the tag library removes Java code from JSP, and only achieves the separation of performance and logic in a limited way, so it never gets rid of the problem of mixing code and HTML pages. In addition, JSP still has other inherent defects. For example, it is difficult to find the correct error location in JSP for the error information of servlet compilation, which brings great difficulties to debugging.

JSF Technology Introduction

On the J2EE platform proposed by Sun, Java Server faces (JSF) is a new standard Java framework used to build Web applications. It provides a component-centric method for developing the javaweb user interface, thus simplifying development. "Enterprise developers" and web designers will find that JSF development can be simple by dragging and dropping User Interface (UI) components to the page, system developers will find that the rich and robust JSF APIs provide them with unparalleled functionality and programming flexibility.

JSF also ensures higher maintainability of applications by integrating well-built Model-View-controller (MVC) design patterns into its architecture.

JSF is a Web application framework standard developed by Java Community process (JCP. JSF has a well-defined request processing lifecycle and rich component hierarchies. It aims to promote the simplicity of Java-based Web user interface development. With the reusable, extensible, and component-based user interface framework provided by JSF, the quick development tool rad supports visual editing of the Web user interface by dragging and dropping components, bind the components on the user interface to a data source and send the events generated on the client user interface to the server for processing. This greatly reduces the difficulty of Java-based Web user interface development, improve development efficiency.

In short, the main part of JSF is a GUI Component Framework and a flexible model for describing components across different Markup languages or client devices. The jsf gui component framework enables developers to create user interfaces for JSF applications.

Jsf gui components include standard HTML Form Controls (such as buttons), layout components, and more complex components, such as data tables. In addition, third parties can expand the basic classes defined in the specifications to develop additional GUI components.

The architecture of the JSF component is designed as follows: the function of the component is defined by the component class, and the rendering of the component is defined by a separate Renderer. The Renderer defines how component classes are mapped to component labels suitable for specific customers.

One of the main advantages of JSF is that it is not only a Java Web user interface standard, but also a framework that strictly follows the Model-View-controller (MVC) design pattern. Clear separation of user interface code (View) and Application Data and logic (model) makes JSF applications easier to manage. To prepare the JSF context that provides page access to application data and prevent unauthorized or incorrect access to the page, all user interactions with the application are handled by a front-end controller. The JSF technology completely separates the application logic from the representation, and is a truly thorough MVC model.

The current version of JSF technology is 1.1, and the next version is 1.2. It will be released together with J2EE 5.0.

Steps for developing a JSF-based Web Application

JSF is a new standard Java framework for building Web applications. You can manually write Web applications according to the JSF framework standards, the Web user interface is designed in the form of text like an HTML or JSP program. At the same time, a system running platform needs to be built before development, operation, and debugging. The disadvantage of this method is that it cannot fully reflect the convenience and efficiency of visual development. It is generally used to analyze the structure of Web applications.

Using the rapid development tool rad is a prerequisite for JSF visual development. With the support of quick development tools, the development, running, and debugging of Web applications that comply with the JSF standard are all implemented in the IDE environment, greatly improving the development efficiency, the entire program development process is fast and efficient. Currently, many RAD tools are supported by major manufacturers, such as IBM's WebSphere Studio, Oracle's jdeveloper, and Sun's Java Studio creator.

If you do not use the IDE development environment, you must build a system running platform before developing applications. For example, install Tomcat and Sun's javaweb services developer pack (jwsdp) 1.2. When using JSF, jstl and JSF's label function library are required to put the required JAR file under the WEB-INF/lib directory of the Web application. If you use the IDE development environment, the preparation work in the early stage of development is relatively simple. You only need to install the IDE environment and do not need other configurations. Generally, the IDE has an embedded application server, it is sufficient to support program development, operation and debugging. Regardless of whether or not the IDE development environment is used, developing Web applications using JSF is generally divided into the following three steps:

View Design

JSF-based web applications are developed conveniently and quickly under the condition that JSF provides a rich set of reusable server-side user interface components. With the support of development tools, you can easily use these components in a visual environment to construct a Web user interface, and handle component data verification, event processing, and other user interface management issues.

Design each required JSP page, place the built-in JSF components on the page, and bind the components to the JavaBean at the application layer. Using the rad tool, you can easily implement page files by dragging and dropping components without having to write a large amount of code. The development tool automatically generates the Java file corresponding to the page, defines the JSF component of the page and Its getter, setter method, and the method corresponding to the "Action" attribute of the JSF component in the file. Programmers can easily modify and debug existing programs.

Model Design

JSF technology completely separates application logic from representation. In model design, programmers only need to consider the Logic Functions of the program, and do not need to consider the data representation. The JSF model is implemented through the JavaBean program.

Controller Design

The Controller Design of JSF is completed in the configuration file. There are two main files related to it: the Web. xml file and the faces-config.xml file (both under the WEB-INF directory ). The Web. xml file is mainly used to control the lifecycle of JSF and implement deployment descriptor. Faces-config.xml file navigation, control the jump between pages in the file.

The configuration step is to first configure the Web. xml file for the web application, and then configure the JSF control file faces-config.xml file. These two files are fixed in the format. In the IDE environment, this process is automatically completed by the tool without the intervention of the designer, even if the manual configuration is relatively simple.

The focus of JSF's technology is on The View part, which completely isolates the web application design roles. JSF web designers only need to focus on the design of the page; application developers are mainly concerned with the development of the model part of the JavaBean; the process control of the program is specially configured by the faces-config.xml.

JSF is a Java-based Web application development field that provides a reusable, scalable, component-based, and tool-friendly server-side UI framework. In Rad development tools that support JSF, people can use Visual Studio.. NET is convenient and quick to build Web user interfaces, greatly reducing the difficulty of using Java technology to implement web user interfaces and improving development efficiency.

JSF has a powerful component system and event processing system, fully implementing the MVC model application architecture, greatly reducing the difficulty of Java-based Web user interface program development and improving development efficiency, it is very suitable for web page development.

JSF is an open standard with good scalability. According to JSF specifications, users can customize their own user interface components, event processors, data verification and conversion components as needed. These components are reusable like standard JSF components. JSF APIs are directly structured on servlet APIs. Therefore, the presentation of JSF user interface components is not limited to specific script technologies or Markup languages. The presentation layer can use technologies other than JSP. Among the many J2EE presentation layer framework technologies, JSF shows its vigorous vitality. Although there are still many problems with the JSF technology, as the JSF technology continues to mature and the version is updated, it will surely get more and more applications.

Link

The JSF technology consists of two main parts:

◆ A group of Java APIs used to represent user interface components and manage their statuses, process events, and verify input. These APIs support internationalization and accessibility;
◆ A set of custom tag libraries used to represent JSF components on the JSP page.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.