Mastering JavaServer Faces 2.2
Book information
Description
About This Book Fortify your JSF solutions by combing the powers of JSF 2.x (2.0, 2.1, and 2.2) Get acquainted with the newly introduced features in JSF 2.2, such as the faces flow, stateless views, pass-through attributes and resource library contracts Browse through over 300 well defined JSF applications presented in a concise and clear cut approach Who This Book Is For If you are a web developer who uses JSF, this is the book for you. Catering to an intermediate-advanced audience, the book assumes you have fundamental knowledge of JSF. It is intended for the developer who wants to improve their skills with the combined power of JSF 2.0, 2.1, and 2.2. What You Will Learn Discover how to write custom JSF 2.2 themes, custom factories, handlers, renderers, and components Access unlimited developing scenarios with the concept of dependency injection Enhance your applications with JSF 2.2 upload component and HTML5 friendly markup Master the new JSF 2.2 Window ID technique Gain insights into managing the application state with stateless viewsExplore the new CDI @ViewScoped and @FlowScoped (detailed presentation) In Detail JavaServer Faces (JSF) is a leading framework and core component of Java Platform Enterprise Edition. JSF is the standard Java EE technology used to build web user interfaces. JSF 2.2 is a recent release with an extensive list of new features, some of which have been expected for a long time and are now ready to be implemented. Starting out with a very basic topic, Expression Language, you will continue onwards covering a wide range of JSF sectors, such as JSF communication, JSF scopes, and so on. Throughout the book, you will master JSF artifacts (AJAX, HTML5, configurations, renders, handlers, listeners, events, factories, tabular data, custom components, Facelets, and so on) in a compendium of programming practices and informative examples. You then round off with a detailed discussion on the capabilities of Facelets. Overall, this book helps you gain knowledge on the latest JSF features in an interesting and original approach. Adding these skills to your personal arsenal will turn you into a veritable JSF master. Cover......Page 1 Copyright......Page 3 Credits......Page 4 About the Author......Page 5 About the Reviewers......Page 6 www.PacktPub.com......Page 9 Table of Contents......Page 10 Preface......Page 18 Chapter 1: Dynamic Access to JSF Application Data through Expression Language (EL 3.0)......Page 24 EL operators......Page 25 EL reserved words......Page 26 Referencing a managed bean......Page 27 Referencing a managed bean's properties......Page 29 Referencing a managed bean's nested properties......Page 30 Referencing Java SE enumerated types......Page 32 Referencing collections......Page 33 EL implicit objects......Page 34 EL method expressions......Page 36 The conditional text in JSF......Page 38 Writing a custom EL resolver......Page 43 EL 3.0 overview......Page 52 Exploring lambda expressions......Page 53 Working with collection objects......Page 55 Summary......Page 57 Chapter 2: Communication in JSF......Page 58 Passing request parameters with the tag......Page 59 Working with view parameters......Page 63 Calling actions on GET requests......Page 70 Passing attributes with the tag......Page 75 Setting property values via action listeners......Page 78 Passing parameters using the Flash scope......Page 81 Replacing the tag with the JSTL tag......Page 86 Sending data through cookies......Page 87 Sending passwords......Page 89 Accessing UI component attributes programmatically......Page 90 Passing parameters via method expressions......Page 91 Communicating via the binding attribute......Page 92 Managed bean communication......Page 93 Injecting a managed bean into another bean......Page 94 Communication between managed beans using the application/session map......Page 95 Accessing other managed beans programmatically......Page 97 Summary......Page 99 JSF scopes versus CDI scopes......Page 100 The request scope......Page 103 The session scope......Page 107 The view scope......Page 109 The application scope......Page 111 The conversation scope......Page 113 The flow scope......Page 117 The simple flow......Page 121 Flows with beans......Page 124 Nested flows......Page 127 Configuring flows programmatically......Page 131 Flows and navigation cases......Page 133 Inspecting flow navigation cases......Page 136 Using the initializer and finalizer......Page 137 Using the flow switch......Page 140 Packaging flows......Page 142 Programmatic flow scope......Page 143 Dependent pseudo-scope......Page 147 The custom scope......Page 148 Writing the custom scope class......Page 149 Resolving a custom scope EL expression......Page 150 Controlling the custom scope lifespan with action listeners......Page 154 Controlling the custom scope lifespan with the navigation handler......Page 156 Beans injection......Page 159 Summary......Page 162 Chapter 4: JSF Configurations Using XML Files and Annotations – Part 1......Page 164 JSF 2.2 new namespaces......Page 165 JSF 2.2 programmatic configuration......Page 166 Configuring managed beans in XML......Page 167 Working with multiple configuration files......Page 173 Configuring locales and resource bundles......Page 175 Configuring validators and converters......Page 177 Configuring navigation......Page 185 Implicit navigation......Page 186 Conditional navigation......Page 189 Preemptive navigation......Page 191 Programmatic Navigation......Page 193 Configuring action listeners......Page 195 Application action listeners......Page 197 Using ......Page 200 Implementing SystemEventListener......Page 202 Configuring phase listeners......Page 208 Working with @ListenerFor and @ListenersFor......Page 213 Summary......Page 214 Chapter 5: JSF Configurations Using XML Files and Annotations – Part 2......Page 216 Configuring resource handlers......Page 217 Adding CSS and JS resources programmatically......Page 224 Configuring the view handler......Page 225 Overriding JSF renders......Page 229 Working with client behavior functionality......Page 235 JSF factories......Page 240 Configuring the global exception handler......Page 241 Configuring RenderKit factory......Page 244 Configuring PartialViewContext......Page 246 Configuring visitContext......Page 249 Configuring ExternalContext......Page 252 Configuring Flash......Page 256 JSF 2.2 Window ID API......Page 257 Configuring lifecycle......Page 263 Configuring the application......Page 267 Configuring VDL......Page 269 Combined power of multiple factories......Page 271 Summary......Page 272 Chapter 6: Working with Tabular Data......Page 274 Creating a simple JSF table......Page 275 The CollectionDataModel class of JSF 2.2......Page 278 Sorting tables......Page 283 Sorting and DataModel – CollectionDataModel......Page 289 Deleting a table row......Page 292 Editing/updating a table row......Page 294 Adding a new row......Page 297 Displaying row numbers......Page 299 Selecting a single row......Page 300 Selecting multiple rows......Page 302 Nesting tables......Page 304 Paginating tables......Page 305 Generating tables with the JSF API......Page 312 Filtering tables......Page 317 Alternate row colors with the rowclasses attribute......Page 323 Highlighting rows on mouse hover......Page 324 Highlighting rows on mouse click......Page 325 Summary......Page 326 Chapter 7: JSF and AJAX......Page 328 A simple JSF-AJAX example to get started......Page 329 The JSF-AJAX attributes......Page 330 The execute and render attributes......Page 331 The listener attribute......Page 333 The event attribute......Page 334 The onevent attribute – monitoring AJAX state on client......Page 335 The onerror attribute – monitoring AJAX errors on client......Page 337 Grouping components under tag......Page 339 Updating input fields with AJAX after validation error......Page 340 The Cancel and Clear buttons......Page 342 Value submitted to a view scoped managed bean......Page 343 Value submitted to a request scoped managed bean......Page 344 Mixing AJAX and flow scope......Page 346 Postback and AJAX......Page 350 Postback request's conditional rendering/executing......Page 352 Is it a non-AJAX request?......Page 355 Queue control for AJAX requests......Page 357 Explicit loading of jsf.js......Page 359 Depicting the params value......Page 360 Non-UICommand components and jsf.ajax.request......Page 361 Customizing jsf.js......Page 364 AJAX and the progress bar/indicator......Page 367 Summary......Page 369 Working with HTML5 and JSF 2.2......Page 370 Pass-through attributes......Page 371 Pass-through elements......Page 373 JSF 2.2 – HTML5 and Bean Validation 1.1 (Java EE 7)......Page 375 JSF 2.2 upload feature......Page 376 A simple JSF 2.2 upload example......Page 378 Using multiple elements......Page 380 Extracting info about a file to be uploaded......Page 381 Writing uploaded data to a disk......Page 383 Upload validator......Page 385 Ajaxify the upload......Page 386 Uploading images with preview......Page 387 Uploading multiple files......Page 395 Upload and the indeterminate progress bar......Page 398 Upload and the determinate progress bar......Page 400 Summary......Page 404 JSF saving the view state......Page 406 Partial state saving and tree visiting......Page 407 JSF saving view state on the server or client......Page 408 JSF logical and physical views......Page 411 Saving the state in a database – an experimental application......Page 412 Writing the custom ResponseStateManager class......Page 415 Adding MongoDB in equation......Page 417 Handling ViewExpiredException......Page 420 Server-state serialization in a session......Page 423 JSF 2.2 is stateless......Page 424 The view scoped beans and the stateless feature......Page 426 JSF security notes......Page 428 SQL injection......Page 429 Summary......Page 430 Chapter 10: JSF Custom Components......Page 432 Building noncomposite custom components......Page 433 Writing a custom tag handler......Page 436 Dissecting a custom component......Page 437 Custom component implementation......Page 440 Building composite components......Page 450 Developing the Temperature composite component......Page 453 Transforming a jQuery component into composite component......Page 457 Writing the HTML5 date picker as a composite component......Page 463 Decorating an image with actions......Page 467 Working with composite facets......Page 469 Validating/converting inputs inside composite components......Page 471 Null values within a composite component's attributes......Page 473 Hiding pass-through attributes in composite components......Page 474 Counting the children of a composite component......Page 476 Top-level component's pitfall......Page 477 Distributing composite components as JARs in JSF 2.2......Page 478 Adding composite components programmatically......Page 480 Summary......Page 482 Chapter 11: JSF 2.2 Resource Library Contracts – Themes......Page 484 Working with contracts......Page 485 Styling tables with contracts......Page 488 Styling UI components with contracts......Page 491 Styling contracts across different devices......Page 493 Writing contracts for composite components......Page 498 Writing a theme switcher......Page 500 Configuring contracts in XML......Page 508 Packaging contracts in JARs......Page 509 Summary......Page 510 A brief overview of the Facelets tags......Page 512 Creating a simple template – PageLayout......Page 515 Passing parameters via ......Page 518 Passing bean properties and action methods via ......Page 520 Exploiting the and tags......Page 522 Iterating with ......Page 525 Working with and ......Page 528 Working with and ......Page 530 Removing the content with ......Page 533 Using the jsfc attribute......Page 535 Extending the PageLayout template......Page 536 Working with FaceletCache......Page 541 ResourceResolver swallowed by ResourceHandler......Page 544 Include Facelets programmatically......Page 548 Creating a TagHandler class......Page 549 Writing custom Facelets taglib functions......Page 551 AJAX and ......Page 553 Exemplifying versus ......Page 554 Exemplifying versus ......Page 555 Summary......Page 556 Appendix: The JSF Life Cycle......Page 558 Index......Page 560
Similar books
Java Coding Problems: Become an expert Java programmer by solving over 250 brand-new, modern, real-world problems
2024 · PDF
Java Coding Problems: Become an expert Java programmer by solving modern real-world problems
2024 · EPUB
jOOQ Masterclass: A practical guide for Java developers to write SQL queries for complex database interactions
2022 · PDF
jOOQ Masterclass: A practical guide for Java developers to write SQL queries for complex database interactions
2022 · EPUB
jOOQ Masterclass: A practical guide for Java developers to write SQL queries for complex database interactions
2022 · PDF
The Complete Coding Interview Guide in Java: An effective guide for aspiring Java developers to ace their programming interviews
2020 · PDF
Java Coding Problems: Improve your Java Programming skills by solving real-world coding challenges
2019 · PDF
The Complete Coding Interview Guide in Java
2020 · EPUB