Absrtact: JavaServer faces, as a new framework of Web presentation layer, is getting more and more attention. This article describes several of the advantages of JSF and the significant changes in web development brought by these advantages to try to demonstrate that JSF will stand out among many competitors and become the mainstream of the Web presentation layer framework. 1. Intro: My first intimate contact with JSF
When I started developing my first Web program in March 2004, I chose JSP. As a traditional desktop programmer, and as an old programmer, the transition to web programmers is extremely painful. 3 months of time, the program was finally completed, but from the JSP hate. Messy writing format, data and interface of the mixed, especially embedded in the page of the scriptlet, so I do not know whether they are programmed or write the page.
Therefore, when I received the second edition of the development task, I did not hesitate to abandon the JSP, looking for an alternative technology. A search on the internet, but found a few frames, review articles uncompromising, mixed, let me completely lost. Hesitating and wavering, Sun's Java EE Tutorial documentation on the JavaServer faces technology attracted me: UI, Component, event, listener these familiar words in desktop programs, Let me find some sense of desktop programmers in web development.
Developing a Web program like a desktop program is my intention to choose JSF. Based on this superficial understanding, stumbled on the road, under the double pressure of the duration and new technology, overload of the work is not enough, but often from the JSF to discover the new features of surprise, but also bring me great satisfaction. When the second edition was finally completed, the calendar turned over for a month. The efficiency gains that JSF brings are significant.
As a matter of fact, I can only say that I have a rudimentary understanding of JSF until now, far from mastery, not to mention mastery, but that does not prevent me from viewing JSF as the preferred framework for web development. Especially for beginners, if you haven't gone too far in the framework of struts, Tiles, Spring, tapestry, and so on, focus your limited energies on the path of JSF.
2. One of the JSF advantages: UI components (ui-component)
The UI component (Ui-component) has always been a patent for desktop programs, although HTML defines basic UI tags, but to make these UI tags work like a UI component, a lot of code snippets are needed to handle the data and its representations. And it's a tedious task to organize these snippets of code effectively to make them coherent. JSF's UI components are truly UI components that greatly simplify the programmer's work, such as placing a text input box on the page that immediately features data padding, interface updates, event listening, action triggering, validation checks, and type conversions. More importantly, the programmer simply writes the core business code based on the business logic, and JSF guarantees that the code is executed at the right time, regardless of how the code fits into the code.
3. JSF Advantage bis: event-driven mode
Events are an important part of object-oriented methods, in which objects communicate and communicate with each other so that one or more objects can respond to the behavior of another object and work together to complete a business logic. In general, when writing web programs, programmers write code for the communication design mechanism between objects. Although the content of communication is the business logic, the mechanism of communication is obviously not much related to the business, so the programmer is wasting time on functions outside the business logic. JSF has changed this situation. JSF's event and interception patterns are similar to familiar JavaBean event patterns, and Java based programmers do not need to learn anything new. JSF UI components can generate events, for example, when the contents of the previous text input box on a page are modified, a value change event is issued. Another object that is interested in value change events simply registers as a listener for the object and writes a processing routine that commands JSF to invoke the processing routine automatically when the event occurs. JSF did all that was left to the programmer, and only the business logic code was written.
4. JSF Advantage Three: direct mapping of user interface to business logic
For example, form submission is the most common task of web programming and one of the most complex tasks. When the user clicks the "OK" button on the Web page, the browser generates an HTTP request, sends it to a servlet on the server side, and executes the service method of the servlet. In the service method, HTTP requests need to undergo decoding, type conversion, validation, state preservation, data Update and so on, dealing with all the details of these links, the programmer is a heavy burden. In JSF, a large part of these tasks are assumed by the framework, which, in the programmer's view, is transparent, and the HTTP requests from the user interface can be mapped directly to an event-handling routine at the back end, and JSF plays a role in the process.
5. JSF Advantage Four: the division of labor between programmers and web designers
In JSP, the work of programmers and web designers is sometimes intertwined and indistinguishable. This is because JSP pages are mixed with some JSP tags that web designers are unfamiliar with, and even obscure Java code. It is unrealistic to ask web designers to understand these tags and codes, and it is not in line with the principle of division of service. In JSF, the framework provides a standard set of UI components for Web page designers, supported by tools that can be simply added to a Web page by dragging and dropping, and then set some display properties to meet visual requirements. Web designers do not need to know the complex code behind the UI component, which is a programmer's business, and programmers do not have to deal with any visual-related details, and what the programmer does is to bind the properties or methods of the class to the UI component. While programmers and web designers need to modify the same file, they do their part, do their job, and do not interfere. The clear division of work between programmers and web designers is a big step in usability for JSF.
6. JSF Advantage Five: Multi-stage partitioning of the request-processing lifecycle
Although they are all based on the servlet, the JSF lifecycle is much more complex than the JSP. The lifecycle of a JSP is very simple, and when the page is executed, the HTML tag is immediately generated and the lifecycle ends. While a complete JSF request-processing lifecycle is carefully planned for 6 phases, a typical JSF request needs to go through all phases, and some special requests can skip some stages. Phase of the subdivision, obviously introduced more processing, but the JSF framework will manage all this, so the programmer to gain more control capacity, while the workload does not increase.
7. JSF Advantage VI: The survival of the accompanying tools
JSF has brought great changes in web programming, the intensity of which is beyond the expectations of many tool makers, so that the tools available for JSF are scarce. JSF, which lacks tool support, can be a respectful one, so JSF is at the beginning of the design for the tool vendor. In one of the few JSF tools, Sun's Java Studio Creator is an excellent development environment Borland JBuilder in JSF1.1 was once a very useful development tool, but now the support of JSF1.2 did not keep up; there are a lot of JSF plug-ins under Eclipse, but there is a charge for real support for WYSIWYG JSF plug-ins, such as Bea's workshop For JSF, Exadel JSF Studio, and so on; Oracle and IBM also have JSF development tools. With the advent of tools, it will be increasingly convenient and fast to develop web programs with JSF.
8. JSF Advantage VII: Comprehensive user-defined support
As mentioned earlier, JSF will greatly simplify the development of web programs, and as a relatively complex framework, how does JSF do this? The original JSF provides programmers with many default components and classes, and typically these default components and classes of JSF are sufficient to meet the needs of web development. However, given that, in some applications, the default behavior of the framework may not meet the requirements of the business, JSF specifically allows programmers to write their own components and classes to meet the specific needs of their customers. For example, programmers can write their own UI components, and can even create their own El interpreter to support non-standard El expression languages.
9. JSF Advantage VIII: One of the official standards of web development
The 1.0 version of JSF was released in February 2004, when it was launched as a stand-alone web technology. After the 1.1 edition to the current 1.2 edition, and just over two years, JSF finally became part of Java EE 5 in 2006 and rose to one of the official standards of web development. The most important mission of Java EE 5 is to simplify Java development, and JSF has undoubtedly made a significant contribution to this mission. Today, with the proliferation of web frameworks and even some flooding, sun is using JSF to establish standards that are beneficial to Java development. Sun's leadership in the Java world is not to be shaken, and for Java programmers, always following the footsteps of industry leaders may be the best way to avoid technology obsolescence.
10. Conclusion: It's your time, jsf!.
Looking at the popularity of a technology, Google's keyword search is an easy way. For illustration purposes, we chose the most popular struts to compare with JSF. In Google, enter the keywords "Struts" and "JSF" to see how many pages Google returns. What interests us is not the absolute number of pages, but the ratio of the number of JSF pages to the number of struts pages. We see that for English pages, this ratio is 0.6, the Japanese page is 1.0, the traditional Chinese page is 0.8, and the Simplified Chinese page is only 0.4. Table 1 lists the specific data and ratios.
Number of English pages (million) number of Japanese pages (million) number of traditional Web pages (million) simplified number of pages (million)
JSF struts JSF struts JSF struts JSF struts
719 1170 145 140 10 13 59 138
jsf/struts = 0.6jsf/struts = 1.0jsf/struts = 0.8jsf/struts = 0.4
Although this method of comparison is not rigorous, but 0.4 of the proportion from a side to explain that JSF has not been popular in the country, with the "ascendant" four words to describe the situation of JSF, is more appropriate. For historical reasons, the domestic software technology has been following the foreign run, this is not our hope, but we have to admit, so from the situation abroad, we have reason to believe that JSF will become the object of domestic programmers. As one philosopher said, JSF is the sun at 89 o ' clock in the morning, hoping to be pinned on JSF.
11. PostScript: Different sounds
Objectively speaking, JSF is not perfect, and the industry's assessment of JSF is mixed. For example, because JSF is too complex, its learning curve is significantly longer than other frameworks such as struts, which in some ways hinders the promotion of JSF, and the introduction of JSF is a bit hasty, with the 1.0 version finding many bugs in use, That Sun's hastily released version 1.1 was designed to fix the bugs; Also, before the JSF1.2 version, the integration of JSP and JSF had serious flaws, mainly due to the different lifecycles, but the 1.2 edition made improvements in this area, and now JSP and JSF can be in a project.
There are a lot of drawbacks to JSF, for example, the UI components are not rich enough, the choice of concrete implementation is too narrow, the actual project using JSF development, there are many bugs in the sun's reference implementation, lack of tool support in the short term, and so on, especially in China, JSF's Chinese documents and books are quite scarce. But, anyway, these are the tribulations of JSF's growth path, and I'm sure Sun will try.