Chapter 9. Custom Components

   

Topics in This Chapter

  • "Implementing Custom Components with Classes" on page 352

  • "Encoding: Generating Markup" on page 358

  • "Decoding: Processing Request Values" on page 362

  • "Implementing Custom Component Tags" on page 368

  • "Revisiting the Spinner" on page 380

  • "Encoding JavaScript to Avoid Server Roundtrips" on page 400

  • "Using Child Components and Facets" on page 405

JSF provides a basic set of components for building HTML-based web applications such as text fields, checkboxes, buttons, and so on. However, most user-interface designers will desire more advanced components, such as calendars, tabbed panes, or navigation trees, that are not part of the standard JSF component set. Fortunately, JSF makes it possible to build reusable JSF components with rich behavior.

This chapter shows you how to implement custom components. We use two custom components a tabbed pane and a spinner, shown in Figure 9-1 to illustrate the various aspects of creating custom components.

Figure 9-1. The TabbedPane and the Spinner

graphics/09fig01.jpg


The JSF API lets you implement custom components and associated tags with the same features as the JSF standard tags. For example, h:input uses a value binding to associate a text field's value with a bean property you could use value bindings to wire calendar cells to bean properties. JSF standard input components fire value change events when their value changes you could fire value change events when a different date is selected in the calendar.

The first part of this chapter uses the spinner component to illustrate basic issues that you encounter in all custom components. We then revisit the spinner to show more advanced issues:

  • "Using an External Renderer" on page 380

  • "Calling Converters from External Renderers" on page 387

  • "Supporting Value Change Listeners" on page 388

  • "Supporting Method Bindings" on page 388

The second half of the chapter examines a tabbed pane component that illustrates the following aspects of custom component development.

  • "Processing SelectItem Children" on page 410

  • "Processing Facets" on page 411

  • "Encoding CSS Styles" on page 414

  • "Using Hidden Fields" on page 415

  • "Saving and Restoring State" on page 416

  • "Firing Action Events" on page 418



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