3982515-JSFSeam - izugizosvn

seedjaggedInternet and Web Development

Nov 12, 2013 (3 years and 10 months ago)

71 views

Copyright AlphaCSP Israel 2008


Web Framework Playoff Seminar

2

Java Server Faces

adopting the standard

Roi Aldaag

Consultant, AlphaCSP

Copyright AlphaCSP Israel 2008


Web Framework Playoff Seminar

3

Agenda


Introduction


Architecture


Configuration


Features


Pros & Cons

Copyright AlphaCSP Israel 2008


Web Framework Playoff Seminar

4

Introduction

Not so long ago, if you “Googled“

the word
JSF
, you probably would

have come across …

Copyright AlphaCSP Israel 2008


Web Framework Playoff Seminar

5

Introduction

The F
-
35
J
oint
S
trike
F
ighter (JSF) …

Copyright AlphaCSP Israel 2008


Web Framework Playoff Seminar

6

Introduction

Today you’d find…

JavaServer Faces Technology

Copyright AlphaCSP Israel 2008


Web Framework Playoff Seminar

7

Introduction :: What is JSF?


What is JSF ?


Specification


UI framework


Component based


Server side


Java web applications

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

8

Introduction :: Motivation

9
Billion Reasons for JSF…

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

9

Introduction :: Motivation


JCP Standard




JSF 1.0/1.1

JSR 127


May 2005

JSF 1.2


JSR 252

May 2006

JSF 2.0

JSR 314

Q4 2008 ?






/ JEE6




Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

10

Introduction :: Motivation


Vendor adoption


JSF RI


MyFaces



Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

11

Introduction :: Motivation


Popularity


Commercial Projects


Open Source Projects


Market


Documentation

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

12

Introduction :: Motivation


IDE integration


Visual tool support


Drag & Drop


Auto
-
complete


Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

13

Introduction :: Motivation


Tools


Component Libraries


IceFaces


RichFaces


ADF / Trinidad


Tomahawk


Extensions


Facelets


Ajax4Jsf


DinoFaces



Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

14

Introduction :: Motivation


View Technology


JSP / Servlet


Other template engines


Facelets


JSFTemplating


Multiple rendering output

from same pages



Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

15

Introduction :: What is Seam?


What is Seam ?


A lightweight framework for JEE
5


Unifies JSF and EJB models

(Web Beans / JSR
299
)


Integrates JSF, POJOs, JPA, jBMP, Drools


Annotation / EL based


Extends JSF


JBoss OS (LGPL)


Release at
2006


Current version
2.0.2
SP
1

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

16

Introduction :: What is Seam?


Misconceptions


Can be used without EJB
3


Does not need a container


Has a small footprint


Easy integration






Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

17

Introduction :: Why JSF+Seam?


Why JSF + Seam?


JSF has some weaknesses…


Seam extends and enhances JSF


Reduces boilerplate code


Annotations


RESTful URLs


JSF Lifecycle


Contextual state management


Ajax Remoting


Exception Handling


Simple Integration


EJB
3
/ jBMP/ Drools / Spring





Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

18

Introduction :: Seam in action

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

19

Agenda


Introduction


Architecture


Configuration


Features


Pros & Cons

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

20

Architecture :: JSF MVC

Front Servlet
(
FacesServlet
)
Controller
Event Listeners
&
Action Handlers
(
ValueChangeListener
,
ActionListener
)
Config
(
faces
-
config
.
xml
)
Events
(
ValueChangeEvent
,
ActionEvent
)
Model
View
Component
Model
(
Java Beans
)
Delegates
(
Convertors
,
Validators
,
Renderers
)
Resources
(
JSP
,
XML
,
Properties
)
Component
Tree
(
UIComponent
)
Business
Objects
(
Managed Beans
)
Request
Response
UIViewRoot
UIForm
UIInput
UIInput
UIPanel

Model


View


Controller


Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

21

Architecture :: JSF MVC

Front Servlet
(
FacesServlet
)
Controller
Event Listeners
&
Action Handlers
(
ValueChangeListener
,
ActionListener
)
Config
(
faces
-
config
.
xml
)
Events
(
ValueChangeEvent
,
ActionEvent
)
Model
View
Component
Model
(
Java Beans
)
Delegates
(
Convertors
,
Validators
,
Renderers
)
Resources
(
JSP
,
XML
,
Properties
)
Component
Tree
(
UIComponent
)
Business
Objects
(
Managed Beans
)
Request
Response
UIViewRoot
UIForm
UIInput
UIInput
UIPanel
Model


POJO’s

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

22

Front Servlet
(
FacesServlet
)
Controller
Event Listeners
&
Action Handlers
(
ValueChangeListener
,
ActionListener
)
Config
(
faces
-
config
.
xml
)
Events
(
ValueChangeEvent
,
ActionEvent
)
Model
View
Component
Model
(
Java Beans
)
Delegates
(
Convertors
,
Validators
,
Renderers
)
Resources
(
JSP
,
XML
,
Properties
)
Component
Tree
(
UIComponent
)
Business
Objects
(
Managed Beans
)
Request
Response
UIViewRoot
UIForm
UIInput
UIInput
UIPanel
Controller


Front Servlet


Configuration


Event Listeners

Architecture :: JSF MVC

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

23

Architecture :: JSF MVC

Front Servlet
(
FacesServlet
)
Controller
Event Listeners
&
Action Handlers
(
ValueChangeListener
,
ActionListener
)
Config
(
faces
-
config
.
xml
)
Events
(
ValueChangeEvent
,
ActionEvent
)
Model
View
Component
Model
(
Java Beans
)
Delegates
(
Convertors
,
Validators
,
Renderers
)
Resources
(
JSP
,
XML
,
Properties
)
Component
Tree
(
UIComponent
)
Business
Objects
(
Managed Beans
)
Request
Response
UIViewRoot
UIForm
UIInput
UIInput
UIPanel
View


Component Tree


Component Model


Delegates


Resources

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

24

UIViewRoot
UIForm
UIInput
UIInput
UIPanel
...

<f:view>


<h:form>


<h:panelGrid columns = "
2
">


<h:inputText/>


<h:inputSecret/>


</panelGrid>


</h:form>

</f:view>

..


HTML

JSP

WML

XML

Architecture :: Component Tree

Markup

Component Tree

JSF tags

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

25

Architecture :: JSF Lifecycle

JSF Lifecycle

1.
Restore view

2.
Apply request values

3.
Process validations

4.
Update model values

5.
Invoke application

6.
Render response


Restore View
Apply Request
Values
Process Validation
Update Model
Values
Invoke Appilcation
Render Response
Request
Response
Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

26

Architecture :: Seam Lifecycle

Seam Lifecycle

1.
Restore view

2.
Restore Conversation

3.
Apply Page Parameters

4.
Apply request values

5.
Process validations

6.
Update model values

7.
Invoke application

8.
Process Selection

9.
Store Conversation

10.
Render response


Restore View
Apply Request
Values
Process Validation
Update Model
Values
Invoke Appilcation
Render Response
Request
Response
Store Conversation
Invoke Page Action
Process Data Model
Selection
Apply Page
Parameters
Restore
Conversation
Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

27

Architecture :: Seam Concepts

Seam Concepts

1.
Three Tier

2.
POJOs and annotations

3.
IoC and bijection

4.
Contextual state management

5.
Interceptors


Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

28

Agenda


Introduction


Architecture


Configuration


Features


Pros & Cons

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

29

Configuration :: JSF

faces
-
config.xml

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

30

Configuration :: Seam

faces
-
config.xml

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

31

Configuration :: JSF

web.xml

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

32

Configuration :: Seam

web.xml

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

33

Agenda


Introduction


Architecture


Configuration


Features


Pros & Cons

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

34

Features :: Demo JSF Project

LoginBean.java

MasterDetailBean.java

jsfLogin.jsp

jsfMasterDetail.jsp

faces
-
config.xml

web.xml

/
webproj
src
WebRoot
WEB
-
INF
managed
XML

XML

JSP

JSP

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

35

Features :: Demo Seam Project

LoginBean.java

MasterDetailBean.java

jsfLogin.jsp

jsfMasterDetail.jsp

faces
-
config.xml

web.xml

/
webproj
src
WebRoot
WEB
-
INF
managed
lib
classes
XML

XML

JSP

JSP

seam.properties

jboss
-
seam.jar

jboss
-
seam
-
ui.jar

components.xml

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

36

Features :: Demo Login page

jsfLogin.jsp

UIViewRoot

UIPanel

UIOutput

UIPanel

UIInput

UIForm

UIOutput

UIInput

UICommand

UIPanel

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

37

LoginBean.java

Features :: JSF Value Binding

jsfLogin.jsp

faces
-
config.xml

Unified EL

Managed Bean

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

38

LoginBean.java

Features :: JSF Method Binding

jsfLogin.jsp

Invoke Application

Phase

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

39

Features :: JSF State Management

jsfLogin.jsp

jsfMasterDetail.jsp

User

Dependency Injection

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

40

Features :: Seam State Management


Contextual state management


Bijection


@In
-

Injection


@Out


Outjection


Dynamic, contextual, bidirectional


Context Scope


Event < Page < Conversation <

Business Process < Session < Application


Conversation


Temporary conversation


Long
-
running conversation


ConversationId



Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

41

Features :: Seam State Management

MasterDetailBean.java

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

42

LoginBean.java

Features :: JSF Page Flow

jsfLogin.jsp

jsfMasterDetail.jsp

faces
-
config.xml

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

43

Features :: Seam Page Flow


Page Actions


HTTP GET


Bookmarking


RESTful URLs

HTTP POST

HTTP GET

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

44

Features :: Seam Page Flow


Page Flow


JBoss Business Process Management (jBPM)


Used to define process workflow / page flow


Define transition between pages


Define navigation rules for each page


Flow is based on events and conditions


Back button


In conversation mode, back button is disallowed


Undefined transition


Seam blocks actions from “stale” pages


Redirects to relevant page


<<
Start State
>>
start
<<
Page
>>
login
<<
Decision
>>
User
authenticated
?
<<
Page
>>
contacts
true
<<
End State
>>
end
false
Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

45

Features :: JSF Validations

MasterDetailBean.java

jsfMasterDetail.jsp

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

46

Features :: Seam Validations

jsfMasterDetail.jsp

MasterDetailBean.java

@org.hibernate.validator.Email

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

47

Features :: JSF Error Handling

javax.servlet.ServletException:
javax/servlet/jsp/tagext/JspIdConsumer

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

48

Features :: Seam Error Handling

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

49

Features :: Seam Error Handling

Exception Annotations


Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

50

Features :: Demo MasterDetail page

jsfMasterDetail.jsp

MasterDetailBean.java

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

51

Features :: Demo MasterDetail page

jsfMasterDetail.jsp
-

continued

HtmlDataTable

HtmlColumn

HtmlColumn

HtmlOutputText

HtmlOutputText

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

52

Features :: JSF Ajax


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:


Ajax
4
Jsf, Dynamic Faces

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

53

Features :: JSF Ajax


Ajax: Component Wide


Ajaxified components


Client validations


Client component interaction


Custom lifecycle


Example:


RichFaces, IceFaces, ADF (Trinidad)



Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

54

Features :: Seam Ajax


Ajax Remoting


Similar to DWR


Access seam components from JS


JavaScript APIs


Seam.Component


Seam.Remote


Expose server side components


@WebRemote


Compatible with Ajax
4
Jsf


Dojo / GWT integration


Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

55

Features :: Documentation


JSF


Specification


Forums


Books


Seam


Reference


Forums


Books



Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

56

Agenda


Introduction


Architecture


Configuration


Features


Pros & Cons

Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

57

Pros & Cons


Seam Sweet spots


Seam Gen (RoR)


Security (Role / Rule based)


Spring Integration


Integrated testing FW (TestNG)



Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

58

Pros & Cons


JSF Shortcomings


Too much wiring


HTTP GET / REST is hard


Complicated Lifecycle


Slow learning curve


Writing new components


Poor exception handling


Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

59

References


JSF


http://www.jcp.org/en/jsr/detail?id=
252


http://jcp.org/en/jsr/detail?id=
314


http://myfaces.apache.org/


Seam


http://www.jboss.com/products/seam


http://www.seamframework.org/


Copyright AlphaCSP Israel
2008


Web Framework Playoff Seminar

60

Thank

You !