JSF Framework Services

   

Now that you have seen your first JSF application, it is easier to explain the services that the JSF framework offers to developers. Figure 1-10 gives a high-level overview of the JSF architecture. As you can see, the JSF framework is responsible for interacting with client devices, and it provides tools for tying together the visual presentation, application logic, and business logic of a web application. However, the scope of JSF is restricted to the presentation tier. Database persistence, web services, and other back-end connections are outside the scope of JSF.

Figure 1-10. High-Level Overview of the JSF Framework

graphics/01fig10.jpg


Here are the most important services that the JSF framework provides.

  • Model-View-Controller Architecture

    All software applications let users manipulate certain data, such as shopping carts, travel itineraries, or whatever data are required in a particular problem domain. These data are called the model. Just like an artist creates a painting of a model in a studio, a software developer produces views of the data model. In a web application, HTML (or a similar rendering technology) is used to paint these views.

    JSF connects the view and the model. As you have seen, a view component can be wired to a bean property of a model object, such as

     

     <h:inputText value="#{user.name}"/> 

    Moreover, JSF operates as the controller that reacts to the user by processing action and value change events, routing them to code that updates the model or the view. For example, you may want to invoke a method to check whether a user is allowed to log in. Use the following JSF tag:

     

     <h:commandButton value="Login" action="#{user.check}"/> 

    When the button is clicked and the form is submitted to the server, the JSF implementation invokes the check method of the user bean. That method can take arbitrary actions to update the model, and it returns the navigation ID of the next page to be displayed. We discuss this mechanism further in Chapter 3.

    Thus, JSF implements the classical model-view-controller architecture.

  • Data Conversion

    Users enter data into web forms as text. Business objects want data as numbers, dates, or other data types. As explained in Chapter 6, JSF makes it easy to specify and customize conversion rules.

  • Validation and Error Handling

    JSF makes it easy to attach validation rules for fields such as "this field is required" or "this field must be a number." Of course, when users enter invalid data, you need to display appropriate error messages. JSF takes away much of the tedium of this programming task. We cover validation in Chapter 6.

  • Internationalization

    JSF manages internationalization issues such as character encodings and the selection of resource bundles. We cover resource bundles in Chapter 2.

  • Custom Components

    Component developers can develop sophisticated components that page designers simply drop into their pages. For example, suppose a component developer produces a calendar component with all the usual bells and whistles. You just use it in your page, with a command such as

     

     <acme:calendar value="#{flight.departure}" startOfWeek="Mon"/> 

    Chapter 9 covers custom components in detail.

  • Alternative Renderers

    By default, JSF generates markup for HTML pages. But it is easy to extend the JSF framework to produce markup for another page description language such as WML or XUL. In Chapter 11, we show you how to use JSF to communicate with J2ME-powered cell phones.

  • Tool Support

    JSF is optimized for use with automated tools. As these tools mature in the coming years, we believe that JSF will be the must-have framework for developing web interfaces with Java.



core JavaServer Faces
Core JavaServer Faces
ISBN: 0131463055
EAN: 2147483647
Year: 2003
Pages: 121

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net