SlideShare a Scribd company logo
JSF 2: myth or panacea?
Magic world of user
interfaces

Сергей Моренец
29 августа 2012 г.
Agenda
•
•
•
•
•

The history of Java Web frameworks
JSF specification and roadmap
JSF plugins and extensions
Custom components design
Q&A
Distributed App UI History
JSF 2: Myth of panacea? Magic world of user interfaces
Imagination
Reality
The history of Java Web
frameworks
The Servlet API
• The introduction in March 1998
• Enabled Java developers to write server-side code for
delivering dynamic Web content
• Java response to CGI
JavaServer Pages
•
•
•
•
•

Released in 1999 by Sun Microsystems
High-level abstraction of Java servlets
Java response to PHP
Adds tags and expression language
Works inside JSP container, which handles all JSP page
view requests.
Apache Struts
•
•
•
•
•

Introduced by Apache Foundation in 2000
Implementation of the Model-View-Controller paradigm
Enabled actions to support navigation
Templates in JSP, XML, Velocity
Struts 2 with AJAX and plugins support
Spring MVC
•
•
•
•
•

Released under Apache 2.0 license in 2003
Spring response to Struts framework
Tightly coupled to the Spring IOC container
Defines strategy interfaces for the responsibilities
Supports portlet development
The Birth of JSF
• Created as JSR #127
• Designed by Sun, Oracle, IBM and BEA in May 2001
• J2EE framework for building Web applications
The JSF Design Goals
• Create a standard UI component framework
• Define a set of lightweight Java classes for UI
components, component state, and input events
• Provide a set of common UI components
• Provide a JavaBeans model for dispatching events from
client-side UI controls to server-side application behavior
The JSF Design Goals
• Define APIs for input validation, including client-side
validation
• Specify a model for internationalization and localization
• Automatic support of all available client configuration
data, such as the browser version
• Support Web Accessibility Initiative (WAI)
History of JSF
• Simple things should be simple. Complex things
should be possible.
Alan Kay
JSF 1.0
• Initial release in March 2004
• Core and performance improvement
• Supports Servlet 2.3 and JSP 1.2
JSF 1.1
• Bugfix release in May 2004
• Performance issues
• Based on J2EE 1.3
JSF 1.2
•
•
•
•
•

Release in May 2006
Fully detached from JSP as view technology
Unified expression language support
Lack of Ajax out-of-box support
Core part of J2EE 5
JSF 2.0
Release in June 2009
JSP replaced by facelets as view technology
Full Ajax support similar to Ajax4jsf
Annotations and convention-over-configuration
invention
• New conversation scope
•
•
•
•
JSF Sample Page
•
•
•
•
•
•
•
•
•
•
•
•
•
•

<html xmlns=http://www.w3.org/1999/xhtml
xmlns:h=http://java.sun.com/jsf/html
xmlns:f="http://java.sun.com/jsf/core">
<h:body>
<h:form>
<h2>A Simple JSF Page</h2>
<h:outputText value="#{modelBean.currentDate}">
<f:convertDateTime type="both"
timeZone="#{userLocale.timeZone}" />
</h:outputText>
<h:inputText value="#{modelBean.username}"/>
<h:commandButton value="Click Here"/>
</h:form>
</h:body>
</html>
ModelBean.java
public class ModelBean {
private Date currentDate;
private String username;
public Date getCurrentDate() {
return currentDate;
}
public void setCurrentDate(Date currentDate) {
this.currentDate = currentDate;
}
public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}
}
Configuration file
•
•
•
•
•
•
•
•
•
•
•

•
•
•
•

<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<application>
<message-bundle>message</message-bundle>
</application>
<managed-bean>
<managed-bean-name>modelBean</managedbean-name>
<managed-beanclass>org.mycompany.ModelBean</managed-bean-class>
<managed-bean-scope>session</managed-beanscope>
</managed-bean>
</faces-config>
Component Rendering
Component LifeCycle
Built on JavaBeans
concepts
• UIComponent hierarchy
Properties
Methods
Events
Validators
Convertors
• Event model
Listener classes
Event objects
• Page navigation
JSF Implementations

• Oracle reference
implementation
• Sub-project of Glassfish

• UI widgets (MyFaces Tomahawk,
MyFaces Trinidad, MyFaces
Tobago)
• Extension packages to (MyFaces
Orchestra, MyFaces Extensions
Validator, MyFaces Extensions
CDI)
• Integration modules ( MyFaces
Portlet Bridge)
Mojarra vs. MyFaces performance
Testcase

MyFaces (ms)

Mojarra(ms)

1. JSF Protocol Tests

239

207

2. Full Body
Replacement

42

35

4134

4426

24

34

5. Double Eval
Detection

2047

2060

6. Table Test,
replacement of table
elements

7289

9229

6. Partial Page
Rendering Nav Case

2168

2308

7. Event Lifecycle test

130

131

3. Multi form situation
4. Testing for
decorated api calls
Ajax-enabled components and
frameworks
•

•
•
•
•
•
•
•
•

jBoss RichFaces, Ajax-enabled JSF components for layout, file
upload, forms, inputs and many other features.
ICEfaces, open-source, Java JSF extension framework and rich
components, Ajax without JavaScript
PrimeFaces Ajax framework with JSF components
Oracle ADF Faces Rich Client, Oracle Application Development
Framework
Backbase Enterprise Ajax — JSF Edition, Ajax framework
IBM Lotus Notes - XPages
MyFaces, The Apache Foundation JSF implementation with Ajax
components
Sun Java BluePrints AJAX Components
ZK Ajax framework with JSF components
RichFaces 4
•
•
•
•

•
•

•
•

A full set of AJAX enabled components
Client-side validation
Advanced queuing
Push component upgrades including
JavaMessaging Service (JMS) integrations
Component Development Kit (CDK).
Comprehensive documentation covering
development best practices, and component
details.
Detailed and automated testing facilities for
components, actions, listeners, and pages.
Broad cross-browser support
RichFaces Components
• Ajax4JSF
• RichFaces
Ajax4JSF
• Core Ajax functionality
• Page-level Ajax support
• Utility components
Rich components
• Self-contained and advanced UI components
• Extension of standard JSF components
• Pluggable customization though Ajax support
A Historical Perspective
• Created as Telamon project in 2005 by Alexander
Smirnov
• Released in 2006 as part of Exadel Visual
Component Platform
• Split into open-source Ajax4jsf and commercial
RichFaces in 2006
• Made open-source in 2007 as Jboss Ajax4jsf and
Jboss RichFaces
• Merged as single RichFaces product in September
2007
Alexander Smirnov
• Architect of the Jboss Richfaces project
• Java Server Faces expert group member
• Jboss GateIn portal developer
RichFaces Team
Client Side Validation
Data Table
Popup Panel
Data Grid
Tree
Rich Editor
Pick List
Push
RichFaces Push
•
•
•
•

Server-side push technique
Based on Atmosphere framework
Client-side support(Comet, HTML5 WebSockets)
Integration with Java Messaging Service
RichBean.java
• public Date getDate() {
•
return new Date();
• }
•
• public void push() throws MessageException {
•
TopicKey topicKey = new TopicKey("sampleAddress");
•
TopicsContext topicsContext =
TopicsContext.lookup();
•
•
topicsContext.publish(topicKey, "empty message");
• }
Index.html
• <a4j:commandButton value="Push!"
action="#{richBean.push}" />
•
• <a4j:push address="sampleAddress">
•
<a4j:ajax event="dataavailable"
render="outputDate" />
• </a4j:push>
•
• <a4j:outputPanel id="outputDate">
•
Date: #{richBean.date}
• </a4j:outputPanel>
Custom components
design in JSF 1.2
AdvancedDateComponent.java
• public class AdvancedDateComponent extends
UIComponentBase {
•
private HtmlSelectOneMenu dayCmb;
•
private HtmlSelectOneMenu monthCmb;
•
private HtmlSelectOneMenu yearCmb;
•
•
•
•

@Override
public String getFamily() {
return "advanced.Date";
}

•
•
•
•
•

@Override
public String getRendererType() {
return "renderer.advanced.Date";
}
AdvancedDateComponent.java
public Object getValue() {
ValueExpression _ve = getValueExpression("value");
return (_ve != null) ? _ve.getValue(getFacesContext().getELContext()) : null;
}
public void setSubmittedValue(FacesContext context) {
Map<String, String> requestParameterValuesMap = context.getExternalContext().
getRequestParameterMap();
String day = requestParameterValuesMap.get(dayCmb.getClientId(context));
String month =
requestParameterValuesMap.get(monthCmb.getClientId(context));
String year = requestParameterValuesMap.get(yearCmb.getClientId(context));
Calendar calendar = Calendar.getInstance();
calendar.set(Integer.valueOf(year), Integer.valueOf(month) - 1,
Integer.valueOf(day));

}

ValueExpression ve = getValueExpression(“value”);
ve.setValue(getFacesContext().getELContext(), calendar.getTime());
AdvancedDateRenderer.java
• public class AdvancedDateRenderer extends Renderer{
•
•
•
•
•
•
•
•

@Override
public void encodeBegin(FacesContext
context, UIComponent
component) throws IOException {
if(component instanceof AdvancedDateComponent)
{
CompositeDateComponent dateComponent =
(CompositeDateComponent)component;
dateComponent.refresh();
dateComponent.updateComponents();
}
AdvancedDateRenderer.java
• @Override
• public void decode(FacesContext context,
• UIComponent component) {
• if (component instanceof
AdvancedDateComponent) {
• AdvancedDateComponent dateComponent =
(AdvancedDateComponent) component;
• dateComponent.refresh();
• dateComponent.setSubmittedValue(context);
• }}}
Configuration file
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•

<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee">
<component>
<display-name>advancedDate</display-name>
<component-type>advanced.Date</component-type>
<component-class>org.test.component.AdvancedDateComponent
</component-class>
<component-extension>
<renderer-type>renderer.advanced.Date</renderer-type>
</component-extension>
</component>
<render-kit>
<renderer>
<component-family>advanced.Date</component-family>
<renderer-type>renderer.advanced.Date</renderer-type>
<renderer-class>org.test.component.AdvancedDateRenderer</rendererclass>
</renderer>
</render-kit>
</faces-config>
Tag configuration file
• <?xml version="1.0"?>
• <facelet-taglib xmlns="http://java.sun.com/JSF/Facelet">
• <namespace>http://test.org/web/tags</namespace>
<tag>
<tag-name>advancedDate</tag-name>
<component>
<componenttype>advanced.Date</component-type>
•
<renderertype>renderer.advanced.Date</renderer-type>
•
</component>
•
</tag>
•
•
•
•

• </facelet-taglib>
account.xhtml
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui=http://java.sun.com/jsf/facelets
xmlns:h="http://java.sun.com/jsf/html"
xmlns:web="http://test.org/web/tags">

<h:outputText value="#{msg['account.birthdate']}" />
<web:compositeDate value=“#{account.birthDate}"
/>
</ui:composition>
Custom components
design in JSF 2.0
Custom components
•
•
•
•

No configuration, XML or otherwise.
No Java code.
To which developers can attach functionality.
Hot-deploy.
compositeDate.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:cc="http://java.sun.com/jsf/composite">
<cc:interface>
<cc:attribute name="birthDate"
shortDescription="Value of the component" />
<cc:attribute name="days"
shortDescription="List of SelectItem objects representing days" />
<cc:attribute name="months"
shortDescription="List of SelectItem objects representing months"
/>
<cc:attribute name="years"
shortDescription="List of SelectItem objects representing years"
/>
</cc:interface>
compositeDate.xhtml
<cc:implementation>
<h:panelGrid columns="3">
<h:selectOneMenu value="#{date.day}">
<f:selectItems value="#{days}" />
</h:selectOneMenu>
<h:selectOneMenu value="#{date.month}">
<f:selectItems value="#{months}" />
</h:selectOneMenu>
<h:selectOneMenu value="#{date.year}">
<f:selectItems value="#{years}" />
</h:selectOneMenu>
</h:panelGrid>
</cc:implementation>
</html>
account.xhtml
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:tr="http://java.sun.com/jsf/composite/trai
ner">
<h:outputText value="#{msg['account.birthdate']}" />
<tr:compositeDate date=“#{account.birthDate}"
days="#{days}" months="months" years="#{years}" />

</ui:composition>
Disadvantages
Jobs at dice.com
StackOverflow tagged questions
•
•
•
•
•
•

High level of understanding
Limited community support
Lack of books and comprehensive documentation
Multiple resource-consuming dependencies
Performance overhead
Migration issues between RF3 and RF4
Love bug story
• I am migrating from RF 3.3.1 to 4.0. I'm experiencing
an issue with the tooltip component. Specifying
"bottom-left" for the direction attribute results in the
following error:
• javax.el.ELException: Cannot convert bottom-left of
type class java.lang.String to class
org.richfaces.component.Positioning
• Was this attribute implemented in 4.0? Am I doing
something wrong?
Love bug story
• Just in case someone else has the same issue, I've
figured it out. In RF 4, 'bottom-right' positioning is no
longer valid. You have to use 'bottomRight'. I am
completely shocked that none of these changes have
made it to their online documentation. I have wasted
time trying to figure out what was happening with this
component. I cannot believe users are expected to go
to the API JavaDocs and look through each class for
possible attribute values.
•
• If any RichFaces guys read this, please either update the
online documentation or remove it. There are way too
many components in there with information that has not
been updated and is just plain wrong
Q&A

• Сергей Моренец, morenets@mail.ru

More Related Content

PDF
Support Tools für die Admin-Konsole - Nebil Kisa, Advanced Support Engineer
PPTX
Integrating Alfresco with Portals
PDF
Mavenizing your Liferay project
PPT
Losing the Document Battle? Alfresco, Drupal Combine for Solution
PPTX
Workshop Framework(J2EE/OSGi/RCP)
PPTX
Getting started with microsoft office 365 share point online development
PPTX
Acing application lifecycle management in SharePoint
PDF
Alfresco Coding mit dem Alfresco SDK (auf Englisch) - Julien Bruinaud, Techni...
Support Tools für die Admin-Konsole - Nebil Kisa, Advanced Support Engineer
Integrating Alfresco with Portals
Mavenizing your Liferay project
Losing the Document Battle? Alfresco, Drupal Combine for Solution
Workshop Framework(J2EE/OSGi/RCP)
Getting started with microsoft office 365 share point online development
Acing application lifecycle management in SharePoint
Alfresco Coding mit dem Alfresco SDK (auf Englisch) - Julien Bruinaud, Techni...

What's hot (20)

PPTX
Pitfalls of Migrating to SharePoint 2010
PDF
Java modules
PPS
04 asp.net session05
PPTX
yii framework
PDF
Laravel and CodeIgniter: pros & cons
PPT
Introduction to Alfresco Surf Platform
PDF
The future of web development write once, run everywhere with angular js an...
PPTX
Sharepoint as a service platform
PPT
Developing modular Java applications
PPT
Best Practices Configuring And Developing Share Point Solutions
PPTX
Develop business apps cross-platform development using visual studio with x...
PPT
Netbeans 6.1 Talk
PPTX
Tarabica 2019 - Migration from ASP.NET MVC to ASP.NET Core
PDF
WCM Roadmap Versions 3 3 And 4 0
PDF
JDK 8 and JDK 8 Updates in OpenJDK
PDF
JEE 8, A Big Overview
PDF
JavaEE 6 tools coverage
PDF
Php apache vs iis By Hafedh Yahmadi
PPTX
Access share point-2013-data-with-provider-hosted-apps
PPT
Pitfalls of Migrating to SharePoint 2010
Java modules
04 asp.net session05
yii framework
Laravel and CodeIgniter: pros & cons
Introduction to Alfresco Surf Platform
The future of web development write once, run everywhere with angular js an...
Sharepoint as a service platform
Developing modular Java applications
Best Practices Configuring And Developing Share Point Solutions
Develop business apps cross-platform development using visual studio with x...
Netbeans 6.1 Talk
Tarabica 2019 - Migration from ASP.NET MVC to ASP.NET Core
WCM Roadmap Versions 3 3 And 4 0
JDK 8 and JDK 8 Updates in OpenJDK
JEE 8, A Big Overview
JavaEE 6 tools coverage
Php apache vs iis By Hafedh Yahmadi
Access share point-2013-data-with-provider-hosted-apps
Ad

Viewers also liked (17)

PPTX
Effective Java applications
PPTX
Effectiveness and code optimization in Java
PPTX
Getting ready to java 8
PPTX
Gradle.Enemy at the gates
PPTX
Java 8 in action.Jinq
PPTX
Gradle 2.Write once, builde everywhere
PPTX
Gradle 2.Breaking stereotypes
PPTX
Top 10 reasons to migrate to Gradle
PPTX
Git.From thorns to the stars
PPTX
Spring Web flow. A little flow of happiness
PPT
Spring Boot. Boot up your development
PPTX
Spring Web Flow. A little flow of happiness.
PPTX
Serialization and performance in Java
PPT
Spring Boot. Boot up your development. JEEConf 2015
PPTX
Spring.Boot up your development
PPTX
Junior,middle,senior?
PPTX
JEEConf 2016. Effectiveness and code optimization in Java applications
Effective Java applications
Effectiveness and code optimization in Java
Getting ready to java 8
Gradle.Enemy at the gates
Java 8 in action.Jinq
Gradle 2.Write once, builde everywhere
Gradle 2.Breaking stereotypes
Top 10 reasons to migrate to Gradle
Git.From thorns to the stars
Spring Web flow. A little flow of happiness
Spring Boot. Boot up your development
Spring Web Flow. A little flow of happiness.
Serialization and performance in Java
Spring Boot. Boot up your development. JEEConf 2015
Spring.Boot up your development
Junior,middle,senior?
JEEConf 2016. Effectiveness and code optimization in Java applications
Ad

Similar to JSF 2: Myth of panacea? Magic world of user interfaces (20)

PPTX
PDF
Utilizing JSF Front Ends with Microservices
PPT
Showcase_Intern
PDF
RichFaces 4 Component Deep Dive - JAX/JSFSummit
PDF
Ajax Applications with JSF2 and New RichFaces 4 at JAX 2011
PDF
Ajax Applications with JSF 2 and New RichFaces 4 - CONFESS 2011
PPT
Javafx
PDF
Java EE 7 Soup to Nuts at JavaOne 2014
PPTX
SoCal Code Camp 2011 - ASP.NET MVC 4
PDF
RichFaces 4 webinar #1: Everything You Need To Know
PDF
Ajax Applications with JSF 2 and New RichFaces 4 - JAX/JSF Summit
PPTX
reacts js with basic details Detailed_ReactJS_Presentation.pptx
PDF
Ajax Applications with JSF 2 and New RichFaces 4 - TSSJS
DOC
SYED_DANISH_J2EE_8YRs
PDF
Overview of Java EE 6 by Roberto Chinnici at SFJUG
PPTX
WebNetConf 2012 - Single Page Apps
PDF
Structured web apps
PPTX
ASP.NET Presentation
PDF
Build 2017 - Whats new for Xamarin Devs
PDF
Java EE 6, Eclipse @ EclipseCon
Utilizing JSF Front Ends with Microservices
Showcase_Intern
RichFaces 4 Component Deep Dive - JAX/JSFSummit
Ajax Applications with JSF2 and New RichFaces 4 at JAX 2011
Ajax Applications with JSF 2 and New RichFaces 4 - CONFESS 2011
Javafx
Java EE 7 Soup to Nuts at JavaOne 2014
SoCal Code Camp 2011 - ASP.NET MVC 4
RichFaces 4 webinar #1: Everything You Need To Know
Ajax Applications with JSF 2 and New RichFaces 4 - JAX/JSF Summit
reacts js with basic details Detailed_ReactJS_Presentation.pptx
Ajax Applications with JSF 2 and New RichFaces 4 - TSSJS
SYED_DANISH_J2EE_8YRs
Overview of Java EE 6 by Roberto Chinnici at SFJUG
WebNetConf 2012 - Single Page Apps
Structured web apps
ASP.NET Presentation
Build 2017 - Whats new for Xamarin Devs
Java EE 6, Eclipse @ EclipseCon

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
Big Data Technologies - Introduction.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
KodekX | Application Modernization Development
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
NewMind AI Weekly Chronicles - August'25 Week I
Review of recent advances in non-invasive hemoglobin estimation
Network Security Unit 5.pdf for BCA BBA.
Per capita expenditure prediction using model stacking based on satellite ima...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Big Data Technologies - Introduction.pptx
Encapsulation_ Review paper, used for researhc scholars
KodekX | Application Modernization Development
Advanced methodologies resolving dimensionality complications for autism neur...
Dropbox Q2 2025 Financial Results & Investor Presentation
The Rise and Fall of 3GPP – Time for a Sabbatical?
Digital-Transformation-Roadmap-for-Companies.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Spectral efficient network and resource selection model in 5G networks
20250228 LYD VKU AI Blended-Learning.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...

JSF 2: Myth of panacea? Magic world of user interfaces