Mastering JavaServer Faces 2.2

Book description

Master the art of implementing user interfaces with JSF 2.2

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.

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)

Publisher resources

Download Example Code

Table of contents

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

Product information

  • Title: Mastering JavaServer Faces 2.2
  • Author(s):
  • Release date: June 2014
  • Publisher(s): Packt Publishing
  • ISBN: 9781782176466