JSF 2 0 cookbook

396 116 0
JSF 2 0 cookbook

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

www.it-ebooks.info JSF 2.0 Cookbook Over 100 simple but incredibly effective recipes for taking control of your JSF applications Anghel Leonard BIRMINGHAM - MUMBAI www.it-ebooks.info JSF 2.0 Cookbook Copyright © 2010 Packt Publishing All rights reserved No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews Every effort has been made in the preparation of this book to ensure the accuracy of the information presented However, the information contained in this book is sold without warranty, either express or implied Neither the author, Packt Publishing, nor its dealers or distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book Packt Publishing has endeavored to provide trademark information about all the companies and products mentioned in this book by the appropriate use of capitals However, Packt Publishing cannot guarantee the accuracy of this information First published: June 2010 Production Reference: 1310610 Published by Packt Publishing Ltd 32 Lincoln Road Olton Birmingham, B27 6PA, UK ISBN 978-1-847199-52-2 www.packtpub.com Cover Image by Prasad Hamine (hamine_p@hotmail.com) www.it-ebooks.info Credits Author Anghel Leonard Reviewer Edem Morny Acquisition Editor Sarah Cullington Development Editor Rakesh Shejwal Technical Editor Arani Roy Indexer Hemangini Bari Editorial Team Leader Mithun Sehgal Project Team Leader Lata Basantani Project Coordinator Poorvi Nair Proofreader Chris Smith Production Coordinator Shantanu Zagade Cover Work Shantanu Zagade www.it-ebooks.info About the Author Anghel Leonard is a senior Java developer with more than 12 years of experience in Java SE, Java EE, and the related frameworks He has written and published more than 20 articles and 100 tips and tricks about Java technology Also, he has written two books about XML and Java (one for beginners and one for advanced users) and another book for Packt Publishing, named JBoss Tools Developer Guide In this time, he has developed web applications using the latest technologies out in the market In the past two years, he has focused on developing RIA projects for GIS fields He is interested in bringing as much desktop to the Web as possible; as a result GIS applications present a real challenge to him I would like to thank my family, especially, my wife! www.it-ebooks.info About the Reviewer Edem Morny has been involved in enterprise Java technologies since he got introduced to Java in 2005, using tools and technologies encompassing both the standard JavaEE stack and non-standard ones such as JBoss Seam, Hibernate, and Spring His experience with JSF includes working with plain JSF, RichFaces, JBoss Seam, and Spring Web Flow's SpringFaces He has been an active promoter of Java EE, speaking at workshops and seminars of a national scale in Ghana He is a Senior Developer at the Application Development Center in Accra, Ghana, for an international biometric security solutions company, which is leading the development of Biocryptic Identity Management Systems for the global market Edem was a technical reviewer for JBoss Tools Developer Guide and JBoss AS Development both published by Packt Publishing You'll find him blogging at http://edemmorny.wordpress.com www.it-ebooks.info www.it-ebooks.info Table of Contents Preface Chapter 1: Using Standard and Custom Converters in JSF Introduction Working with implicit and explicit conversions Standard converters for numbers Standard converters for date and time Converters and NULL values Creating and using a custom converter Using custom converters for h:selectOneMenu Binding converters to backing bean properties RichFaces and standard converters RichFaces and custom converters Instance variables in converters Client-side converters with MyFaces Trinidad Chapter 2: Using Standard and Custom Validators in JSF Introduction Using a standard validator Customizing error messages for validators Creating a custom validator Binding validators to backing bean properties Validating forms with RichFaces rich:beanValidator Validating forms with RichFaces rich:ajaxValidator Apache MyFaces Commons validators Bean validation with f:validateBean Enforcing a value's presence with f:validateRequired Using regular expressions with f:validateRegex www.it-ebooks.info 10 12 15 19 22 25 30 32 34 36 40 51 52 53 55 58 61 63 65 67 68 76 78 Table of Contents Chapter 3: File Management Introduction Downloading files using Mojarra Scales Multi-file upload using Mojarra Scales File upload with Apache MyFaces Tomahawk AJAX multi-file upload with RichFaces Downloading with PrimeFaces 2.0 PPR multi-file upload with PrimeFaces 2.0 Extracting data from an uploaded CSV file Exporting data to Excel, PDF, CVS, and XML 81 81 81 85 88 93 97 100 104 109 Chapter 4: Security 113 Chapter 5: Custom Components 129 Chapter 6: AJAX in JSF 201 Introduction Working with the JSF Security project Using the JSF Security project without JAAS Roles Using secured managed beans with JSF Security Using Acegi/Spring security in JSF applications Introduction Building a "HelloWorld" JSF custom component Renderers/validators for custom components Adding AJAX support to JSF custom components Using Proxy Id library for dynamic IDs Using JSF ID Generator Accessing resources from custom components Custom components with Archetypes for Maven RichFaces CDK and custom components Composite custom components with zero Java Creating a login composite component in JSF 2.0 Building a spinner composite component in JSF 2.0 Mixing JSF and Dojo widget for custom components Introduction A first JSF 2.0-AJAX example Using the f:ajax tag Installing and using Dynamic Faces in NetBeans 6.8 Using the inputSuggestAjax component ajax4jsf—more than 100 AJAX components Writing reusable AJAX components in JSF 2.0 PrimeFaces, CommandLink, and CommandButton ii www.it-ebooks.info 113 113 116 121 123 129 131 138 144 161 163 167 169 173 187 190 193 195 201 201 204 205 208 211 221 223 Table of Contents Chapter 7: Internationalization and Localization 229 Chapter 8: JSF, Images, CSS, and JS 243 Chapter 9: JSF—Managing and Testing 279 Chapter 10: Facelets 301 Introduction Loading message resource bundles in JSF Using locales and message resource bundles Message resource bundles without f:loadBundle Working with parameterized messages Accessing message resource keys from a class Providing a theme to a Visual Web JSF Project Displaying Arabic, Chinese, Russian, and so on Selecting a time zone in JSF 2.0 Introduction Injecting CSS in JSF JSF, CSS, and tables JSF and dynamic CSS Integrating JavaScript and JSF Getting a JSF inputText value from JavaScript Working with JSF hidden fields from JavaScript Passing parameters from JS to JSF (client to server) Passing parameters from JSF to JS (server to client) Opening a pop-up window using JSF and JS Passing parameters with HTTP GET within the URL Communication between parent pop-up windows Populating a JS load function with JSF values Dynamic images with PrimeFaces Cropping images with PrimeFaces Working with rss4jsf project Using resource handlers Introduction Managing JSF with Faces Console Testing JSF applications with JSFUnit JSFUnit and Ant JSFUnit API A JSF and JMeter issue Working with JSF Chart Creator Introduction Installing Facelets under JSF 1.2 (or JSF 1.1) Facelets aliasing components 229 230 231 233 234 236 240 241 242 244 244 246 248 251 253 254 256 257 258 260 262 267 269 270 273 275 279 279 283 289 292 295 297 301 302 303 iii www.it-ebooks.info ... under JSF 1 .2 (or JSF 1.1) Facelets aliasing components 22 9 23 0 23 1 23 3 23 4 23 6 24 0 24 1 24 2 24 4 24 4 24 6 24 8 25 1 25 3 25 4 25 6 25 7 25 8 26 0 26 2 26 7 26 9 27 0 27 3 27 5 27 9 27 9 28 3 28 9 29 2 29 5 29 7 301 3 02 . .. double value 123 45. 123 45Format as 00 000 .00 000 : 123 45. 123 45 Format as 00 000 : 12, 345 Format as currency: $ 12, 345. 12 Format as percent: 34,5 12. 345% Format as pattern ##### ,00 %: 1 ,23 ,45, 12% How it works... timeJun 15, 20 09 Monday, June 15, 20 09 11:14:53 AM GMT 15/14 / 20 09 20 09-14-15 20 09 .06 .15 at 11:14:53 GMT 11:14 AM June 15, 20 09 6:14:53 AM 15 iunie 20 09 11:14:53 GMT Montag, 15 Juni 20 09 11:14 See

Ngày đăng: 13/03/2019, 10:45

Mục lục

    Chapter 1: Using Standard and Custom Converters in JSF

    Working with implicit and explicit conversions

    Standard converters for numbers

    Standard converters for date and time

    Converters and NULL values

    Creating and using a custom converter

    Using custom converters for h:selectOneMenu

    Binding converters to backing bean properties

    RichFaces and standard converters

    RichFaces and custom converters

Tài liệu cùng người dùng

Tài liệu liên quan