2. About Me
Apache MyFaces PMC Member
Co-author of “The Definitive Guide to Apache MyFaces and Facelets”
Reference in “Core JSF 2nd Edition”
Recognized speaker in international and local conferences (JSFOne, JSFDays...)
Oracle RCF Member
Krank Framework committer
JSF Chart Creator Author
YUI4JSF Project Lead
FacesTrace Project Lead
FC Barcelona Fan
Working for SpringSource
4. JSF 1.x Overview
Component Oriented
JSF 1.0, 1.1 and 1.2
Standard (jsr 127 and 252)
Two implementations
Apache MyFaces
Mojarra (RI)
5. JSF 1.x - The Good
Component oriented
Extendible
Third party components (Trinidad, Tomahawk,
RichFaces, IceFaces ...)
Rapid application development
Vendor and Tool support
6. JSF 1.x - The Bad
JSP based
Performance
Not very rich
Exception handling
Too much xml
A bit more...
7. JSF 2.0 Overview
JSR 314
Part of JEE 6
New features, improvements and fixes
Influenced by community and trends
Other web frameworks, Ajax, JSF extensions,
Component libs, blogs etc...
8. Roadmap
JSR process started in July, 2007
Early Draft Review 1 finished on July 2008
Early Draft Review 2 finished on Oct 2008
Proposed Final Draft Date, December 2008
Timed with JEE 6
9. So What’s New?
AJAX
Easy Component Development
Resource Loading
PDL (Page Description Language)
More Scopes
Less configuration
12. Resource Handling
What is a resource?
css, javascript, images ...
A resource has;
library, version, locale, name
Two new classes
javax.faces.application.Resource
javax.faces.application.ResourceHandler
Load from;
/resources
/META-INF/resources
13. Resource Handling
Resource Format
[localePrefix/] [libraryName/] [libraryVersion/] resourceName [/resourceVersion]
Examples
Under /resources or /META-INF/resources
- tr/mycoolcomponentlib/1.0/logo.png
- mycoolcomponentlib/1.0/widget.js/1.0.js
- mycoolcomponentlib/styles.css
Ability to load from classpath
14. Resources and
Custom Components
@ResourceDependency(name=”ajaxsuggest.js”, library=”mycoolcomponentlib”)
public class InputSuggest extends UIInput {...}
OR
@ResourceDependencies({
@ResourceDependency(name=”ajaxsuggest.js”, library=”mycoolcomponentlib”)
@ResourceDependency(name=”ajaxsuggest.css”, library=”mycoolcomponentlib”))}
public class InputSuggest extends UIInput {...}
OR
Application app = FacesContext.getCurrentInstance().getApplication();
Resource resource= app.getResourceHandler().createResource(“suggest.js”,”lib”);
writer.write(“<script ...”); //encode using request.getRequestPath();
19. Ajax and Custom
Components
Include ajax.js with annotation
@AjaxDependency(target=”head”)
public class MyAjaxComponent extends UIInput {
}
Or with ResourceHandler
ResourceHandler.createAjaxResource();
24. Project Stage
web.xml
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
JNDI
java:comp/env/jsf/ProjectStage
How to get it?
Application.getProjectStage()
26. System Events
Subscription based, no queueing
A bit similar to PhaseEvent idea
Ingridients
System Events
System Event Listeners
Subscribers (Application or UIComponent)
27. System Events
Application level system events
public abstract void subscribeToEvent(Class<? extends SystemEvent>
systemEventClass, SystemEventListener listener);
public abstract void subscribeToEvent(Class<? extends SystemEvent>
systemEventClass, Class sourceClass, SystemEventListener listener);
public abstract void publishEvent(Class<? extends SystemEvent>
systemEventClass, SystemEventListenerHolder source);
public void publishEvent(Class<? extends SystemEvent>
systemEventClass, Class<?> sourceBaseType, Object source);
28. System Events
UIComponent level system events
public void subscribeToEvent(Class<? extends SystemEvent>
eventClass, ComponentSystemEventListener componentListener);
public void unsubscribeFromEvent(Class<? extends SystemEvent>
eventClass, ComponentSystemEventListener componentListener);
AfterAddToParentEvent
BeforeRenderEvent ComponentSystemEvent
ViewMapCreatedEvent
ViewMapDestroyedEvent
29. System Events
Listen with annotations
@ListenerFor(systemEventClass=AfterAddToParentEvent.class)
public class MyComponent extends UIOutput {}
@ListenersFor({
@ListenerFor(systemEventClass=AfterAddToParentEvent.class,
@ListenerFor(systemEventClass=BeforeRenderEvent.class)})
public class MyComponent extends UIOutput {}
30. Scopes
ViewScope
For managed beans
Component scope
Composition
Conversation scope
Not in yet, through webbeans?
31. Scopes - ViewScope
A new managed bean scope
Lives until view is changed
@ManagedBean(name=”myBean”)
@ViewScoped
public class MyBeanInViewScope {
...
}
43. Future of JSF
More component libraries
JSF in EE (WebBeans, Seam, Spring Faces ...)
More RIA integration (Flex, Ajax ...)
Tool support
More adaptation
44. Resources
JSF 2.0 EG blog : http://blogs.jsfcentral.com/jsf2group
Ed Burns’s blog: http://weblogs.java.net/blog/edburns/
Ryan Lubke’s blog: http://blogs.sun.com/rlubke/
Jim Driscoll’s blog: http://weblogs.java.net/blog/driscoll/
JSR Page: http://jcp.org/en/jsr/detail?id=314
45. The End - Cheers!
http://cagataycivici.wordpress.com
cagatay@apache.org
PS3 Network id: FacesContext