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...