jsf and seam

Post on 18-May-2015

11.892 Views

Category:

Business

5 Downloads

Preview:

Click to see full reader

DESCRIPTION

JSF & Seam by Roi Aldag from AlphaCSPwww.alphacsp.com

TRANSCRIPT

2Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Java Server FacesJava Server Facesadopting the standardadopting the standard

Roi AldaagConsultant, AlphaCSP

3Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

AgendaAgenda

Introduction Architecture Configuration Features Pros & Cons

4Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Introduction Introduction

Not so long ago, if you “Googled“the word JSF, you probably would have come across …

5Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Introduction Introduction

The F-35 Joint Strike Fighter (JSF) …

6Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Introduction Introduction

Today you’d find…

JavaServer Faces Technology

7Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Introduction :: What is JSF? Introduction :: What is JSF?

What is JSF ? Specification UI framework Component based Server side Java web applications

8Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Introduction :: MotivationIntroduction :: Motivation

9 Billion Reasons for JSF…

9Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Introduction :: MotivationIntroduction :: Motivation

JCP Standard

JSF 1.0/1.1 JSR 127 May 2005

JSF 1.2 JSR 252 May 2006JSF 2.0 JSR 314 Q4 2008 ?

/ JEE6

10Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Introduction :: Motivation Introduction :: Motivation

Vendor adoption JSF RI MyFaces

11Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Introduction :: Motivation Introduction :: Motivation

Popularity Commercial Projects Open Source Projects Market Documentation

12Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Introduction :: MotivationIntroduction :: Motivation

IDE integration Visual tool support Drag & Drop Auto-complete

13Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Introduction :: Motivation Introduction :: Motivation

Tools Component Libraries

IceFaces RichFaces ADF / Trinidad Tomahawk

Extensions Facelets Ajax4Jsf DinoFaces

14Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Introduction :: Motivation Introduction :: Motivation

View Technology JSP / Servlet Other template engines

Facelets JSFTemplating

Multiple rendering output from same pages

15Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Introduction :: What is Seam? Introduction :: What is Seam?

What is Seam ? A lightweight framework for JEE5 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 SP1

16Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Introduction :: What is Seam? Introduction :: What is Seam?

Misconceptions Can be used without EJB3 Does not need a container Has a small footprint Easy integration

17Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Introduction :: Why JSF+Seam?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 EJB3 / jBMP/ Drools / Spring

18Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Introduction :: Seam in actionIntroduction :: Seam in action

19Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

AgendaAgenda

Introduction Architecture Configuration Features Pros & Cons

20Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Architecture :: JSF MVCArchitecture :: JSF MVC

Front Servlet(FacesServlet)

Controller

Event Listeners &Action Handlers

(ValueChangeListener,ActionListener)

Config(faces-config.xml)

Events(ValueChangeEvent,

ActionEvent)

ModelView

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

21Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Architecture :: JSF MVCArchitecture :: JSF MVC

Front Servlet(FacesServlet)

Controller

Event Listeners &Action Handlers

(ValueChangeListener,ActionListener)

Config(faces-config.xml)

Events(ValueChangeEvent,

ActionEvent)

ModelView

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

22Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Front Servlet(FacesServlet)

Controller

Event Listeners &Action Handlers

(ValueChangeListener,ActionListener)

Config(faces-config.xml)

Events(ValueChangeEvent,

ActionEvent)

ModelView

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 MVCArchitecture :: JSF MVC

23Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Architecture :: JSF MVCArchitecture :: JSF MVC

Front Servlet(FacesServlet)

Controller

Event Listeners &Action Handlers

(ValueChangeListener,ActionListener)

Config(faces-config.xml)

Events(ValueChangeEvent,

ActionEvent)

ModelView

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

24Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

UIViewRoot

UIForm

UIInput UIInput

UIPanel

...<f:view>< h:form>

< h:panelGrid columns = "2>"< h:inputText>/< h:inputSecret>/

/< panelGrid>/< h:form>/<f:view>

..

...<f:view>< h:form>

< h:panelGrid columns = "2>"< h:inputText>/< h:inputSecret>/

/< panelGrid>/< h:form>/<f:view>

..

HTMLHTML

JSP

WMLWML

XMLXML

Architecture :: Component TreeArchitecture :: Component Tree

MarkupComponent TreeJSF tags

25Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Architecture :: JSF LifecycleArchitecture :: JSF Lifecycle

JSF Lifecycle1. Restore view2. Apply request values3. Process validations4. Update model values5. Invoke application6. Render response

Restore View

Apply Request Values

Process Validation

Update Model Values

Invoke Appilcation

Render Response

Request

Response

26Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Architecture :: Seam LifecycleArchitecture :: Seam Lifecycle

Seam Lifecycle1. Restore view2. Restore Conversation3. Apply Page Parameters4. Apply request values5. Process validations6. Update model values7. Invoke application8. Process Selection9. Store Conversation10. Render response

Restore View

Apply Request Values

Process Validation

Update Model Values

Invoke Appilcation

Render Response

Request

ResponseStore Conversation

Invoke Page Action

Process Data Model Selection

Apply Page Parameters

RestoreConversation

27Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Architecture :: Seam ConceptsArchitecture :: Seam Concepts

Seam Concepts1. Three Tier2. POJOs and annotations3. IoC and bijection4. Contextual state management5. Interceptors

28Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

AgendaAgenda

Introduction Architecture Configuration Features Pros & Cons

29Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Configuration :: JSFConfiguration :: JSF

faces-config.xml

30Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Configuration :: SeamConfiguration :: Seam

faces-config.xml

31Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Configuration :: JSFConfiguration :: JSF

web.xml

32Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Configuration :: SeamConfiguration :: Seam

web.xml

33Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

AgendaAgenda

Introduction Architecture Configuration Features Pros & Cons

34Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Features :: Demo JSF ProjectFeatures :: Demo JSF Project

LoginBean.java MasterDetailBean.java

jsfLogin.jsp jsfMasterDetail.jsp

faces-config.xmlweb.xml

/webproj

src

WebRoot

WEB-INF

managed

XML

XMLJSP

JSP

35Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Features :: Demo Seam ProjectFeatures :: Demo Seam Project

LoginBean.java MasterDetailBean.java

jsfLogin.jsp jsfMasterDetail.jsp

faces-config.xmlweb.xml

/webproj

src

WebRoot

WEB-INF

managed

lib

classes

XML

XML

JSP

JSP

seam.properties

jboss-seam.jar

jboss-seam-ui.jar

components.xml

36Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Features :: Demo Login pageFeatures :: Demo Login page

jsfLogin.jsp

UIViewRoot

UIPanel

UIOutput

UIPanel

UIInput

UIForm

UIOutput

UIInput

UICommand

UIPanel

37Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

LoginBean.java

Features :: JSF Value BindingFeatures :: JSF Value Binding

jsfLogin.jsp

faces-config.xml

Unified EL

Managed Bean

38Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

LoginBean.java

Features :: JSF Method BindingFeatures :: JSF Method Binding

jsfLogin.jsp

Invoke ApplicationPhase

39Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Features :: JSF State ManagementFeatures :: JSF State Management

jsfLogin.jsp jsfMasterDetail.jsp

User

Dependency Injection

40Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Features :: Seam State ManagementFeatures :: 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

41Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Features :: Seam State ManagementFeatures :: Seam State Management

MasterDetailBean.java

42Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

LoginBean.java

Features :: JSF Page FlowFeatures :: JSF Page Flow

jsfLogin.jsp jsfMasterDetail.jsp

faces-config.xml

43Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Features :: Seam Page FlowFeatures :: Seam Page Flow

Page Actions HTTP GET Bookmarking RESTful URLs

HTTP POST

HTTP GET

44Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Features :: Seam Page FlowFeatures :: 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

45Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Features :: JSF ValidationsFeatures :: JSF Validations

MasterDetailBean.java

jsfMasterDetail.jsp

46Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Features :: Seam ValidationsFeatures :: Seam Validations

jsfMasterDetail.jsp

MasterDetailBean.java

@org.hibernate.validator.Email

47Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Features :: JSF Error HandlingFeatures :: JSF Error Handling

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

48Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Features :: Seam Error HandlingFeatures :: Seam Error Handling

49Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Features :: Seam Error HandlingFeatures :: Seam Error Handling

Exception Annotations

50Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Features :: Demo MasterDetail pageFeatures :: Demo MasterDetail page

jsfMasterDetail.jsp

MasterDetailBean.java

51Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Features :: Demo MasterDetail pageFeatures :: Demo MasterDetail page

jsfMasterDetail.jsp - continued

HtmlDataTable

HtmlColumn HtmlColumn

HtmlOutputText HtmlOutputText

52Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Features :: JSF AjaxFeatures :: 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:

Ajax4Jsf, Dynamic Faces

53Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Features :: JSF AjaxFeatures :: JSF Ajax

Ajax: Component Wide Ajaxified components Client validations Client component interaction Custom lifecycle Example:

RichFaces, IceFaces, ADF (Trinidad)

54Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Features :: Seam AjaxFeatures :: 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 Ajax4Jsf Dojo / GWT integration

55Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Features :: DocumentationFeatures :: Documentation

JSF Specification Forums Books

Seam Reference Forums Books

56Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

AgendaAgenda

Introduction Architecture Configuration Features Pros & Cons

57Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Pros & ConsPros & Cons

Seam Sweet spots Seam Gen (RoR) Security (Role / Rule based) Spring Integration Integrated testing FW (TestNG)

58Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Pros & ConsPros & Cons

JSF Shortcomings Too much wiring HTTP GET / REST is hard Complicated Lifecycle Slow learning curve Writing new components Poor exception handling

59Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

ReferencesReferences

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/

60Copyright AlphaCSP Israel 2008 – Web Framework Playoff Seminar

Thank Thank You !You !

top related