Mastering JavaServer Faces 2.2
eBook - ePub

Mastering JavaServer Faces 2.2

  1. 578 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Mastering JavaServer Faces 2.2

About this book

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.

Approach

A homogenous guide integrating the features of JSF 2.x (2.0, 2.1 and 2.2), following a learning through examples paradigm with its main focus on the advanced concepts of JSF.

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.

Tools to learn more effectively

Saving Books

Saving Books

Keyword Search

Keyword Search

Annotating Text

Annotating Text

Listen to it instead

Listen to it instead

Information

Mastering JavaServer Faces 2.2


Table of Contents

Mastering JavaServer Faces 2.2
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Instant updates on new Packt books
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Dynamic Access to JSF Application Data through Expression Language (EL 3.0)
EL syntax
EL operators
EL precedence of operators
EL reserved words
EL immediate and deferred evaluation
EL value expressions
Referencing a managed bean
Referencing a managed bean's properties
Referencing a managed bean's nested properties
Referencing Java SE enumerated types
Referencing collections
EL implicit objects
EL method expressions
The conditional text in JSF
Writing a custom EL resolver
EL 3.0 overview
Working with the assignment operator
Working with the string concatenation operator
Working with the semicolon operator
Exploring lambda expressions
Working with collection objects
Summary
2. Communication in JSF
Passing and getting parameters
Using context parameters
Passing request parameters with the <f:param> tag
Working with view parameters
Calling actions on GET requests
Passing attributes with the <f:attribute> tag
Setting property values via action listeners
Passing parameters using the Flash scope
Replacing the <f:param> tag with the JSTL <c:set> tag
Sending data through cookies
Working with hidden fields
Sending passwords
Accessing UI component attributes programmatically
Passing parameters via method expressions
Communicating via the binding attribute
Managed bean communication
Injecting a managed bean into another bean
Communication between managed beans using the application/session map
Accessing other managed beans programmatically
Summary
3. JSF Scopes – Lifespan and Use in Managed Beans Communication
JSF scopes versus CDI scopes
The request scope
The session scope
The view scope
The application scope
The conversation scope
The flow scope
The simple flow
Flows with beans
Nested flows
Configuring flows programmatically
Flows and navigation cases
Inspecting flow navigation cases
Using the initializer and finalizer
Using the flow switch
Packaging flows
Programmatic flow scope
Dependent pseudo-scope
The none scope
The custom scope
Writing the custom scope class
Resolving a custom scope EL expression
Controlling the custom scope lifespan with action listeners
Controlling the custom scope lifespan with the navigation handler
Managed bean instantiation
Beans injection
Summary
4. JSF Configurations Using XML Files and Annotations – Part 1
JSF 2.2 new namespaces
JSF 2.2 programmatic configuration
Configuring managed beans in XML
Working with multiple configuration files
Configuring locales and resource bundles
Configuring validators and converters
Configuring navigation
Implicit navigation
Conditional navigation
Preemptive navigation
Programmatic Navigation
Configuring action listeners
Application action listeners
Configuring system event listeners
Using <f:event>
Implementing SystemEventListener
Configuring phase listeners
Working with @ListenerFor and @ListenersFor
Summary
5. JSF Configurations Using XML Files and Annotations – Part 2
Configuring resource handlers
Adding CSS and JS resources programmatically
Configuring the view handler
Overriding JSF renders
Working with client behavior functionality
JSF factories
Configuring the global exception handler
Configuring RenderKit factory
Configuring PartialViewContext
Configuring visitContext
Configuring ExternalContext
Configuring Flash
JSF 2.2 Window ID API
Configuring lifecycle
Configuring the application
Configuring VDL
Combined power of multiple factories
Summary
6. Working with Tabular Data
Creating a simple JSF table
The CollectionDataModel class of JSF 2.2
Sorting tables
Sorting and DataModel – CollectionDataModel
Deleting a table row
Editing/updating a table row
Adding a new row
Displaying row numbers
Selecting a single row
Selecting multiple rows
Nesting tables
Paginating tables
Generating tables with the JSF API
Filtering tables
Styling tables
Alternate row colors with the rowclasses attribute
Highlighting rows on mouse hover
Highlighting rows on mouse click
Summary
7. JSF and AJAX
A brief overview of the JSF-AJAX lifecycle
A simple JSF-AJAX example to get started
The JSF-AJAX attributes
The execute and render attributes
The listener attribute
The event attribute
The onevent attribute – monitoring AJAX state on client
The onerror attribute – monitoring AJAX errors on client
Grouping components under <f:ajax> tag
Updating input fields with AJAX after validation error
The Cancel and Clear buttons
Value submitted to a view scoped managed bean
Value submitted to a request scoped managed bean
Mixing AJAX and flow scope
Postback and AJAX
Postback request's conditional rendering/executing
Is it a non-AJAX request?
AJAX and <f:param>
Queue control for AJAX requests
Explicit loading of jsf.js
Depicting the params value
Non-UICommand components and jsf.ajax.request
Customizing jsf.js
AJAX and the progress bar/indicator
Summary
8. JSF 2.2 – HTML5 and Upload
Working with HTML5 and JSF 2.2
Pass-through attributes
Pass-through elements
JSF 2.2 – HTML5 and Bean Validation 1.1 (Java EE 7)
JSF 2.2 upload feature
A simple JSF 2.2 upload example
Using multiple <h:inputFile> elements
Extracting info about a file to be uploaded
Writing uploaded data to a disk
Upload validator
Ajaxify the upload
Uploading images with preview
Uploading multiple files
Upload and the indeterminate progress bar
Upload and the determinate progress bar
Summary
9. JSF State Management
JSF saving the view state
JSF partial saving view state
Partial state saving and tree visiting
JSF saving view state on the server or client
JSF logical and physical views
Saving the state in a database – an experimental application
Writing the custom ResponseStateManager class
Adding MongoDB in equation
Handling ViewExpiredException
Server-state serialization in a session
JSF 2.2 is stateless
The view scoped beans and the stateless feature
Detecting stateless views programmatically
JSF security notes
Cross-site request forgery (CSRF)
Cross-site scripting (XSS)
SQL injection
Summary
10. JSF Custom Components
Building noncomposite custom components
Writing a custom tag handler
Dissecting a custom component
Custom component implementation
Building composite components
Developing the Temperature composite component
Transf...

Table of contents

  1. Mastering JavaServer Faces 2.2

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access Mastering JavaServer Faces 2.2 by Anghel Leonard in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming in Java. We have over one million books available in our catalogue for you to explore.