JSF 2.2

Edward Burns
Edward BurnsSoftware Stylist at Oracle
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I1
JSF 2.2 New Features
in Context
Edward Burns
@edburns
Consulting Member of Staff, Oracle
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I2
My plan for your time investment
 How is JSF still relevant?
 JSF 2.2 Big Ticket Features: in Context
– 1055 Stateless Views: Context: Performance
– 1090 HTML5 Friendly Markup: Context: Markup Evolution
– 730 Flows and 1142 Resource Library Contracts:
Context: Multi-tenancy and Modularity
 Other features: Context free
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I3
The following is intended to outline our general product direction. It is intended
for information purposes only, and may not be incorporated into any contract.
It is not a commitment to deliver any material, code, or functionality, and should
not be relied upon in making purchasing decisions. The development, release,
and timing of any features or functionality described for Oracle s products
remains at the sole discretion of Oracle.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I4
 JSR 127
– JSF 1.0 11 March 2004
– JSF 1.1 27 May 2004
 JSR 252
– JSF 1.2 11 May 2006
– JSF 1.2 Maintenance Release 1
19 December 2006
– JSF 1.2 Maintenance Release 2
13 June 2008
– JSF 1.2 Maintenance Release 3
25 August 2008
Where is JSF in its Lifecycle?
JSR Timeline  JSR 314
– JSF 2.0 1 July 2009
– JSF 2.1 16 July 2010
– JSF 2.1 Maintenance Release 2
22 November 2010
 JSR 344
– Started 14 April 2011
– Early Draft Review released
8 December 2011
– Proposed Final Draft 14 Mar 2013
– Final June 2013
http://bit.ly/JavaEE7WrapsUp
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I5
WE STILL NEED WEB APPS THAT ARE
QUICK TO
BUILD,MAINTAINABLE, LOCALIZABLE, AC
CESSIBLE,
SECURE, DEVICE INDEPENDENT, GOOD
LOOKING, AND ARE FUN TO USE
How Can JSF Still Be Relevant?
Abstractions Endure
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I6
Is JSF Really That Old?
JavaOne 2001
technical keynote
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I7
Restate the Scope of JSF
 Separate Component Semantics from Rendering
 Allow components to “own” their little patch of the UI
– encode/decode
 Well defined lifecycle: Inversion of Control
UI Logic Substantially on Server
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I8
 Unofficial usage tracked at
http://bit.ly/RealWorldJsfLinks2
 or google RealWorldJsfLinks
JSF Used on Every Continent
Real World JSF Links
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I9
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I10
What’s Hot Now?
 HTML5 native applications
– JavaScript MVC frameworks
– REST
 Dan North, thought leader
– “The Browser is Dead…”
 http://bit.ly/DanNorthBrowserIsDead PDF
 http://bit.ly/DanNorthBrowserIsDeadVideo YouTube
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I11
Dan North’s Assessment of What’s Hot Now
 Technologies
– Graphics: 2D and 3D + transforms
– Client local storage
– Sever Sent Events: Web Sockets
– Ecmascript
 Techniques
– Everything is asynchronous
– Don’t page template, just use the DOM (jQuery)
– No UI state on the server
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I12
Dan North’s Assessment of What’s Hot Now
 Use standards…
– W3C standards
– JCP standards?
 JSON JSR-353
 WebSocket JSR-356
 JAX-RS JSR-339
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I13
So why are these things hot now?
 Flashy results?
 Maintainability?
 Better runtime performance  potential for better user experience?
 Wider reach?
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I14
So why are these things hot now?
 Flashy results?
– This is a component library concern. Many component libraries have very
flashy components.
– Abstractions endure
 Maintainability?
 Better runtime performance  potential for better user experience?
 Wider reach?
JSF responses
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I15
So why are these things hot now?
 Flashy results?
 Maintainability?
– JavaEE/JSF was designed for large teams of corporate developers
producing code that needs to stick around long after said developers have
moved on.
– For example, emphasis on statically typed technologies
 Better runtime performance  potential for better user experience?
 Wider reach?
JSF responses
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I16
So why are these things hot now?
 Flashy results?
 Maintainability?
 Better runtime performance  potential for better user experience?
– With any technology, including the HTML5 native approach, it is possible to
produce a poorly performing user experience. The question is how hard is
it to produce a decently performing one.
– Stateless JSF is a step in that direction.
 Wider reach?
JSF responses
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I17
So why are these things hot now?
 Flashy results?
 Maintainability?
 Better runtime performance  potential for better user experience?
 Wider reach?
– JSF was designed for client device independence
– HTML5, while growing, is still not at the least common denominator level
– Being able to support IE 6 is sometimes still important
JSF responses
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I18
So why are these things hot now?
 Flashy results?
 Maintainability?
 Better runtime performance  potential for better user experience?
 Wider reach?
JSF responses
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I19
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I20
In reality, many approaches can co-exist
 JSF for one class of developers/users
 HTML5 native for another
 Re-use in the application tier
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I21
Where is JSF in its Lifecycle?
Implementation Status
 Oracle Mojarra JSF 2.2.0 is in GlassFish 4.0, which requires JDK7
 It will also run on GlassFish 3.1+, which requires JDK6
 It will also run on Tomcat 7 (but you must bring your own CDI if you
want to use CDI dependent features such as Faces Flows)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I22
My plan for your time investment
 How is JSF still relevant?
 Big Ticket Features: in Context
– 1055 Stateless Views: Context: Performance
– 1090 HTML5 Friendly Markup: Context: Markup Evolution
– 730 Flows and 1142 Resource Library Contracts:
Context: Multi-tenancy and Modularity
 Other features: Context free
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I23
JSF 2.2 Big Ticket Features
in Context
Issue numbers relative to JSF JIRA
http://jsf-spec.java.net/issues/
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I24
New to JSF?
 JSF 2.0 was a blockbuster release
– Facelets
– Composite Components
– Ajax
– Resource Libraries
2.0 Big Ticket Feature Review
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I25
1055 Stateless JSF
 Kinds of state in a JSF app
– UIComponent state
– Model tier state
– Persistence tier state
What is state?
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I26
1055 Stateless JSF
 Kinds of state in a JSF app
– UIComponent state
– Model tier state
– Persistence tier state
What is state?
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I27
1055 Stateless JSF
 Kinds of state in a JSF app
– UIComponent state
– Model tier state
– Persistence tier state
 Context: Stateless is important mostly as performance concern
– See http://bit.ly/LeonardoJsfPerformance Leonardo Uribe’s paper
– Much can be done in the way you use JSF to reduce statefulness
What is state?
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I28
1055 Stateless JSF
 Leverage existing API
 Biggest gain for smallest change
– Expose existing UIComponent transient property on f:view
<f:view transient=“true”>
– Spec changes in Restore View Phase, ResponseStateManager
 Be advised
– Must be on outer-most <f:view> in Facelets inclusion
– View scoped managed beans will not work if the view is marked stateless
JSF 2.2 approach to stateless
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I29
1055 Stateless JSF
 Automatic state management is a key value-add of JSF
– Differentiates it from RESTful
 Pros
– Can be lazy with your UI,
Why is this important?
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I30
1090 HTML5 Friendly Markup
 This is a JSF page
The best part of Wicket comes to JSF
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I31
1090 HTML5 Friendly Markup
 JSF Views are written in a View Declaration Language (VDL).
 The standard Facelet VDL is an XML application with two kinds of
elements
– HTML Markup
– JSF Components
 HTML Markup is passed through straight to the browser
 JSF Components take some action on the server, during the lifecycle
Let’s get back to basics
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I32
1090 HTML5 Friendly Markup
 Before JSF 2.2
– JSF tags hide complexity of underlying HTML+script+css+images
– JSF “Renderer”:
 encode: markup to browser
 decode: name=value from browser
<html>…
<my:colorPicker value=“#{colorBean.color2}” />
<my:calendar value=“#{calendarBean.date1}” />
</html>
 Context: Missing feature in browser? Write a JSF component.
Let the elegance of HTML shine through
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I33
1090 HTML5 Friendly Markup
 With JSF 2.2
– Pure HTML+script+css+images in the JSF page
– JSF Renderer handles decode from browser
 Leverage the strength of the JSF lifecycle
 Leverage the expressiveness of HTML5
<html>…
<input type=“color” jsf:value=“#{colorBean.color2}”/>
<input type=“date” jsf:value=“#{calendarBean.date1}” />
</html>
 Context: New feature in browser? Use “pass through elements”
Let the elegance of HTML shine through
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I34
1090 HTML5 Friendly Markup
 DEMO
Let the elegance of HTML shine through
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I35
1142 Resource Library Contracts
730 Faces Flows
 Allow composing a JSF app as a
collection of modules
– Faces Flows modularize behavior
– Resource Library Contracts modularize
appearance
 Well defined contract for each
Modularity and Multi-tenant capability
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I36
1142 Resource Library Contracts 730 Faces Flows
 Two new concepts in JSF 2.2
– Resource Library Contract
– Faces Flows
What’s going on here?
Builds on facelets concepts
Builds on navigation concepts
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I37
Resource Library Contracts
Facelets Review
<ui:define name="headline">
Today's News
</ui:define>
<ui:define name="story">
Facelets is now a part
of JSF 2.0...
</ui:define>
T eFaceletsGazet e
Sit
Navigat on
● Events
● Docs
● Forums
About Contact Sit M ap
_template.html
template client
greeting.html
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I38
Resource Library Contracts
Facelets Review T eFaceletsGazet e
Sit
Navigat on
● Events
● Docs
● Forums
About Contact Sit M ap
Template File name
_template.html
Insertion points
Resources
css classes, scripts, images
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I39
Resource Library Contracts
A Contract is Born
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractA
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I40
Resource Library Contracts
Loading Conventions
contractA
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractB
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractC
• Declared Templates
• Declared Insertion Points
• Declared Resources
<web-app-root>/contracts
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I41
Resource Library Contracts
Loading Conventions
contractA
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractB
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractC
• Declared Templates
• Declared Insertion Points
• Declared Resources
<web-app-root>/contracts
contractD
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractE
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractF
• Declared Templates
• Declared Insertion Points
• Declared Resources
JAR files in WEB-INF/lib
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I42
Resource Library Contracts
Loading Conventions
contractA
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractB
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractC
• Declared Templates
• Declared Insertion Points
• Declared Resources
<web-app-root>/contracts
contractD
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractE
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractF
• Declared Templates
• Declared Insertion Points
• Declared Resources
JAR files in WEB-INF/lib
Set of available contracts
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I43
Resource Library Contracts
Loading Conventions
contractA
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractB
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractC
• Declared Templates
• Declared Insertion Points
• Declared Resources
<web-app-root>/contracts
contractD
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractE
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractF
• Declared Templates
• Declared Insertion Points
• Declared Resources
JAR files in WEB-INF/lib
Set of available contracts
Facelet 1 Facelet 3Facelet 2
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I44
Resource Library Contracts
Loading Configuration
contractA
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractB
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractC
• Declared Templates
• Declared Insertion Points
• Declared Resources
<web-app-root>/contracts
contractD
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractE
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractF
• Declared Templates
• Declared Insertion Points
• Declared Resources
JAR files in WEB-INF/lib
Set of available contracts
Facelet 1 Facelet 3Facelet 2
faces-config.xml
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I45
Resource Library Contracts
Loading Configuration
contractA
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractB
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractC
• Declared Templates
• Declared Insertion Points
• Declared Resources
<web-app-root>/contracts
contractD
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractE
• Declared Templates
• Declared Insertion Points
• Declared Resources
contractF
• Declared Templates
• Declared Insertion Points
• Declared Resources
JAR files in WEB-INF/lib
Set of available contracts
Facelet 1
<f:view contracts="contractA">
...
Facelet 3Facelet 2
faces-config.xml
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I46
Resource Library Contracts
 Resource Library Contract
– Convention
 Available contracts discovered at startup
 All of them are made available to the application
 Assumes there are no naming collisions
– Configuration
 faces-config.xml <resource-library-contracts> element
– Controls which parts of the app are allowed to use which contracts
 contracts attribute in <f:view>
– Declares that this view is only able to use these named contracts
Modular Appearance
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I47
Faces Flows
Standards are for Standardizing, Not Innovating
 ADF Task Flows
 Spring Web Flow
 Apache MyFaces CODI
Architectural Pedigree
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I48
Flow Concepts
 Can be “called” from any place in the application
 Single entry point
 Input parameters and return values
 Well defined interface contract
– Internal implementation details hidden
 New flowScoped for flow local storage
 New @FlowScoped CDI annotation: automatic activation/passivation
Hint: Think of a flow like a Java method
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I49
Flow Navigation
 Navigation is no longer just between pages
 Navigation is now between flow “nodes”
 Information Hiding comes to JSF. Welcome to 1972!
 Multiple node types:
– View
– Method Call
– Switch
– Flow Call
– Flow Return
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I50
Flow Navigation
 Flow represented at
runtime by instance of
javax.faces.flow.Flow
 JSF 2.2 authoring
experience
– XML
– Builder
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I51
730 Faces Flows 1142 Resource Library Contracts
 Two new concepts in JSF 2.2
– Resource Library Contract
– Faces Flows
 Each builds on the packaging scheme in JSF 2.0
– A special directory in the web app root
 /contracts
 /flows
– A special location in the Classpath
 /META-INF /contracts
 /META-INF/flows
What’s going on here?
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I52
730 Faces Flows 1142 Resource Library Contracts
 Two new concepts in JSF 2.2
– Resource Library Contract
– Faces Flows
 Each builds on the packaging scheme in JSF 2.0
– A special directory in the web app root
 /contracts
 /flows
– A special location in the Classpath
 /META-INF /contracts
 /META-INF/flows
What’s going on here?
Useful during development
Useful during deployment
}
}
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I53
1142 Resource Library Contracts
 DEMO
Explore the contracts aspect of flow_and_contract and scrumtoys demo
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I54
730 Faces Flows
Standards are for Standardizing, Not Innovating
 ADF Task Flows
 Spring Web Flow
 Apache MyFaces CODI
Architectural Pedigree
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I55
730 Faces Flows
 Can be “called” from any place in the application
 Single entry point
 Input parameters and return values
 Well defined interface contract
– Internal implementation details hidden
 New facesFlowScope for flow local storage
 New @FlowScoped CDI annotation: automatic activation/passivation
Hint: Think of a flow like a Java method
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I56
 Navigation is no longer just between pages
 Navigation is now between flow “nodes”
 Information Hiding comes to JSF. Welcome to 1972!
 Multiple node types:
– View
– Method Call
– Switch
– Flow Call
– Flow Return
730 Faces Flows
Navigation
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I57
 Flow represented at
runtime by instance of
javax.faces.flow.Flow
 JSF 2.2 authoring
experience
– XML
– Builder
730 Faces Flows
Navigation
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I58
Flow Definition
 Name of the flow
 Where does the flow start?
 Input values
 Optional initializer & finalizer
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I59
Flow Definition
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I60
730 Faces Flows
Spec challenge
 Ensuring the feature works well with the existing JSF features
– POSTback based navigation: <h:command{Button,Link}>
– GET based navigation: <h:{button,link}>
 Navigation rules
– Was one level
– Now is a stack
– “return” case was tricky
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I61
My plan for your time investment
 How is JSF still relevant?
 Big Ticket Features: in Context
– 1055 Stateless Views: Context: Performance
– 1090 HTML5 Friendly Markup: Context: Markup Evolution
– 730 Flows and 1142 Resource Library Contracts:
Context: Multi-tenancy and Modularity
 Other features: Context free
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I62
Other Features
• Medium Sized
• Small Sized
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I63
Medium Sized Features
1. 1042 ViewActions
2. 869 CSRF protection
3. 949 ClientWindow
4. 802 File Upload
5. 763 CDI injection of JSF artifacts
6. 599 Programmatic Composite Component creation
7. 594, 703 FacesComponent enhancetments
8. 479 UIData implements Collection
9. 1001 Composite and Java components in the same library
10. 533 Programmatic faces-config
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I64
1042 ViewActions
 JSF 2.0 introduced <f:metadata>
– Use with <f:viewParam>
 JSF 2.2 introduces <f:viewAction>
– Use inside of <f:metadata>
– Use along side of <f:viewParam>
 Like a button that clicks itself
– Can cause navigation
– Can choose the lifecycle phase
 UIViewAction component sits behind <f:viewAction> tag.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I65
869 Cross Site Request Forgery Protection
 What is Cross Site Request Forgery
(CSRF, pronounced SEE-surf)?
– http://en.wikipedia.org/wiki/Cross-site_request_forgery
– Trick the browser into sending requests that the user did not actually intend
to initiate
JSF Is Not Just for POSTback Anymore
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I66
869 Cross Site Request Forgery Protection
 How does JSF protect your app against this attack?
1. It already does and always has!
POSTback is a virture. JSF 2.2 just makes encryption of the view state on
by default
2. New <protected-views> section in faces-config
 View Token
– When rendering a non-POSTback link or button
 Referer [sic] and Origin headers
JSF Is Not Just for POSTback Anymore
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I67
949 ClientWindow
 JSF finally has framework level support for the many different ways a
UIComponent tree can be rooted
– Browser tab
– Browser window
– Browser pop-up
– Portlet
– …
 New class javax.faces.lifecycle.ClientWindow
– A client window is always associated with exactly one UIViewRoot instance
at a time, but may display many different UIViewRoots during its lifetime.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I68
949 ClientWindow
 FacesServlet now must call Lifecycle.attachWindow()
 Lifecycle.attachWindow()
– Takes no action unless feature is enabled
– Looks for incoming client window
– Creates one if not present
– Stores it on the ExternalContext
How does it work?
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I69
802 File Upload Component
 For the benefit of Apache Tomcat users, JSF has always chosen to lag
one Servlet version behind the Java EE umbrella spec in which it is
included
Why so long?
Included
JSF
Version
Included
Servlet
Version
Minimum Servlet
Version for
Included JSF
J2EE 1.4 1.1 2.4 2.3
Java EE 5 1.2 2.5 2.4
Java EE 6 2.0 3.0 2.5
Java EE 7 2.2 3.1 3.0
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I70
 Final spec has “Ajax” and non-Ajax support
 “Ajax” can be XHR level 2 or hidden IFRAME
<h:inputFile id="file"
value="#{fileUploadBean.uploadedFile}">
<f:validator validatorId="FileValidator" />
</h:inputFile>
802 File Upload Component
Usage
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I71
@ManagedBean
@RequestScoped
public class FileUploadBean {
private Part uploadedFile; // getter/setter
public String getFileText() {
String text = "";
if (null != uploadedFile) { try {
InputStream is = uploadedFile.getInputStream();
text = new Scanner( is ).useDelimiter("A").next();
} catch (IOException ex) {}
}
return text;
}
}
802 File Upload Component
Usage
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I72
@FacesValidator(value="FileValidator")
public class FileValidator implements Validator {
@Override public void validate(FacesContext context,
UIComponent component, Object value) throws ValidatorException {
Part file = (Part) value;
try {
InputStream is = file.getInputStream();
text = new Scanner( is ).useDelimiter("A").next();
} catch (Exception ex) { throw new ValidatorException(“”, ex); }
if (!text.contains("JSR-344")) {
throw new ValidatorException(new FacesMessage("Invalid file”);
}
}
802 File Upload Component
Usage
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I73
763 CDI Injection of JSF Artifacts
 All Common Annotation and CDI Annotations must work in
– ELResolvers
– Factories
– JSF singletons (ResourceHandler, StateManager, etc)
– ActionListeners
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I74
599 Programmatic Component Creation
 Application.createComponent()
– Used to create UIComponent instances given component-family, etc
 ViewDeclarationLanguage.createComponent()
– Used to create UIComponent instances given tag library URI, tag name,
and optional attributes
– Equivalent to using the tag in a page
– Designed for use with composite components
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I75
594, 703 FacesComponent enhancements
 @FacesComponent added in JSF 2.0
– Allows declaring a UIComponent to the runtime
 JSF 2.2 adds new attributes (with sensible defaults)
– createTag causes a facelet tag handler to automatically be created
– namespace declares the tag library namespace in which the tag handler
will reside
– tagName declares the tag name
– value now has a default behavior
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I76
479 UIData supports Collection
 Prior to JSF 2.2, UIData only supported
– Arrays
– java.util.List
– java.sql.ResultSet
– javax.servlet.jsp.jstl.sql.Result
 JSF 2.2 adds
– java.util.Collection
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I77
1001 Composite and Regular Components
 Prior to JSF 2.2, was not possible to have both kinds of components in
the same tag library
 Now it is.
Both in the same tag library
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I78
533 Programmatic faces-config
 New class
javax.faces.application.ApplicationConfigurationPopulator
 Is a java.util.ServiceLoader service
 Has a populateApplicationConfiguration() method
– Gets passed an “empty” DOM Document
– You can populate it as if it were a regular faces-config.xml file.
– It gets put in with the rest of the discovered faces-config files.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I79
Other Features
• Medium Sized
• Small Sized
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I80
Small Sized Features
 1142 “reset button” API
 766 Events from the Flash
 1134 “role” passthrough attribute
 1050 Ajax delay
 1085 httpOnly cookie support
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I81
Q&A
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I82
The preceding was intended to outline our general product direction. It was
intended for information purposes only, and may not be incorporated into any
contract. It is not a commitment to deliver any material, code, or functionality, and
should not be relied upon in making purchasing decisions. The development,
release, and timing of any features or functionality described for Oracle s
products remains at the sole discretion of Oracle.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I83
1 of 83

Recommended

Express JS Rest API Tutorial by
Express JS Rest API TutorialExpress JS Rest API Tutorial
Express JS Rest API TutorialSimplilearn
215 views7 slides
Jdbc complete by
Jdbc completeJdbc complete
Jdbc completeSandeep Rawat
1.7K views72 slides
Spring boot by
Spring bootSpring boot
Spring bootPradeep Shanmugam
649 views12 slides
Diziler C# by
Diziler C#Diziler C#
Diziler C#Batu54
1.3K views35 slides
Spring - Part 1 - IoC, Di and Beans by
Spring - Part 1 - IoC, Di and Beans Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans Hitesh-Java
1.3K views36 slides
Server side programming by
Server side programming Server side programming
Server side programming javed ahmed
387 views29 slides

More Related Content

What's hot

Java Spring Framework by
Java Spring FrameworkJava Spring Framework
Java Spring FrameworkMehul Jariwala
2.9K views29 slides
Spring MVC to iOS and the REST by
Spring MVC to iOS and the RESTSpring MVC to iOS and the REST
Spring MVC to iOS and the RESTRoy Clarkson
26.4K views49 slides
Learn Dashing Widget in 90 minutes by
Learn Dashing Widget in 90 minutesLearn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutesLarry Cai
33.3K views17 slides
JPA and Hibernate by
JPA and HibernateJPA and Hibernate
JPA and Hibernateelliando dias
5.8K views49 slides
Designing APIs with OpenAPI Spec by
Designing APIs with OpenAPI SpecDesigning APIs with OpenAPI Spec
Designing APIs with OpenAPI SpecAdam Paxton
6K views19 slides
Swagger UI by
Swagger UISwagger UI
Swagger UIWalaa Hamdy Assy
959 views11 slides

What's hot(20)

Spring MVC to iOS and the REST by Roy Clarkson
Spring MVC to iOS and the RESTSpring MVC to iOS and the REST
Spring MVC to iOS and the REST
Roy Clarkson26.4K views
Learn Dashing Widget in 90 minutes by Larry Cai
Learn Dashing Widget in 90 minutesLearn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutes
Larry Cai33.3K views
Designing APIs with OpenAPI Spec by Adam Paxton
Designing APIs with OpenAPI SpecDesigning APIs with OpenAPI Spec
Designing APIs with OpenAPI Spec
Adam Paxton6K views
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T... by Edureka!
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
Edureka!1.7K views
REST: From GET to HATEOAS by Jos Dirksen
REST: From GET to HATEOASREST: From GET to HATEOAS
REST: From GET to HATEOAS
Jos Dirksen48.3K views
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20 by Phil Wilkins
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
Phil Wilkins1.1K views
Rest & RESTful WebServices by Prateek Tandon
Rest & RESTful WebServicesRest & RESTful WebServices
Rest & RESTful WebServices
Prateek Tandon5.8K views
Microservices Design Patterns by Haim Michael
Microservices Design PatternsMicroservices Design Patterns
Microservices Design Patterns
Haim Michael203 views
SPRING - MAVEN - REST API (ITA - Luglio 2017) by Valerio Radice
SPRING - MAVEN - REST API (ITA - Luglio 2017)SPRING - MAVEN - REST API (ITA - Luglio 2017)
SPRING - MAVEN - REST API (ITA - Luglio 2017)
Valerio Radice3.8K views
REST API and CRUD by Prem Sanil
REST API and CRUDREST API and CRUD
REST API and CRUD
Prem Sanil155.9K views
Introduction to REST - API by Chetan Gadodia
Introduction to REST - APIIntroduction to REST - API
Introduction to REST - API
Chetan Gadodia1.1K views
The Beginner’s Guide To Spring Cloud by VMware Tanzu
The Beginner’s Guide To Spring CloudThe Beginner’s Guide To Spring Cloud
The Beginner’s Guide To Spring Cloud
VMware Tanzu2K views
[112]rest에서 graph ql과 relay로 갈아타기 이정우 by NAVER D2
[112]rest에서 graph ql과 relay로 갈아타기 이정우[112]rest에서 graph ql과 relay로 갈아타기 이정우
[112]rest에서 graph ql과 relay로 갈아타기 이정우
NAVER D225.3K views

Viewers also liked

Java Server Faces 2 by
Java Server Faces 2Java Server Faces 2
Java Server Faces 2'Farouk' 'BEN GHARSSALLAH'
6.4K views76 slides
Presentation JEE et son écossystéme by
Presentation JEE et son écossystémePresentation JEE et son écossystéme
Presentation JEE et son écossystémeAlgeria JUG
2.2K views49 slides
Développement d'applications pour la plateforme Java EE by
Développement d'applications pour la plateforme Java EEDéveloppement d'applications pour la plateforme Java EE
Développement d'applications pour la plateforme Java EESabri Bouchlema
2K views65 slides
Jsf by
JsfJsf
JsfNguyen Tran
2.9K views44 slides
Jsf presentation by
Jsf presentationJsf presentation
Jsf presentationAshish Gupta
6.3K views20 slides
Lecture 10 - Java Server Faces (JSF) by
Lecture 10 - Java Server Faces (JSF)Lecture 10 - Java Server Faces (JSF)
Lecture 10 - Java Server Faces (JSF)Fahad Golra
2.9K views31 slides

Viewers also liked(6)

Presentation JEE et son écossystéme by Algeria JUG
Presentation JEE et son écossystémePresentation JEE et son écossystéme
Presentation JEE et son écossystéme
Algeria JUG2.2K views
Développement d'applications pour la plateforme Java EE by Sabri Bouchlema
Développement d'applications pour la plateforme Java EEDéveloppement d'applications pour la plateforme Java EE
Développement d'applications pour la plateforme Java EE
Sabri Bouchlema2K views
Lecture 10 - Java Server Faces (JSF) by Fahad Golra
Lecture 10 - Java Server Faces (JSF)Lecture 10 - Java Server Faces (JSF)
Lecture 10 - Java Server Faces (JSF)
Fahad Golra2.9K views

Similar to JSF 2.2

JSF 2.2 Input Output JavaLand 2015 by
JSF 2.2 Input Output JavaLand 2015JSF 2.2 Input Output JavaLand 2015
JSF 2.2 Input Output JavaLand 2015Edward Burns
1.9K views64 slides
JDK versions and OpenJDK by
JDK versions and OpenJDKJDK versions and OpenJDK
JDK versions and OpenJDKWolfgang Weigend
1.8K views48 slides
Burns jsf-confess-2015 by
Burns jsf-confess-2015Burns jsf-confess-2015
Burns jsf-confess-2015Edward Burns
2.3K views37 slides
JSF 2.2 Status at DOAG 2011 by
JSF 2.2 Status at DOAG 2011JSF 2.2 Status at DOAG 2011
JSF 2.2 Status at DOAG 2011Edward Burns
1.5K views18 slides
Ed presents JSF 2.2 at a 2013 Gameduell Tech talk by
Ed presents JSF 2.2 at a 2013 Gameduell Tech talkEd presents JSF 2.2 at a 2013 Gameduell Tech talk
Ed presents JSF 2.2 at a 2013 Gameduell Tech talkEdward Burns
907 views58 slides
It's a jdk jungle out there - JDK 11 and OpenJDK 11 by
It's a jdk jungle out there - JDK 11 and OpenJDK 11It's a jdk jungle out there - JDK 11 and OpenJDK 11
It's a jdk jungle out there - JDK 11 and OpenJDK 11Wolfgang Weigend
1.2K views92 slides

Similar to JSF 2.2(20)

JSF 2.2 Input Output JavaLand 2015 by Edward Burns
JSF 2.2 Input Output JavaLand 2015JSF 2.2 Input Output JavaLand 2015
JSF 2.2 Input Output JavaLand 2015
Edward Burns1.9K views
Burns jsf-confess-2015 by Edward Burns
Burns jsf-confess-2015Burns jsf-confess-2015
Burns jsf-confess-2015
Edward Burns2.3K views
JSF 2.2 Status at DOAG 2011 by Edward Burns
JSF 2.2 Status at DOAG 2011JSF 2.2 Status at DOAG 2011
JSF 2.2 Status at DOAG 2011
Edward Burns1.5K views
Ed presents JSF 2.2 at a 2013 Gameduell Tech talk by Edward Burns
Ed presents JSF 2.2 at a 2013 Gameduell Tech talkEd presents JSF 2.2 at a 2013 Gameduell Tech talk
Ed presents JSF 2.2 at a 2013 Gameduell Tech talk
Edward Burns907 views
It's a jdk jungle out there - JDK 11 and OpenJDK 11 by Wolfgang Weigend
It's a jdk jungle out there - JDK 11 and OpenJDK 11It's a jdk jungle out there - JDK 11 and OpenJDK 11
It's a jdk jungle out there - JDK 11 and OpenJDK 11
Wolfgang Weigend1.2K views
Java: how to thrive in the changing world by Alexey Fyodorov
Java: how to thrive in the changing worldJava: how to thrive in the changing world
Java: how to thrive in the changing world
Alexey Fyodorov598 views
Serverless Java - Challenges and Triumphs by David Delabassee
Serverless Java - Challenges and TriumphsServerless Java - Challenges and Triumphs
Serverless Java - Challenges and Triumphs
David Delabassee282 views
GlassFish in Production Environments by Bruno Borges
GlassFish in Production EnvironmentsGlassFish in Production Environments
GlassFish in Production Environments
Bruno Borges9.7K views
2015 JavaOne LAD JSF 2.3 & MVC 1.0 by mnriem
2015 JavaOne LAD JSF 2.3 & MVC 1.02015 JavaOne LAD JSF 2.3 & MVC 1.0
2015 JavaOne LAD JSF 2.3 & MVC 1.0
mnriem624 views
Coding for desktop and mobile with HTML5 and Java EE 7 - Geertjan Wielenga by JAXLondon_Conference
Coding for desktop and mobile with HTML5 and Java EE 7 - Geertjan WielengaCoding for desktop and mobile with HTML5 and Java EE 7 - Geertjan Wielenga
Coding for desktop and mobile with HTML5 and Java EE 7 - Geertjan Wielenga
JavaOne 2014 BOF4241 What's Next for JSF? by Edward Burns
JavaOne 2014 BOF4241 What's Next for JSF?JavaOne 2014 BOF4241 What's Next for JSF?
JavaOne 2014 BOF4241 What's Next for JSF?
Edward Burns29.8K views
20160123 java one2015_feedback @ Osaka by Takashi Ito
20160123 java one2015_feedback @ Osaka20160123 java one2015_feedback @ Osaka
20160123 java one2015_feedback @ Osaka
Takashi Ito467 views
Increased Developer Productivity for IoT with Java and Reactive Blocks (Oracl... by Bart Jonkers
Increased Developer Productivity for IoT with Java and Reactive Blocks (Oracl...Increased Developer Productivity for IoT with Java and Reactive Blocks (Oracl...
Increased Developer Productivity for IoT with Java and Reactive Blocks (Oracl...
Bart Jonkers554 views
Владимир Иванов (Oracle): Java: прошлое и будущее by Olga Lavrentieva
Владимир Иванов (Oracle): Java: прошлое и будущееВладимир Иванов (Oracle): Java: прошлое и будущее
Владимир Иванов (Oracle): Java: прошлое и будущее
Olga Lavrentieva5.2K views
Seven Points for Applying Java EE 7 by Hirofumi Iwasaki
Seven Points for Applying Java EE 7Seven Points for Applying Java EE 7
Seven Points for Applying Java EE 7
Hirofumi Iwasaki24.2K views

More from Edward Burns

Jakarta EE 11 Status Update​ by
Jakarta EE 11 Status Update​Jakarta EE 11 Status Update​
Jakarta EE 11 Status Update​Edward Burns
61 views43 slides
Sponsored Session: Please touch that dial! by
Sponsored Session: Please touch that dial!Sponsored Session: Please touch that dial!
Sponsored Session: Please touch that dial!Edward Burns
9 views25 slides
How modernizing enterprise applications gives you a competitive advantage by
How modernizing enterprise applications gives you a competitive advantageHow modernizing enterprise applications gives you a competitive advantage
How modernizing enterprise applications gives you a competitive advantageEdward Burns
9 views35 slides
Wie Azure Jakarta EE Nutzt by
Wie Azure Jakarta EE NutztWie Azure Jakarta EE Nutzt
Wie Azure Jakarta EE NutztEdward Burns
19 views34 slides
Practical lessons from customers performing digital transformation with Azure by
Practical lessons from customers performing digital transformation with AzurePractical lessons from customers performing digital transformation with Azure
Practical lessons from customers performing digital transformation with AzureEdward Burns
32 views46 slides
wls-azure-devnexus-2022.pdf by
wls-azure-devnexus-2022.pdfwls-azure-devnexus-2022.pdf
wls-azure-devnexus-2022.pdfEdward Burns
122 views34 slides

More from Edward Burns(20)

Jakarta EE 11 Status Update​ by Edward Burns
Jakarta EE 11 Status Update​Jakarta EE 11 Status Update​
Jakarta EE 11 Status Update​
Edward Burns61 views
Sponsored Session: Please touch that dial! by Edward Burns
Sponsored Session: Please touch that dial!Sponsored Session: Please touch that dial!
Sponsored Session: Please touch that dial!
Edward Burns9 views
How modernizing enterprise applications gives you a competitive advantage by Edward Burns
How modernizing enterprise applications gives you a competitive advantageHow modernizing enterprise applications gives you a competitive advantage
How modernizing enterprise applications gives you a competitive advantage
Edward Burns9 views
Wie Azure Jakarta EE Nutzt by Edward Burns
Wie Azure Jakarta EE NutztWie Azure Jakarta EE Nutzt
Wie Azure Jakarta EE Nutzt
Edward Burns19 views
Practical lessons from customers performing digital transformation with Azure by Edward Burns
Practical lessons from customers performing digital transformation with AzurePractical lessons from customers performing digital transformation with Azure
Practical lessons from customers performing digital transformation with Azure
Edward Burns32 views
wls-azure-devnexus-2022.pdf by Edward Burns
wls-azure-devnexus-2022.pdfwls-azure-devnexus-2022.pdf
wls-azure-devnexus-2022.pdf
Edward Burns122 views
Jakarta EE und Microprofile sind bei Azure zu Hause by Edward Burns
Jakarta EE und Microprofile sind bei Azure zu HauseJakarta EE und Microprofile sind bei Azure zu Hause
Jakarta EE und Microprofile sind bei Azure zu Hause
Edward Burns169 views
Java on Your Terms with Azure by Edward Burns
Java on Your Terms with AzureJava on Your Terms with Azure
Java on Your Terms with Azure
Edward Burns139 views
Wars I’ve Seen From Java EE to Spring and more, Azure has you covered by Edward Burns
Wars I’ve SeenFrom Java EE to Spring and more, Azure has you coveredWars I’ve SeenFrom Java EE to Spring and more, Azure has you covered
Wars I’ve Seen From Java EE to Spring and more, Azure has you covered
Edward Burns122 views
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e... by Edward Burns
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
Edward Burns203 views
Programming Language Platform Growth: Table Stakes or Deal Makes? by Edward Burns
Programming Language Platform Growth: Table Stakes or Deal Makes?Programming Language Platform Growth: Table Stakes or Deal Makes?
Programming Language Platform Growth: Table Stakes or Deal Makes?
Edward Burns280 views
Programming Language Platform Growth: Table Stakes or Deal Makes? by Edward Burns
Programming Language Platform Growth: Table Stakes or Deal Makes?Programming Language Platform Growth: Table Stakes or Deal Makes?
Programming Language Platform Growth: Table Stakes or Deal Makes?
Edward Burns238 views
Building a Serverless State Service for the Cloud by Edward Burns
Building a Serverless State Service for the CloudBuilding a Serverless State Service for the Cloud
Building a Serverless State Service for the Cloud
Edward Burns472 views
Servlet 4.0 at GeekOut 2015 by Edward Burns
Servlet 4.0 at GeekOut 2015Servlet 4.0 at GeekOut 2015
Servlet 4.0 at GeekOut 2015
Edward Burns19.3K views
Java EE 7 from an HTML5 Perspective, JavaLand 2015 by Edward Burns
Java EE 7 from an HTML5 Perspective, JavaLand 2015Java EE 7 from an HTML5 Perspective, JavaLand 2015
Java EE 7 from an HTML5 Perspective, JavaLand 2015
Edward Burns3.4K views
HTTP/2 comes to Java. What Servlet 4.0 means to you. DevNexus 2015 by Edward Burns
HTTP/2 comes to Java.  What Servlet 4.0 means to you. DevNexus 2015HTTP/2 comes to Java.  What Servlet 4.0 means to you. DevNexus 2015
HTTP/2 comes to Java. What Servlet 4.0 means to you. DevNexus 2015
Edward Burns19.2K views
JSF 2.3 Adopt-a-JSR 10 Minute Infodeck by Edward Burns
JSF 2.3 Adopt-a-JSR 10 Minute InfodeckJSF 2.3 Adopt-a-JSR 10 Minute Infodeck
JSF 2.3 Adopt-a-JSR 10 Minute Infodeck
Edward Burns3.6K views
Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck by Edward Burns
Servlet 4.0 Adopt-a-JSR 10 Minute InfodeckServlet 4.0 Adopt-a-JSR 10 Minute Infodeck
Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck
Edward Burns3.1K views
CON5898 What Servlet 4.0 Means To You by Edward Burns
CON5898 What Servlet 4.0 Means To YouCON5898 What Servlet 4.0 Means To You
CON5898 What Servlet 4.0 Means To You
Edward Burns31.5K views
JavaOne 2014 Java EE 8 Booth Slides by Edward Burns
JavaOne 2014 Java EE 8 Booth SlidesJavaOne 2014 Java EE 8 Booth Slides
JavaOne 2014 Java EE 8 Booth Slides
Edward Burns1.1K views

Recently uploaded

The Power of Generative AI in Accelerating No Code Adoption.pdf by
The Power of Generative AI in Accelerating No Code Adoption.pdfThe Power of Generative AI in Accelerating No Code Adoption.pdf
The Power of Generative AI in Accelerating No Code Adoption.pdfSaeed Al Dhaheri
44 views18 slides
Qualifying SaaS, IaaS.pptx by
Qualifying SaaS, IaaS.pptxQualifying SaaS, IaaS.pptx
Qualifying SaaS, IaaS.pptxSachin Bhandari
1.1K views8 slides
Business Analyst Series 2023 - Week 4 Session 7 by
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7DianaGray10
152 views31 slides
The Role of Patterns in the Era of Large Language Models by
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language ModelsYunyao Li
104 views65 slides
MVP and prioritization.pdf by
MVP and prioritization.pdfMVP and prioritization.pdf
MVP and prioritization.pdfrahuldharwal141
40 views8 slides
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023 by
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023Redefining the book supply chain: A glimpse into the future - Tech Forum 2023
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023BookNet Canada
46 views19 slides

Recently uploaded(20)

The Power of Generative AI in Accelerating No Code Adoption.pdf by Saeed Al Dhaheri
The Power of Generative AI in Accelerating No Code Adoption.pdfThe Power of Generative AI in Accelerating No Code Adoption.pdf
The Power of Generative AI in Accelerating No Code Adoption.pdf
Saeed Al Dhaheri44 views
Business Analyst Series 2023 - Week 4 Session 7 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7
DianaGray10152 views
The Role of Patterns in the Era of Large Language Models by Yunyao Li
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language Models
Yunyao Li104 views
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023 by BookNet Canada
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023Redefining the book supply chain: A glimpse into the future - Tech Forum 2023
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023
BookNet Canada46 views
AIM102-S_Cognizant_CognizantCognitive by PhilipBasford
AIM102-S_Cognizant_CognizantCognitiveAIM102-S_Cognizant_CognizantCognitive
AIM102-S_Cognizant_CognizantCognitive
PhilipBasford23 views
NTGapps NTG LowCode Platform by Mustafa Kuğu
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform
Mustafa Kuğu474 views
Optimizing Communication to Optimize Human Behavior - LCBM by Yaman Kumar
Optimizing Communication to Optimize Human Behavior - LCBMOptimizing Communication to Optimize Human Behavior - LCBM
Optimizing Communication to Optimize Human Behavior - LCBM
Yaman Kumar39 views
"Node.js Development in 2024: trends and tools", Nikita Galkin by Fwdays
"Node.js Development in 2024: trends and tools", Nikita Galkin "Node.js Development in 2024: trends and tools", Nikita Galkin
"Node.js Development in 2024: trends and tools", Nikita Galkin
Fwdays37 views
Adopting Karpenter for Cost and Simplicity at Grafana Labs.pdf by MichaelOLeary82
Adopting Karpenter for Cost and Simplicity at Grafana Labs.pdfAdopting Karpenter for Cost and Simplicity at Grafana Labs.pdf
Adopting Karpenter for Cost and Simplicity at Grafana Labs.pdf
MichaelOLeary8213 views
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or... by ShapeBlue
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
ShapeBlue209 views
Cocktail of Environments. How to Mix Test and Development Environments and St... by Aleksandr Tarasov
Cocktail of Environments. How to Mix Test and Development Environments and St...Cocktail of Environments. How to Mix Test and Development Environments and St...
Cocktail of Environments. How to Mix Test and Development Environments and St...
GDSC GLAU Info Session.pptx by gauriverrma4
GDSC GLAU Info Session.pptxGDSC GLAU Info Session.pptx
GDSC GLAU Info Session.pptx
gauriverrma415 views
Initiating and Advancing Your Strategic GIS Governance Strategy by Safe Software
Initiating and Advancing Your Strategic GIS Governance StrategyInitiating and Advancing Your Strategic GIS Governance Strategy
Initiating and Advancing Your Strategic GIS Governance Strategy
Safe Software198 views

JSF 2.2

  • 1. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I1 JSF 2.2 New Features in Context Edward Burns @edburns Consulting Member of Staff, Oracle
  • 2. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I2 My plan for your time investment  How is JSF still relevant?  JSF 2.2 Big Ticket Features: in Context – 1055 Stateless Views: Context: Performance – 1090 HTML5 Friendly Markup: Context: Markup Evolution – 730 Flows and 1142 Resource Library Contracts: Context: Multi-tenancy and Modularity  Other features: Context free
  • 3. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I3 The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle s products remains at the sole discretion of Oracle.
  • 4. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I4  JSR 127 – JSF 1.0 11 March 2004 – JSF 1.1 27 May 2004  JSR 252 – JSF 1.2 11 May 2006 – JSF 1.2 Maintenance Release 1 19 December 2006 – JSF 1.2 Maintenance Release 2 13 June 2008 – JSF 1.2 Maintenance Release 3 25 August 2008 Where is JSF in its Lifecycle? JSR Timeline  JSR 314 – JSF 2.0 1 July 2009 – JSF 2.1 16 July 2010 – JSF 2.1 Maintenance Release 2 22 November 2010  JSR 344 – Started 14 April 2011 – Early Draft Review released 8 December 2011 – Proposed Final Draft 14 Mar 2013 – Final June 2013 http://bit.ly/JavaEE7WrapsUp
  • 5. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I5 WE STILL NEED WEB APPS THAT ARE QUICK TO BUILD,MAINTAINABLE, LOCALIZABLE, AC CESSIBLE, SECURE, DEVICE INDEPENDENT, GOOD LOOKING, AND ARE FUN TO USE How Can JSF Still Be Relevant? Abstractions Endure
  • 6. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I6 Is JSF Really That Old? JavaOne 2001 technical keynote
  • 7. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I7 Restate the Scope of JSF  Separate Component Semantics from Rendering  Allow components to “own” their little patch of the UI – encode/decode  Well defined lifecycle: Inversion of Control UI Logic Substantially on Server
  • 8. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I8  Unofficial usage tracked at http://bit.ly/RealWorldJsfLinks2  or google RealWorldJsfLinks JSF Used on Every Continent Real World JSF Links
  • 9. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I9
  • 10. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I10 What’s Hot Now?  HTML5 native applications – JavaScript MVC frameworks – REST  Dan North, thought leader – “The Browser is Dead…”  http://bit.ly/DanNorthBrowserIsDead PDF  http://bit.ly/DanNorthBrowserIsDeadVideo YouTube
  • 11. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I11 Dan North’s Assessment of What’s Hot Now  Technologies – Graphics: 2D and 3D + transforms – Client local storage – Sever Sent Events: Web Sockets – Ecmascript  Techniques – Everything is asynchronous – Don’t page template, just use the DOM (jQuery) – No UI state on the server
  • 12. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I12 Dan North’s Assessment of What’s Hot Now  Use standards… – W3C standards – JCP standards?  JSON JSR-353  WebSocket JSR-356  JAX-RS JSR-339
  • 13. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I13 So why are these things hot now?  Flashy results?  Maintainability?  Better runtime performance  potential for better user experience?  Wider reach?
  • 14. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I14 So why are these things hot now?  Flashy results? – This is a component library concern. Many component libraries have very flashy components. – Abstractions endure  Maintainability?  Better runtime performance  potential for better user experience?  Wider reach? JSF responses
  • 15. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I15 So why are these things hot now?  Flashy results?  Maintainability? – JavaEE/JSF was designed for large teams of corporate developers producing code that needs to stick around long after said developers have moved on. – For example, emphasis on statically typed technologies  Better runtime performance  potential for better user experience?  Wider reach? JSF responses
  • 16. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I16 So why are these things hot now?  Flashy results?  Maintainability?  Better runtime performance  potential for better user experience? – With any technology, including the HTML5 native approach, it is possible to produce a poorly performing user experience. The question is how hard is it to produce a decently performing one. – Stateless JSF is a step in that direction.  Wider reach? JSF responses
  • 17. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I17 So why are these things hot now?  Flashy results?  Maintainability?  Better runtime performance  potential for better user experience?  Wider reach? – JSF was designed for client device independence – HTML5, while growing, is still not at the least common denominator level – Being able to support IE 6 is sometimes still important JSF responses
  • 18. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I18 So why are these things hot now?  Flashy results?  Maintainability?  Better runtime performance  potential for better user experience?  Wider reach? JSF responses
  • 19. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I19
  • 20. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I20 In reality, many approaches can co-exist  JSF for one class of developers/users  HTML5 native for another  Re-use in the application tier
  • 21. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I21 Where is JSF in its Lifecycle? Implementation Status  Oracle Mojarra JSF 2.2.0 is in GlassFish 4.0, which requires JDK7  It will also run on GlassFish 3.1+, which requires JDK6  It will also run on Tomcat 7 (but you must bring your own CDI if you want to use CDI dependent features such as Faces Flows)
  • 22. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I22 My plan for your time investment  How is JSF still relevant?  Big Ticket Features: in Context – 1055 Stateless Views: Context: Performance – 1090 HTML5 Friendly Markup: Context: Markup Evolution – 730 Flows and 1142 Resource Library Contracts: Context: Multi-tenancy and Modularity  Other features: Context free
  • 23. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I23 JSF 2.2 Big Ticket Features in Context Issue numbers relative to JSF JIRA http://jsf-spec.java.net/issues/
  • 24. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I24 New to JSF?  JSF 2.0 was a blockbuster release – Facelets – Composite Components – Ajax – Resource Libraries 2.0 Big Ticket Feature Review
  • 25. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I25 1055 Stateless JSF  Kinds of state in a JSF app – UIComponent state – Model tier state – Persistence tier state What is state?
  • 26. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I26 1055 Stateless JSF  Kinds of state in a JSF app – UIComponent state – Model tier state – Persistence tier state What is state?
  • 27. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I27 1055 Stateless JSF  Kinds of state in a JSF app – UIComponent state – Model tier state – Persistence tier state  Context: Stateless is important mostly as performance concern – See http://bit.ly/LeonardoJsfPerformance Leonardo Uribe’s paper – Much can be done in the way you use JSF to reduce statefulness What is state?
  • 28. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I28 1055 Stateless JSF  Leverage existing API  Biggest gain for smallest change – Expose existing UIComponent transient property on f:view <f:view transient=“true”> – Spec changes in Restore View Phase, ResponseStateManager  Be advised – Must be on outer-most <f:view> in Facelets inclusion – View scoped managed beans will not work if the view is marked stateless JSF 2.2 approach to stateless
  • 29. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I29 1055 Stateless JSF  Automatic state management is a key value-add of JSF – Differentiates it from RESTful  Pros – Can be lazy with your UI, Why is this important?
  • 30. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I30 1090 HTML5 Friendly Markup  This is a JSF page The best part of Wicket comes to JSF
  • 31. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I31 1090 HTML5 Friendly Markup  JSF Views are written in a View Declaration Language (VDL).  The standard Facelet VDL is an XML application with two kinds of elements – HTML Markup – JSF Components  HTML Markup is passed through straight to the browser  JSF Components take some action on the server, during the lifecycle Let’s get back to basics
  • 32. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I32 1090 HTML5 Friendly Markup  Before JSF 2.2 – JSF tags hide complexity of underlying HTML+script+css+images – JSF “Renderer”:  encode: markup to browser  decode: name=value from browser <html>… <my:colorPicker value=“#{colorBean.color2}” /> <my:calendar value=“#{calendarBean.date1}” /> </html>  Context: Missing feature in browser? Write a JSF component. Let the elegance of HTML shine through
  • 33. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I33 1090 HTML5 Friendly Markup  With JSF 2.2 – Pure HTML+script+css+images in the JSF page – JSF Renderer handles decode from browser  Leverage the strength of the JSF lifecycle  Leverage the expressiveness of HTML5 <html>… <input type=“color” jsf:value=“#{colorBean.color2}”/> <input type=“date” jsf:value=“#{calendarBean.date1}” /> </html>  Context: New feature in browser? Use “pass through elements” Let the elegance of HTML shine through
  • 34. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I34 1090 HTML5 Friendly Markup  DEMO Let the elegance of HTML shine through
  • 35. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I35 1142 Resource Library Contracts 730 Faces Flows  Allow composing a JSF app as a collection of modules – Faces Flows modularize behavior – Resource Library Contracts modularize appearance  Well defined contract for each Modularity and Multi-tenant capability
  • 36. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I36 1142 Resource Library Contracts 730 Faces Flows  Two new concepts in JSF 2.2 – Resource Library Contract – Faces Flows What’s going on here? Builds on facelets concepts Builds on navigation concepts
  • 37. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I37 Resource Library Contracts Facelets Review <ui:define name="headline"> Today's News </ui:define> <ui:define name="story"> Facelets is now a part of JSF 2.0... </ui:define> T eFaceletsGazet e Sit Navigat on ● Events ● Docs ● Forums About Contact Sit M ap _template.html template client greeting.html
  • 38. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I38 Resource Library Contracts Facelets Review T eFaceletsGazet e Sit Navigat on ● Events ● Docs ● Forums About Contact Sit M ap Template File name _template.html Insertion points Resources css classes, scripts, images
  • 39. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I39 Resource Library Contracts A Contract is Born • Declared Templates • Declared Insertion Points • Declared Resources contractA
  • 40. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I40 Resource Library Contracts Loading Conventions contractA • Declared Templates • Declared Insertion Points • Declared Resources contractB • Declared Templates • Declared Insertion Points • Declared Resources contractC • Declared Templates • Declared Insertion Points • Declared Resources <web-app-root>/contracts
  • 41. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I41 Resource Library Contracts Loading Conventions contractA • Declared Templates • Declared Insertion Points • Declared Resources contractB • Declared Templates • Declared Insertion Points • Declared Resources contractC • Declared Templates • Declared Insertion Points • Declared Resources <web-app-root>/contracts contractD • Declared Templates • Declared Insertion Points • Declared Resources contractE • Declared Templates • Declared Insertion Points • Declared Resources contractF • Declared Templates • Declared Insertion Points • Declared Resources JAR files in WEB-INF/lib
  • 42. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I42 Resource Library Contracts Loading Conventions contractA • Declared Templates • Declared Insertion Points • Declared Resources contractB • Declared Templates • Declared Insertion Points • Declared Resources contractC • Declared Templates • Declared Insertion Points • Declared Resources <web-app-root>/contracts contractD • Declared Templates • Declared Insertion Points • Declared Resources contractE • Declared Templates • Declared Insertion Points • Declared Resources contractF • Declared Templates • Declared Insertion Points • Declared Resources JAR files in WEB-INF/lib Set of available contracts
  • 43. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I43 Resource Library Contracts Loading Conventions contractA • Declared Templates • Declared Insertion Points • Declared Resources contractB • Declared Templates • Declared Insertion Points • Declared Resources contractC • Declared Templates • Declared Insertion Points • Declared Resources <web-app-root>/contracts contractD • Declared Templates • Declared Insertion Points • Declared Resources contractE • Declared Templates • Declared Insertion Points • Declared Resources contractF • Declared Templates • Declared Insertion Points • Declared Resources JAR files in WEB-INF/lib Set of available contracts Facelet 1 Facelet 3Facelet 2
  • 44. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I44 Resource Library Contracts Loading Configuration contractA • Declared Templates • Declared Insertion Points • Declared Resources contractB • Declared Templates • Declared Insertion Points • Declared Resources contractC • Declared Templates • Declared Insertion Points • Declared Resources <web-app-root>/contracts contractD • Declared Templates • Declared Insertion Points • Declared Resources contractE • Declared Templates • Declared Insertion Points • Declared Resources contractF • Declared Templates • Declared Insertion Points • Declared Resources JAR files in WEB-INF/lib Set of available contracts Facelet 1 Facelet 3Facelet 2 faces-config.xml
  • 45. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I45 Resource Library Contracts Loading Configuration contractA • Declared Templates • Declared Insertion Points • Declared Resources contractB • Declared Templates • Declared Insertion Points • Declared Resources contractC • Declared Templates • Declared Insertion Points • Declared Resources <web-app-root>/contracts contractD • Declared Templates • Declared Insertion Points • Declared Resources contractE • Declared Templates • Declared Insertion Points • Declared Resources contractF • Declared Templates • Declared Insertion Points • Declared Resources JAR files in WEB-INF/lib Set of available contracts Facelet 1 <f:view contracts="contractA"> ... Facelet 3Facelet 2 faces-config.xml
  • 46. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I46 Resource Library Contracts  Resource Library Contract – Convention  Available contracts discovered at startup  All of them are made available to the application  Assumes there are no naming collisions – Configuration  faces-config.xml <resource-library-contracts> element – Controls which parts of the app are allowed to use which contracts  contracts attribute in <f:view> – Declares that this view is only able to use these named contracts Modular Appearance
  • 47. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I47 Faces Flows Standards are for Standardizing, Not Innovating  ADF Task Flows  Spring Web Flow  Apache MyFaces CODI Architectural Pedigree
  • 48. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I48 Flow Concepts  Can be “called” from any place in the application  Single entry point  Input parameters and return values  Well defined interface contract – Internal implementation details hidden  New flowScoped for flow local storage  New @FlowScoped CDI annotation: automatic activation/passivation Hint: Think of a flow like a Java method
  • 49. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I49 Flow Navigation  Navigation is no longer just between pages  Navigation is now between flow “nodes”  Information Hiding comes to JSF. Welcome to 1972!  Multiple node types: – View – Method Call – Switch – Flow Call – Flow Return
  • 50. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I50 Flow Navigation  Flow represented at runtime by instance of javax.faces.flow.Flow  JSF 2.2 authoring experience – XML – Builder
  • 51. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I51 730 Faces Flows 1142 Resource Library Contracts  Two new concepts in JSF 2.2 – Resource Library Contract – Faces Flows  Each builds on the packaging scheme in JSF 2.0 – A special directory in the web app root  /contracts  /flows – A special location in the Classpath  /META-INF /contracts  /META-INF/flows What’s going on here?
  • 52. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I52 730 Faces Flows 1142 Resource Library Contracts  Two new concepts in JSF 2.2 – Resource Library Contract – Faces Flows  Each builds on the packaging scheme in JSF 2.0 – A special directory in the web app root  /contracts  /flows – A special location in the Classpath  /META-INF /contracts  /META-INF/flows What’s going on here? Useful during development Useful during deployment } }
  • 53. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I53 1142 Resource Library Contracts  DEMO Explore the contracts aspect of flow_and_contract and scrumtoys demo
  • 54. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I54 730 Faces Flows Standards are for Standardizing, Not Innovating  ADF Task Flows  Spring Web Flow  Apache MyFaces CODI Architectural Pedigree
  • 55. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I55 730 Faces Flows  Can be “called” from any place in the application  Single entry point  Input parameters and return values  Well defined interface contract – Internal implementation details hidden  New facesFlowScope for flow local storage  New @FlowScoped CDI annotation: automatic activation/passivation Hint: Think of a flow like a Java method
  • 56. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I56  Navigation is no longer just between pages  Navigation is now between flow “nodes”  Information Hiding comes to JSF. Welcome to 1972!  Multiple node types: – View – Method Call – Switch – Flow Call – Flow Return 730 Faces Flows Navigation
  • 57. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I57  Flow represented at runtime by instance of javax.faces.flow.Flow  JSF 2.2 authoring experience – XML – Builder 730 Faces Flows Navigation
  • 58. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I58 Flow Definition  Name of the flow  Where does the flow start?  Input values  Optional initializer & finalizer
  • 59. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I59 Flow Definition
  • 60. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I60 730 Faces Flows Spec challenge  Ensuring the feature works well with the existing JSF features – POSTback based navigation: <h:command{Button,Link}> – GET based navigation: <h:{button,link}>  Navigation rules – Was one level – Now is a stack – “return” case was tricky
  • 61. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I61 My plan for your time investment  How is JSF still relevant?  Big Ticket Features: in Context – 1055 Stateless Views: Context: Performance – 1090 HTML5 Friendly Markup: Context: Markup Evolution – 730 Flows and 1142 Resource Library Contracts: Context: Multi-tenancy and Modularity  Other features: Context free
  • 62. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I62 Other Features • Medium Sized • Small Sized
  • 63. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I63 Medium Sized Features 1. 1042 ViewActions 2. 869 CSRF protection 3. 949 ClientWindow 4. 802 File Upload 5. 763 CDI injection of JSF artifacts 6. 599 Programmatic Composite Component creation 7. 594, 703 FacesComponent enhancetments 8. 479 UIData implements Collection 9. 1001 Composite and Java components in the same library 10. 533 Programmatic faces-config
  • 64. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I64 1042 ViewActions  JSF 2.0 introduced <f:metadata> – Use with <f:viewParam>  JSF 2.2 introduces <f:viewAction> – Use inside of <f:metadata> – Use along side of <f:viewParam>  Like a button that clicks itself – Can cause navigation – Can choose the lifecycle phase  UIViewAction component sits behind <f:viewAction> tag.
  • 65. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I65 869 Cross Site Request Forgery Protection  What is Cross Site Request Forgery (CSRF, pronounced SEE-surf)? – http://en.wikipedia.org/wiki/Cross-site_request_forgery – Trick the browser into sending requests that the user did not actually intend to initiate JSF Is Not Just for POSTback Anymore
  • 66. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I66 869 Cross Site Request Forgery Protection  How does JSF protect your app against this attack? 1. It already does and always has! POSTback is a virture. JSF 2.2 just makes encryption of the view state on by default 2. New <protected-views> section in faces-config  View Token – When rendering a non-POSTback link or button  Referer [sic] and Origin headers JSF Is Not Just for POSTback Anymore
  • 67. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I67 949 ClientWindow  JSF finally has framework level support for the many different ways a UIComponent tree can be rooted – Browser tab – Browser window – Browser pop-up – Portlet – …  New class javax.faces.lifecycle.ClientWindow – A client window is always associated with exactly one UIViewRoot instance at a time, but may display many different UIViewRoots during its lifetime.
  • 68. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I68 949 ClientWindow  FacesServlet now must call Lifecycle.attachWindow()  Lifecycle.attachWindow() – Takes no action unless feature is enabled – Looks for incoming client window – Creates one if not present – Stores it on the ExternalContext How does it work?
  • 69. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I69 802 File Upload Component  For the benefit of Apache Tomcat users, JSF has always chosen to lag one Servlet version behind the Java EE umbrella spec in which it is included Why so long? Included JSF Version Included Servlet Version Minimum Servlet Version for Included JSF J2EE 1.4 1.1 2.4 2.3 Java EE 5 1.2 2.5 2.4 Java EE 6 2.0 3.0 2.5 Java EE 7 2.2 3.1 3.0
  • 70. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I70  Final spec has “Ajax” and non-Ajax support  “Ajax” can be XHR level 2 or hidden IFRAME <h:inputFile id="file" value="#{fileUploadBean.uploadedFile}"> <f:validator validatorId="FileValidator" /> </h:inputFile> 802 File Upload Component Usage
  • 71. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I71 @ManagedBean @RequestScoped public class FileUploadBean { private Part uploadedFile; // getter/setter public String getFileText() { String text = ""; if (null != uploadedFile) { try { InputStream is = uploadedFile.getInputStream(); text = new Scanner( is ).useDelimiter("A").next(); } catch (IOException ex) {} } return text; } } 802 File Upload Component Usage
  • 72. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I72 @FacesValidator(value="FileValidator") public class FileValidator implements Validator { @Override public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException { Part file = (Part) value; try { InputStream is = file.getInputStream(); text = new Scanner( is ).useDelimiter("A").next(); } catch (Exception ex) { throw new ValidatorException(“”, ex); } if (!text.contains("JSR-344")) { throw new ValidatorException(new FacesMessage("Invalid file”); } } 802 File Upload Component Usage
  • 73. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I73 763 CDI Injection of JSF Artifacts  All Common Annotation and CDI Annotations must work in – ELResolvers – Factories – JSF singletons (ResourceHandler, StateManager, etc) – ActionListeners
  • 74. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I74 599 Programmatic Component Creation  Application.createComponent() – Used to create UIComponent instances given component-family, etc  ViewDeclarationLanguage.createComponent() – Used to create UIComponent instances given tag library URI, tag name, and optional attributes – Equivalent to using the tag in a page – Designed for use with composite components
  • 75. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I75 594, 703 FacesComponent enhancements  @FacesComponent added in JSF 2.0 – Allows declaring a UIComponent to the runtime  JSF 2.2 adds new attributes (with sensible defaults) – createTag causes a facelet tag handler to automatically be created – namespace declares the tag library namespace in which the tag handler will reside – tagName declares the tag name – value now has a default behavior
  • 76. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I76 479 UIData supports Collection  Prior to JSF 2.2, UIData only supported – Arrays – java.util.List – java.sql.ResultSet – javax.servlet.jsp.jstl.sql.Result  JSF 2.2 adds – java.util.Collection
  • 77. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I77 1001 Composite and Regular Components  Prior to JSF 2.2, was not possible to have both kinds of components in the same tag library  Now it is. Both in the same tag library
  • 78. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I78 533 Programmatic faces-config  New class javax.faces.application.ApplicationConfigurationPopulator  Is a java.util.ServiceLoader service  Has a populateApplicationConfiguration() method – Gets passed an “empty” DOM Document – You can populate it as if it were a regular faces-config.xml file. – It gets put in with the rest of the discovered faces-config files.
  • 79. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I79 Other Features • Medium Sized • Small Sized
  • 80. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I80 Small Sized Features  1142 “reset button” API  766 Events from the Flash  1134 “role” passthrough attribute  1050 Ajax delay  1085 httpOnly cookie support
  • 81. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I81 Q&A
  • 82. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I82 The preceding was intended to outline our general product direction. It was intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle s products remains at the sole discretion of Oracle.
  • 83. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. I83