2. What’s new in
JSF 2.0 ?
Roi Aldaag
Consultant, AlphaCSP
roia@alphacsp.com
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 2
3. Objective
Overview of the new requested
features of the upcoming
JSF 2.0
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 3
4. Agenda
Introduction
JSF Evolution
JSF 1.0 / 1.1
JSF 1.2
JSF 2.0
JSR 314
Community wish list
Technology Adoption
Ease of development
Features
Performance
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 4
5. Introduction
Something about acronyms
Definition
Motivation
JSF Ecosystem
Architecture
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 5
6. Something about acronyms…
Not so long ago, if you “Googled“
the word JSF, you probably would
have come across …
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 6
7. Something about acronyms…
The F-35 Joint Strike Fighter (JSF) …
(AKA Lightning II)
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 7
8. Something about acronyms…
Today you’d find…
JavaServer Faces Technology
And probably also … Sponsored Links
AlphaCSP
Specializes in high availability e-business
application design and ASP hosting
services on the UML, EJB, JAVA, J2EE,
CORBA, XML and WML platforms.
www.alphacsp.com
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 8
9. Definition
What is JSF?
Specification
UI framework
Component based
Server side
Java web applications
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 9
10. Motivation
Servlet/JSP API
No GUI structure
No model
No event handling mech.
No I18N support
AWT / Swing
Not web oriented
Many web frameworks
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 10
11. “Welcome to the jungle”
Java Web Frameworks (partial list)
Echo Bishop Macaw
Cocoon Barracuda Smile
Millstone Action Framework MyFaces
OXF Shocks Chiba
JBanana
Struts
SOFIA
JSF Jeenius
TeaServlet JWarp …
Tapestry
wingS
WebWork
Expresso
RIFE
Bento
Spring MVC
jStatemachine
Canyamo
jZonic
Maverick
OpenEmcee
JPublish
Turbine
JATO
Scope
Folium
Warfare
Jucas
JWAA
Verge
Jaffa
Niggle
Jacquard
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 11
12. Motivation
How do we choose?
We need a standard !
Vendor adoption
IDE integration
Support
JSF is a standard
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 12
13. JSF Ecosystem
• Open Source Projects:
SourceForge.net: over 100 projects
• Implementations
Open Source: Sun JSF RI, Apache MyFaces
Commercial: IBM, Oracle
• Third Party Components
IceSoft IceFaces, JBoss RichFaces, Oracle ADF,
Apache Tomahawk, Galileo Faces
• Extensions
Ajax4JSF, Dyno Faces, JSF Extensions
• IDE Support
IntelliJ, Eclipse, JDeveloper, Excadel Studio
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 13
14. Architecture
Controller • Model
Config
(faces-config.xml)
• View
• Controller
Events
Request (ValueChangeEvent,
ActionEvent)
Event Listeners &
Front Servlet Action Handlers
(FacesServlet) (ValueChangeListener,
ActionListener)
Component
Tree Component Business
(UIComponent) Model Objects
(Java Beans) (Managed Beans)
UIViewRoot
Delegates
UIForm (Convertors,
Validators,
Renderers)
Response UIPanel
UIInput UIInput
Resources
(JSP,
XML,
Properties)
View Model
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 14
15. Architecture
Controller • Controller
Config
(faces-config.xml)
• Front Servlet
Request Events
(ValueChangeEvent,
ActionEvent)
Event Listeners &
• Configuration
Front Servlet Action Handlers
• Event Listeners
(FacesServlet) (ValueChangeListener,
ActionListener)
Component
Tree Component Business
(UIComponent) Model Objects
(Java Beans) (Managed Beans)
UIViewRoot
Delegates
UIForm (Convertors,
Validators,
Renderers)
Response UIPanel
UIInput UIInput
Resources
(JSP,
XML,
Properties)
View Model
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 15
16. Architecture
Controller • Model
Config
(faces-config.xml)
• Business Objects
Request Events
(ValueChangeEvent,
ActionEvent)
Event Listeners &
• POJO’s
Front Servlet Action Handlers
(FacesServlet) (ValueChangeListener,
ActionListener)
Component
Tree Component Business
(UIComponent) Model Objects
(Java Beans) (Managed Beans)
UIViewRoot
Delegates
UIForm (Convertors,
Validators,
Renderers)
Response UIPanel
UIInput UIInput
Resources
(JSP,
XML,
Properties)
View Model
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 16
17. Architecture
Controller • View
Config
(faces-config.xml)
• Component Tree
Request Events
(ValueChangeEvent,
ActionEvent)
Event Listeners &
• Component Model
Front Servlet Action Handlers
• Delegates
(FacesServlet) (ValueChangeListener,
ActionListener)
• Resources
Component
Tree Component Business
(UIComponent) Model Objects
(Java Beans) (Managed Beans)
UIViewRoot
Delegates
UIForm (Convertors,
Validators,
Renderers)
Response UIPanel
UIInput UIInput
Resources
(JSP,
XML,
Properties)
View Model
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 17
18. Architecture
Lifecycle
Restore view
Apply request values
Process validations
Update model values
Invoke application
Render response
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 18
19. Architecture
Example
JSP with JSF tags
Component Tree
Markup
...
UIViewRoot
<f:fiew>
HTML
<h:form>
<h:panelGrid columns = "2"> UIForm
<h:inputText/>
<h:inputSecret/> WML
</panelGrid>
UIPanel
</h:form>
</f:view>
..
JSP XML
UIInput UIInput
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 19
21. JSF Evolution
History
JSF 1.0 / 1.1
JSF 2
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 21
22. History
JSF 1.0, 1.1 JSF 1.2 JSF 2.0
JSR 127 JSR 252 JSR 314
Servlet 2.3, JSP 1.2 Servlet 2.5, JSP 2.1
JSR Review Ballot: JSR Review Ballot: JSR Review Ballot:
May 2001 August 2004 May 2007
Final Release 2: Final Release 2: Final Release 2:
May 2004 May 2006 JEE6 – 4Q 2008
2004 2006 2008 ??
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 22
23. JSF 1.1 (JSR 127)
Shortcomings
JSF – JSP Mismatch
<h:commandLink action="foo">
Read between the lines
Read between the lines
<a href=“#” onClick=“…”></a>
</h:commandLink>
<h:commandLink action="foo"> <a href=“#” onClick=“…”>
<h:outputText Read between the lines
value="Read between the lines”/> </a>
</h:commandLink>
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 23
24. JSF 1.1 (JSR 127)
Shortcomings
JSF – JSP Mismatch
Different Lifecycle
Writing to the same stream
Limited EL
Not compatible with JSP EL
Forbidden nesting components (<c:forEach>)
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 24
25. JSF 1.2 (JSR 252)
JSP EL JSF EL
Improvements
New Content Interweaving Model
JSP ViewHandler, JSP Base Tag class Unified EL
Unified EL in JSTL (javax.el)
Deferred evaluation
Support get / set value
Support method invocation
Pluggable API for resolving expressions
JSTL integration (<c:forEach>)
Back Button / Multi Frame Apps
Message association
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 25
26. JSF 1.2 (JSR 252)
Shortcomings
Development
Customizing components is complicated
Exceptions are not descriptive
No support for annotations
Deployment
Unnecessary deployment step
Not JEE compliant (packaging, DI)
Components
Missing / Limited components
Security
No security model (managed beans, resources)
Ajax
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 26
27. Custom Components
Let’s say we
want a
collapsible
panel …
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 27
35. Exceptions: JSF 1.2
No centralized exception handling
Servlet filter
Poor documentation
“Silent error”
Validation error
No Exception
No log output
Need to use <h:messages/>
Unified EL wraps exception
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 35
36. Exceptions: JSF 1.2
exception.jsf
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<f:view>
<h:form>
<h:inputText value="#{myBean.name}"/>
</h:form>
</f:view>
MyBean.class
public class MyBean {
public String getName() {
if(true) throw new RuntimeException("my exception");
return "line not reached";
}
. . .
}
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 36
37. Exceptions: JSF 1.2
Instead of
A stack trace dump
javax.servlet.ServletException:
javax/servlet/jsp/tagext/JspIdConsumer
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 37
38. Exceptions: Facelets
We should be getting
Verbose description (location, tree, phase, variables)
javax.el.ELException: /exception.xhtml @7,40
value="#{myBean.name}": java.lang.RuntimeException
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 38
39. Ajax: JSF 1.2
• Good:
– Ajax “ready”
– JSF component maintain state
– Well defined req processing
– Hides JS from page author
• Bad:
– No built-in support
– No standard
– Full view rendering
– Incompatible comp. libraries
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 39
40. Templating: JSF 1.2
• No standard support
– <f:subview../>
– <c:import…/>
– <jsp:include …/>
Header
Nav Content
Footer
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 40
41. Community Reservations
“… It is OK to learn things,
but learning should be like
series of "AHA!" moments
and "WOW! they do that too!"
exclamations.
Learning JSF is series
of WTF moments -
and it should not be! …”
“JSF Articles – Wish List for JSF 2.0 and more AJAX+JSF”,
The Server Side, April 05, 2007
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 41
42. Community Reservations
“… I download 1 framework and it should be complete.
Don't tell me I need to download 5 other packages from
various websites to make it actually useful??? …”
“… JSF should not be like a mine-field. It should be fun to use.
It should be impossible for a silent error to occur, and
this is exactly what happens when you have a validation
error but no corresponding h:message(s) tag. …”
News / Comments -“JSF sucks...and has no hope”
The Server Side, 2007
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 42
43. Community Wish List
Facelets integration
Client Side Validation
Scoping
Easier Development of components
Simplify configuration
Centralized Exception handling
Navigation Rules API
Hard failure
…
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 43
44. The Irony
JSF defined a standard
UI development has advanced
JSF got “old”
Many great ideas
Many JSF extensions (to fill void)
New technologies
Irony: Back to starting point
Need for a new standard
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 44
45. JSF 2.0
JSR 314
Ease of development
Technology Adoption
Features
Performance
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 45
46. JSR 314
Purpose
Max. development productivity (IDE)
Min. maintenance complexity
Integrate with other web tech.
More responsive UI (Ajax)
Requirements
Ease of development
New Features & Fixes
Performance & Scalability
Technology Adoption
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 46
47. JSR 314
Specification Lead
Ed Burns Sun Microsystems, Inc.
Roger Kitain Sun Microsystems, Inc.
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 47
48. JSR 314
Milestones (anticipated):
Stage Start Finish
Author 1st Draft 7 Feb 07 9 Feb 07
2nd Draft Reviewed 15 Feb 07 9 Mar 07
Author 1st EG Public Draft 7 Mar 07 9 Mar 07
1st EG Public Draft Review 9 Mar 07 16 Mar 07
File JSR with JCP Apr 07 Apr 07
JSR Review Ballot Apr 07 May 07
EG Formation May 07 Aug 07
Early Draft Review Oct 07 Oct 07
Public Review Feb 08 Mar 08
Public Review Ballot Mar 08 Apr 08
Proposed Final Draft JavaEE6
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 48
49. JSR 314
Introducing the Experts
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 49
50. Let the experts play
Expert Group Kick-off
Meeting
Buy a Feature
Will the community
needs be met?
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 50
51. Let the experts play (cont.)
Feature List (partial):
Name Feature Cost
Facelets Templating, Component Aggregation 165
Zero Dep Eliminate Deployment Step 100
EZComp Simplify creation of customize 100
components
Ajax Expand lifecycle to be aware of Ajax, 80
client lifecycle
Errors Better error reporting 80
Listeners New listeners for lifecycle events 50
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 51
52. Let the experts play (cont.)
Feature List (cont.):
Name Feature Cost
Config. No faces-confix.xml, no web.xml 50
Mostly Get Bookmarking, support got “GET” 80
Annotations Components, managed beans, 25
navigation rules
Rendering Declarative rendering (no out.println) 25
Fix State Default to stateless components 80
Skins Skinning / Themeing 60
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 52
53. Let the experts play (cont.)
The Results:
Name Number of units purchased Cost
Ajax 5 80
Facelets 4 165
Annotations 4 25
State Saving 4 80
Validation++ 4 15
EZComp 3 100
Errors 3 80
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 53
54. JSF 2.0
JSR 314
Ease of development
Technology Adoption
Features
Performance
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 54
55. Ease Of Development
Annotations
Templating
Component Aggregation
Verbose Exceptions
JSF Artifacts in WAR
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 55
56. Ease Of Development
Annotations
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 56
57. Ease Of Development
Annotations: JSF 1.2
• Tedious XML
– faces-config.xml
– Web.xml
• JEE 5 Annotations
– @EJB
– @PersistenceContext
–…
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 57
58. Ease Of Development
Annotations: JSF 2.0
• Artifacts
– Managed beans @Property(el=true, saveState=true)
– Scope
– Navigation Rules @Bean
– Dependency Injection @PhaseListener
– Converters @Converter
– Validators
• Zero Configuration
• Skip deployment
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 58
59. Ease Of Development
Templating
• Faceletes Header
– Develop UI live
• JSF Templating Nav Content
– Pages, components
• Struts Tiles
Footer
– Layouts
– Screen definition
– Inheritance
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 59
60. JSF 2.0
JSR 314
Ease of development
Technology Adoption
Features
Performance
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 60
61. Technology Adoption
Ajax
Passing values between pages
Skinning / Themeing
Web Beans JSR 299
Client lifecycle / validation
Server Side Scripting
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 61
62. Technology Adoption
Ajax: Page wide
• Page wide support (region, zone)
• Add support to existing components
• Sub view processing
• Partial tree rendering
• Normal lifecycle
• Partial page refresh
• Example:
Ajax4Jsf, Dynamic Faces
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 62
72. Technology Adoption
Skinning / Themeing
• Example:
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 72
73. JSF 2.0
JSR 314
Ease of development
Technology Adoption
New Features
Performance
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 73
74. New Features
Separate build / render tree
Bookmarking
Additional standard components
AJAX aware lifecycle
Partial tree traversal
Page actions
Access to persistence store
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 74
75. New Features
Separate build / render tree
Initial Request
Render Response Phase
Create Component Tree
Render Tree
Postback Request
Restore View Phase
Create Component Tree
Render Response Phase
Render Tree
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 75
76. New Features
Bookmarking
JSF 1.2
No support in <h:form/>
Command component don’t generate GET
Use implicit “param”
Enhanced Support for Http GET
New lifecycle for non-faces request (init req)
Submitted values come from HTTP params
not (input components)
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 76
77. New Features
Additional standard components
Current set is to weak
Components from different vendors cannot coexist
Date Picker File Upload Tree
Tabbed Panel
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 77
78. JSF 2.0
JSR 314
Ease of development
Technology Adoption
Features
Performance
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 78
79. Performance
Save / restore page deltas
ADF
Client side component validations
Inter client component interaction
Example: Dual combo box
Caching for rendering
Improve PhaseListener Interceptor
Filter requests
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 79
80. Prolog
The question should be:
Not - will the community needs be met ?
But, will the community needs be met -
on time … ?
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 80
82. Definition
What is JSF ?
A server side user interface component framework for Java technology based
web applications.
Sun J2EE 1.4 Tutorial
A component-based, Web-tier UI framework
Mastering JavaServer Faces, Wiley 2004
A component architecture
A standard set of UI widgets
An application infrastructure
JavaServer Faces in Action, Manning 2005
A specification with implementations offered by multiple vendors
A set of user interface (UI) components
API for extending the standard components or developing new
JavaServerFaces,O’Reilly4002
A set of prefabricated UI (user interface) components
An event-driven programming model
A component model that enables third-party developers to supply additional
components
Core JavaServer Faces, Sun 2007
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 82
83. Resources
JSR Draft
https://javaserverfaces-spec-public.dev.java.net/
proposals/JSF-2_0-draft.html
JCP – JSR 314
http://jcp.org/en/jsr/detail?id=314
Ed Burns Blog
http://weblogs.java.net/blog/edburns
“The Requirements Scratchpad”
http://wiki.java.net/bin/view/Projects/Jsf2RequirementsScratchpad
Community Forums & Blogs
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 83
84. Wish List
Pre-JCP-filed draft for JavaServer Faces 2.0
JSR / Ed Burns
http://weblogs.java.net/blog/edburns
JSF 2.0 requirements scratchpad
http://wiki.java.net
JSF 2.0 is Here!
http://www.oreillynet.com/onjava
JSF 2.0 Wish List Part 1 / Kito Man
http://www.jsfcentral.com
EE6 wishlist part II: JSF / Gavin King
http://in.relation.to
JSF 2.0 Begins
…
Copyright AlphaCSP Israel 2007 - The JavaEdge Seminar 84