Java Server Faces (JSF)

streakconvertingSoftware and s/w Development

Dec 13, 2013 (3 years and 10 months ago)

137 views

Saif

Kamaal

Java Server Faces (JSF
)

Next Generation User Interface

About Me


Masters in Computer
Applciation

from Mumbai University.


Software developer for 3 years (2007)


Java Web development since 2006


SCJP, SCWCD,
Weblogic

Certified.


Recent projects use JSF
-

Richfaces
, Hibernate,
JBoss
, Oracle


Working on Code Generation.


Summary


Brief History of JSF.


Motivations for JSF, the Java Landscape.


JSF details.


Demo apps in JSF and
Richfaces
.


How UI Framework originated?


Tradition applications were desktop applications based on
AWT and then Swing.


The origin of internet and increase in the number of clients
gave rise to web based applications.


Traditional web based applications were written in
servlets

(still a number of projects are based on
servlets
).


Then came JSP and people said “We have got what we always
wanted”


no sooner they realized how wrong they were

.


Some technologies came here and went like light.


Application Development

a Layered Approach

Why go for a Layered Approach ?


strategic separation of different elements


each layer is organized to provide support and base
functionality to the next


easier to solve multiple small problems than fewer big ones


mitigates risk of technological evolution


value in consistency helps maintenance

A Common Layer Stack

Benefits of a Layered Approach


Change to a different Data Source with minimal effort
-

through Data Access Layer


Add new Deployment Options
-

e.g. Add a Web Services
Layer over the Business Services Layer


Storage & Data Structures are independent of the
Presentation Layer


and so on …

Layer Deployments on Tiers


Layers reside on the same machine, same runtime and any
object visible to one layer can be passed to the other either by
Value or by Reference.



Tiers could be on different machines or on different
runtimes, hence the data has to passed by Value only
-

as
serialized objects.

Issues with
Servlet


In terms of creating a
Grapical

user
interface,servlet

is tough
to
use.Because

you have to write huge code to send html text
to client.


No separation of concern. Java and HTML mix.


Change in presentation part also required compiling the
whole
servlet
.


And the list goes on….

Sample
Servlet

Code


Issues with JSP


JSP were created
beacause

complaints of developers like me
and you who were tired of typing
out.println
("<HTML><HEAD><TITLE>" +
pageInfo.getTitle
() + "</TITLE></HEAD>"); into their
servlet

code.


To solve the problem of separation of concerns but …


And so on..

Sample JSP Code


Saif

Kamaal

Emirates Group IT

Enters JSF


Next Generation User Interface

What is Java Server Faces?


JSF is a spec which defines a component
-
based MVC
framework


JSF 1.2 is included in the larger JEE5 spec


The spec was developed by involving many people from
orgs like Sun, Apache, IBM, Oracle


Not tied to a Web framework, nor a thick
-
client GUI


theoretically could be applied to either


Implementations, frameworks:


Sun RI vs. Apache
MyFaces


JBoss

Seam vs. Apache Struts 2 Shale


IBM, Oracle have proprietary solutions

The Problem with Web apps


HTML? HTML? Java people like Objects, HTML is not
Objects


Web programming is more difficult than GUI
programming


Java programming is hard


and J2EE is even more
difficult:
Servlets
? JSP? EJBs!?!


Microsoft has
VisualStudio

which turns web
programming into drag
-
and
-
drop, that looks easy! 10
minute demo!


Answer: a Framework!

(yet another framework, of course)


Struts


reduced lines of code, made apps pretty complex,
created a niche of skilled Struts mercenaries


WebWork



fixed some of the Struts hassle


SpringMVC



brought powerful AOP concepts to web dev


Tapestry


JSP? dump it, XML rules!


MVC

WARS


any Web apps in 2006 means seeing a mix of Struts, Tapestry,
Spring MVC, and
Webwork

(consultant: which one pays the best?)


the battle rages on, who will win? how can you tell who won?
Trust Craig? Trust Rod? How can a OSS project define victory?


Converting legacy apps: Struts is dead! long live Struts 2 Action
and Struts 2 Shale!!!


How can I possibly pick one for a new project, when the
technology is under attack?


JSF to the rescue


Make Committees, Not War!


get the
big

players together to solve MVC problems in a standard way,
argue, compromise, repeat... publish final Spec


Use components, not actions, more like Swing, less like Struts


Set a standard so we can build derivative products like IDEs with drag
-
n
-
drop ease, without worrying about change



The differentiator that JSF brings, which other similar


frameworks do not have, is the backing of a standard specification
(JSR127).



Because JSF is part of the J2EE standard specification, it is a top priority
for every major J2EE tools vendor in the market (including Oracle,
IBM, Borland, and Sun) to support it, which in turn will guarantee a
wide adoption


and good tools support.


and the main objective...


We will hit the target !!!!

3 Tier Application

MVC


not again …

How the two brothers are different?


How the JSF Specification Fits In

errr
... What’s a component?


the JSF spec defines a standard set of components and
relationships


the View layer (e.g. JSP) and the Java code on the server use
these components to interact and pass data


JSF tree is the current set of components in a Java object
graph


Struts,
Webwork
,
SpringMVC

use actions, not components


typical JSF component tree

View

Form

input

command

combo

input

Enough of
bla

bla
..some real action
please


Setup tools like Eclipse 3.5, Maven, 2.x, Tomcat/
JBoss
.


Download the
jsf

jars.


Additionally can use
JBoss

Tools.