facelets - javaserver faces

Download Facelets - JavaServer Faces

Post on 03-Apr-2015

261 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

Facelets - JavaServer Faces View Definition Framework

https://facelets.dev.java.net/nonav/docs/dev/docbook.html

Facelets - JavaServer Faces View Definition FrameworkDeveloper DocumentationJacob Hookom Editing and bug fixes: Ed Burns Editing: Hiroshi Iwatani 1.0.0

Table of Contents Introduction Documentation Guide 1. Getting Started with Facelets 1.1. Downloading Facelets 1.2. Dependencies 1.3. Directory Structure 1.4. Project Setup 1.4.1. Web.xml Descriptor 1.4.2. Faces-Config.xml 1.5. The NumberBean 1.5.1. The Java Code 1.5.2. Faces Bean Descriptor 1.6. Creating Web Pages 1.6.1. The Page Template - template.xhtml 1.6.2. Configuring User Input - guess.xhtml 1.6.3. Displaying the Response - response.xhtml 1.7. Handling Navigation 1.8. Deployment 2. Configuration 2.1. Configuring JavaServer Faces 2.1.1. JavaServer Faces RI 2.1.2. Apache MyFaces 2.2. Web Application Descriptors 2.2.1. Initialization Parameters 2.2.2. Security 2.3. Logging 3. Tag Libraries 3.1. Using Tags 3.1.1. Tag Namespaces 3.1.2. Using 'jsfc' 3.1.3. Unresolved Namespaces 3.2. Available Tag Libraries 3.2.1. JavaServer Faces Specification 3.2.2. Templating Library 3.2.3. JSTL Support 3.2.4. Oracle ADF Faces 3.3. Functions 3.4. Loading Libraries 3.5. Creating Tag Libraries 3.5.1. Tag Library Schema 3.5.2. UIComponents 3.5.3. Validators 3.5.4. Converters 3.5.5. Tag (Source) Files 3.5.6. Custom Tags 3.5.7. Function Specification 4. Expression Language 4.1. Inlining Text 4.2. EL Lifecycle

1 de 31

4/12/2010 22:20

Facelets - JavaServer Faces View Definition Framework

https://facelets.dev.java.net/nonav/docs/dev/docbook.html

5. Templating and Re-Use 5.1. Template/Client Relationships 5.1.1. Wrapping Content within a Template 5.1.2. Piecemeal Content within a Template 5.1.3. Multi-Level Templating 5.2. 5.3. 5.4. 5.5. 5.6. 5.7. 5.8. 5.9. 5.10. 5.11. 5.12. 6. Facelets Architecture 6.1. View Creation 6.2. Facelets API 6.2.1. FaceletFactory 6.2.2. Facelet 6.2.3. FaceletHandler 6.3. Document Compiler 7. Extending Facelets 7.1. Tag Development Overview 7.2. Custom TagHandlers 7.3. Meta Tags 7.3.1. Custom ComponentHandlers 7.3.2. Custom ValidateHandlers 7.3.3. Custom ConvertHandlers 7.4. FaceletViewHandler 7.5. Tag Decorators 8. Building Facelets 8.1. Using Ant 8.2. IDE Integration

IntroductionThe web community is eagerly seeking a light-weight, templating framework backed by JavaServer Faces as the industry standard. While JavaServer Faces and JavaServer Pages technology (JSP) are meant to be aligned, Facelets steps outside of the JSP specification and provides a highly performant, JSF-centric view technology. Anyone who has created a JSP page will be able to do the same with Facelets and familiar XML-tag use. The difference is under the hood where all the burden of the JSP vendor API is removed to greatly enhance JSF as a platform and provide easy plug-and-go development without requiring JSP tag development. JavaServer Faces UIComponents are first class citizens within Facelets; there's no need to develop extra objects to integrate. There's also no need to learn yet another XML schema to define your views. Facelets includes many features such as: Works with JSF 1.1 and JSF 1.2, including Sun's RI and Apache MyFaces. Zero Tag development time for UIComponents Fast Templating/Decorators for Components and Pages The ability to specify UIComponent trees in separate files (UICompositions) Line/Tag/Attribute precise Error Reporting Specify Tags in Separate Files, even packaged with Jars Full EL support, including Functions Build-time EL Validation XML configuration files aren't necessary Reserves the 'jsfc' attribute which acts the same as Tapestry's jwcid (Example: )

Plugable Decorators to really make designer's job easy (Example: transform to at compile time) Works with any RenderKit Facelet APIs aren't dependent on a Web Container Everyone wants to be more designer friendly, and Tapestry seems to be the only choice developers are pursuing. On the other hand,

2 de 31

4/12/2010 22:20

Facelets - JavaServer Faces View Definition Framework

https://facelets.dev.java.net/nonav/docs/dev/docbook.html

JSF is the standard everyone would like to have happen, but JSF needs a more "pluggable" ViewHandler framework that is both designer and developer friendly. Out of the box, Facelets provides full support for all components specified in the JavaServer Faces specification, including limited support for JSTL tags such as and . Where developers really gain an advantage with using Facelets is its ability to auto-wire additional artifacts to your XML documents such as UIComponents, Validators, and Converters. Facelets is a clean slate for correcting concerns with JSF. Templating, re-use, and ease of development are top priorities that will help bring developers on board with JSF as a suitable platform for large scale projects.

Documentation GuideTo get a jump start on development, this guide covers varying degrees of depth. Please follow these steps: Chapter 1, Getting Started with Facelets as an entry-level tutorial on using JavaServer Faces and Facelets together. All of the content in this section is generic to Faces with the exception of Section 1.6, Creating Web Pages. This section describes the simplest Facelets templating scenario that could possibly work. Chapter 2, Configuration for details on setting up your web application for use with Facelets. Chapter 3, Tag Libraries for incorporating JSF objects into Facelet documents as tags. Chapter 5, Templating and Re-Use to learn about how Facelets encourages templating and re-use in your documents. Chapter 6, Facelets Architecture as an overview to the Facelets API and compiler. Chapter 7, Extending Facelets as a starting point for extending Facelets functionality with custom tag handlers. Additional documentation and resources such as: mailing lists, forums, and announcements, are available on Facelets' home page at: http://facelets.dev.java.net

Chapter 1. Getting Started with Facelets Tutorial GoalsThis section will walk you through creating a simple Number Guess web application. Familiarity with Java Web Applications is required along with some knowledge of JavaServer Faces. For those who are new to those technologies, you can browse: Java Web Applications - http://www.onjava.com/pub/a/onjava/2001/03/15/tomcat.html JavaServer Faces - http://java.sun.com/j2ee/javaserverfaces/ The steps in this tutorial are as follows: 1. Section 1.1, Downloading Facelets for downloading Facelets binaries or for accessing Facelets source code from CVS. 2. Section 1.2, Dependencies will provide an overview of libraries needed to use JavaServer Faces with Facelets 3. Section 1.3, Directory Structure shows the familiar directory structure you should use for this tutorial 4. Section 1.4, Project Setup has initial configuration settings you need to get up and running 5. Section 1.5, The NumberBean details the one JavaBean our tutorial requires and how to use it in JavaServer Faces 6. Section 1.6, Creating Web Pages shows how to create and use a template within JavaServer Faces components 7. Section 1.7, Handling Navigation includes how to tie your views together 8. Section 1.8, Deployment finishes off the tutorial with deploying your application While this tutorial is a little basic for some, you may want to jump back to Documentation Guide for direction.

3 de 31

4/12/2010 22:20

Facelets - JavaServer Faces View Definition Framework

https://facelets.dev.java.net/nonav/docs/dev/docbook.html

1.1. Downloading FaceletsFacelets is currently available as a sub-project of the JavaServer Faces Reference Implementation on Java.net (http://facelets.dev.java.net/). You have a couple options for downloading Facelets: Download a release binary from http://facelets.dev.java.net/servlets/ProjectDocumentList. Once downloaded, unzip the project into an appropriate folder. If you are a member of Java.net, you may checkout Facelets from CVS. Make sure you are located in the appropriate directory and use the following CVS commands (Replace USER_NAME with your Java.net Member Login Name): 1. cvs -d :pserver:USER_NAME@cvs.dev.java.net:/cvs login 2. cvs -d :pserver:USER_NAME@cvs.dev.java.net:/cvs checkout facelets More information on accessing Java.net's CVS repository is located at http://facelets.dev.java.net/servlets/ProjectSource. See Chapter 8, Building Facelets for more information on building Facelets from source (specifically if you used CVS).

1.2. DependenciesFacelets will work with both version 1.1 and 1.2 of JavaServer Faces and makes no bearing on the implementation used. Facelets also uses the new EL-API and again can be used with any implementation of that API. Please reference the table below to make sure your dependencies are available to Facelets: Table 1.1. Facelets Dependencies Project JavaServer Faces RI Build Included? Req? No No Description The reference implementation of JSF 1.1 and JSF 1.2 are available for use with your application. The alternative to the JSF reference implementation. MyFaces currently implements the JSF 1.1 specification. JSF 1.2 API that works with the new EL Specification. This API is packaged with the JavaServer Faces RI and available on Java.net. The standardized EL specification that is standalone from JSP or JSF, but used by both frameworks. The reference implementation that is used by Facelets for handling EL. This dependency should not be an issue for most deployments as it's a standard part of web containers and JREs. Link

http://javaserverfaces.dev.java.net/

Apache MyFaces

No

No

http://myfaces.apache.org/

JavaServer Faces 1.2 API

Yes

No

http://javaserverfaces.dev.java.net/

EL API

Yes

Yes

http://glassfish.dev.java.net/