12.07.2015 Views

Beginning Java EE 6 with GlassFish 3, Second Edition

Beginning Java EE 6 with GlassFish 3, Second Edition

Beginning Java EE 6 with GlassFish 3, Second Edition

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 11 ■ PAGES AND COMPONENTSJSF has a more complex life cycle, and this is why, in the “Expression Language” section, I showedyou two different syntaxes: one using the dollar symbol (${expression}) and the other using the hash(#{expression}). $ is for expressions that can be executed immediately (when you know that the objectsin the expression are available), and # is for deferred expressions (which have to be evaluated later in thelife cycle).With JSF 1.2, both syntaxes were unified, but this led to much confusion and many errors. Forexample, if you use JSP as the PDL, you won’t have access to some JSF tags (such as the Facelets tags forexample). In this section, I will use Facelets as the PDL.Table 11-9 lists all the tag libraries that a Facelets PDL page can use. There are the functions andcore libraries that were in the JSTL sections, the Facelets tags (<strong>with</strong> the ui prefix), and new tags such asJSF’s core and html, and composite, which allows you to create custom components. Other JSTL tags(formatting, SQL, and XML actions) are not supported by Facelets.Table 11-9. Tag Libraries Allowed <strong>with</strong> Facelets PDLURICommonPrefixDescriptionhttp://java.sun.com/jsf/html h This tag library contains components andtheir HTML renderers (h:commandButton,h:commandLink, h:inputText, etc.).http://java.sun.com/jsf/core f This library contains custom actions that areindependent of any particular rendering(f:selectItem, f:validateLength,f:convertNumber, etc.).http://java.sun.com/jsf/facelets ui Tags in this library add templating support.http://java.sun.com/jsf/composite composite This tag library is used for declaring anddefining composite components.http://java.sun.com/jsp/jstl/core c Facelets pages can use some of the core JSPtag libraries (, , and).http://java.sun.com/jsp/jstl/functions fn Facelets pages can use all the function JSPtag libraries.Let’s focus on the JSF HTML components that will allow you to create rich web interfaces.Chapter 12 shows most of the JSF core library <strong>with</strong> converters and validators. But first let’s take a look atthe JSF page life cycle.Life CycleA JSF page is a component tree <strong>with</strong> a specific life cycle. You should understand it so you know whencomponents are validated or the model is updated. Clicking a button causes a request to be sent fromyour web browser to the server. This request is translated into an event that can be processed by your324

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!