Jsf tags

Solo disponible en BuenasTareas
  • Páginas : 29 (7111 palabras )
  • Descarga(s) : 0
  • Publicado : 25 de abril de 2011
Leer documento completo
Vista previa del texto
STANDARD JSF TAGS

Topics in This Chapter • “An Overview of the JSF Core Tags” on page 86 • “An Overview of the JSF HTML Tags” on page 87 • “Forms” on page 96 • “Text Fields and Text Areas” on page 100 • “Buttons and Links” on page 111 • “Selection Tags” on page 122 • “Messages” on page 149 • “Panels” on page 154

Chapter

4

Development of compelling JSF applications requires a goodgrasp of the JSF tag libraries—core and HTML—that represent a combined total of 43 tags. Because of their prominence in the JSF framework, this chapter and the next— Data Tables—provide in-depth coverage of those tags, their attributes, and how you can best use them. Even simple JSF pages use tags from both libraries. Many JSF pages have a structure similar to this:
...

To use the JSF taglibraries, you must import them with taglib directives, as in the preceding code fragment. You can choose any name you want for the prefixes. The convention is f and h, for the core and HTML libraries, respectively. This chapter starts with a brief look at the core library. That library, with 18 tags, is smaller than its HTML sibling, which has 25. It’s also considerably simpler than the HTMLlibrary. Because of that simplicity and because most of the core tags are discussed elsewhere in this book, the overwhelming majority of this chapter focuses on the HTML library.
85

86

Chapter 4 I Standard JSF Tags

We begin our exploration of the HTML library with a look at common attributes shared by most JSF HTML tags. Then we discuss each tag individually with attribute tables forreference and useful code examples that you can adapt to your own applications.
NOTE: The core library has 2.8 attributes per tag—the HTML library has 26.2.

An Overview of the JSF Core Tags
The core library is the poor stepchild of the HTML library—the former exists entirely to support the latter. The core tags are listed in Table 4–1.
Table 4–1 Tag view subview facet attribute param actionListenervalueChangeListener convertDateTime convertNumber validator validateDoubleRange validateLength validateLongRange loadBundle selectitems selectitem verbatim JSF Core Tags Description Creates the top-level view Creates a subview of a view Adds a facet to a component Adds an attribute (key/value) to a component Adds a parameter to a component Adds an action listener to a component Adds a valuechangelistener to a component Adds a datetime converter to a component Adds a number converter to a component Adds a validator to a component Validates a double range for a component’s value Validates the length of a component’s value Validates a long range for a component’s value Loads a resource bundle, stores properties as a Map Specifies items for a select one or select many component Specifies anitem for a select one or select many component Adds markup to a JSF page

An Overview of the JSF HTML Tags

87

Most of the core tags represent objects you add to components: • • • • • • • Attributes Listeners Converters Validators Facets Parameters Select items

The core library also contains tags for defining views and subviews, loading resource bundles, and adding arbitrary text to a page.All of the core tags are discussed at length elsewhere in this book.
NOTE: All tag attributes, except for var and id, accept value reference expressions. The majority of those expressions represent value bindings; a handful represent method bindings.

An Overview of the JSF HTML Tags
JSF HTML tags represent the following kinds of components: • • • • • Inputs Outputs Commands Selection OthersThe Others category includes forms, messages, and components that layout other components. Table 4–2 lists all the HTML tags.
Table 4–2 Tag form inputText inputTextarea inputSecret JSF HTML Tags Description HTML form Single-line text input control Multiline text input control Password input control

88

Chapter 4 I Standard JSF Tags

Table 4–2 Tag inputHidden outputLabel outputLink...
tracking img