Facelets Essentials.pdf

(1002 KB) Pobierz
32015006 UNPDF
Available as a
PDF Electronic Book
or Print On Demand
Essentials
Guide to JavaServer Faces View
Definition Framework
88
PAGES
Bruno Aranda and Zubin Wadia
Facelets
32015006.024.png 32015006.025.png 32015006.026.png 32015006.027.png 32015006.001.png 32015006.002.png 32015006.003.png 32015006.004.png 32015006.005.png 32015006.006.png 32015006.007.png 32015006.008.png 32015006.009.png 32015006.010.png 32015006.011.png 32015006.012.png 32015006.013.png 32015006.014.png 32015006.015.png 32015006.016.png 32015006.017.png
About firstPress
Apress’s firstPress series is your source for understanding cutting-edge technology. Short, highly focused, and
written by experts, Apress’s firstPress books save you time and effort. They contain the information you could get
based on intensive research yourself or if you were to attend a conference every other week—if only you had the
time. They cover the concepts and techniques that will keep you ahead of the technology curve. Apress’s firstPress
books are real books, in your choice of electronic or print-on-demand format , with no rough edges even when the
technology itself is still rough. You can't afford to be without them.
Facelets Essentials: Guide to JavaServer™ Faces View
Definition Framework
Dear Reader,
As seasoned JavaServer™ Faces (JSF™) veterans, it has long been our desire to publish a book that helps our
community to do JSF applications right. Without a doubt, one of the most instrumental technologies in making JSF a
reality in production environments is the Facelets framework. Many, many JSF applications have been written
without leveraging this critical framework, resulting in high performance overhead and causing developers and
project stakeholders plenty of stomach acid. We emphatically aim to correct this.
Our book focuses on helping you to fully leverage this powerful Facelets view definition framework within your JSF
applications. After absorbing the material in this book, you will be able to write JSF view tiers with greater efficiency
and yield better performance out of your applications, as compared to similar applications leveraging classic JSP™
API. The patterns we encourage in this book are a result of our nine years’ cumulative experience with JSF across
three of the major Reference Implementations—Sun™, MyFaces and IBM.
Writing this book about Facelets wouldn’t have been possible, of course, if Jacob Hookom hadn’t founded the project
back in 2005. Since then, the project has been growing successfully with the help of the community and has become
the de facto standard for JSF view definition and for the upcoming JSF2.0 release. We thank Jacob for blessing this
initiative and allowing us to bring Facelets out to an even wider audience.
We would also like to thank Martin Marinschek for the ideas, insight, and experience he generously lent to this
initiative. Additionally, we would like to acknowledge Wolf Benz, who tried our code samples and provided valuable
feedback. We look forward to you enjoying this book and benefiting from our experiences!
Best regards,
Bruno Aranda and Zubin Wadia
Contents
Facelets ..................................................................................... 1
Why Use Facelets ......................................................................................... 2
Creating an Application with Facelets ........................................................ 3
Downloading Facelets ................................................................................... 3
Adding Dependencies.................................................................................... 5
Creating a Project Structure .......................................................................... 6
Configuring the Web Descriptor (web.xml) ................................................. 7
Configuring the Faces Descriptor (faces-config.xml)................................. 10
Creating JSF Views ..................................................................................... 10
Unified Expression Language ................................................................... 21
Inline Text ................................................................................................... 22
Tag Libraries .............................................................................................. 22
Loading the Tag Libraries ........................................................................... 24
The jsfc Attribute ........................................................................................ 30
Facelets Templating and Template Clients............................................... 31
Facelets Tag Reference .............................................................................. 32
<ui:component/> ......................................................................................... 32
<ui:composition/> ....................................................................................... 33
<ui:debug/> ................................................................................................. 34
<ui:decorate/>.............................................................................................. 35
<ui:define/> ................................................................................................. 38
<ui:fragment/>............................................................................................. 39
<ui:include/> ............................................................................................... 40
<ui:insert/> .................................................................................................. 41
32015006.018.png
<ui:param/> ................................................................................................. 44
<ui:remove/> ............................................................................................... 47
<ui:repeat/> ................................................................................................. 48
Creating Composition Components........................................................... 49
Creating the inputTextLabeled Custom Component................................... 50
Creating the simpleColumn Custom Component ....................................... 54
Creating the scrollableDataTable Custom Component............................... 57
Creating the editableColumn Custom Component ..................................... 63
Reusing the Custom Tag Library ................................................................ 66
Using Source Files from Other JAR Libraries ............................................ 67
Extending Facelets ..................................................................................... 69
Facelets Architecture ................................................................................... 69
Custom Tag Development........................................................................... 71
Using Metatags............................................................................................ 75
Extending the ViewHandler ...................................................................... 83
ii
Facelets Essentials
32015006.019.png 32015006.020.png 32015006.021.png
Facelets Essentials: Guide to
JavaServer™ Faces View
Definition Framework
by Bruno Aranda and Zubin Wadia
Facelets is a templating language developed from the ground up with
JavaServer™ Faces (JSF™) in mind. Because Facelets has come about as a
result of many of the concerns with JavaServer™ Pages (JSP™) API when
building JSF views, it steps outside of the JSP specification and provides a
highly performant, JSF-centric view technology. Its top properties are
templating, code reuse, and ease of development.
Focusing on these priorities allows Facelets to help make JSF suitable for
large-scale projects. For example, one of the first things a Facelets
developer finds is that the technology immediately leads to a reduction in
user interface (UI) code. Take our advice: use Facelets in your applications
instead of JSP. In this book, we will show you how to maximize your JSF
productivity with Facelets by leveraging it the right contexts.
Facelets Essentials
iii
32015006.022.png 32015006.023.png
Zgłoś jeśli naruszono regulamin