behind myths revealing jsf 2 and richfaces...

66
Behind Myths Revealing JSF 2 and RichFaces 4 Lukáš Fryč 12.2.2011

Upload: others

Post on 28-Sep-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Behind MythsRevealing JSF 2 and RichFaces 4

Lukáš Fryč12.2.2011

Page 2: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Agenda

• JavaServer Faces 2.0De-mystification

Newsworthy in 2.0

• RichFaces 4.0Conceptual Overview

New-comings in 4.0

• Question & Answers

Page 3: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

JSR-314JavaServer Faces

De-mystification

Page 4: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

JavaServer Faces 2.0

• Standard Face for JavaEE 6• Component-Oriented

• Strict MVC

Page 5: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Component Tree

Page 6: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

View SelectionRequest

Response

Model

http://localhost:8080/practice02-jsf/detail.jsf?auctionId=23

Page 7: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Request Life-CycleRequest

Restore View

Apply request values

Process validations

Update model values

Invoke application

Model

trigger update

invoke

convert & apply

validate

update

What's next?Response

Page 8: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Request Life-Cycle

Response

Model

Navigation Handler

chan

ge v

iew

outcome + state

Request

Restore View

Apply request values

Process validations

Update model values

Invoke application

What's next?

Page 9: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Request Life-Cycle

Render responseResponse

Model

Navigation Handler

rend

er

mar

kup

Request

Restore View

Apply request values

Process validations

Update model values

Invoke application

state

Page 10: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

JSF ~ View + ControllerModel

●Encapsulates application state

●Responds to state queries

●Exposes application functionality

●Notifies Views of changes

Controller●Defines application behavior

●Maps user actions to model updates

●Selects views for response

●One for each functionality

View●Renders the models

●Requests updates from models

●Sends user actions to controller

●Allow controller to select View

Change Notification

State Query

View Selection

User Actions

State Change

Navigation Handler

Page 11: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Model & ViewObject #{}

#{}#{}

#{}

Page 12: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Model & ViewObject #{}

#{}#{}

#{}

Expression Language

@Named

Page 13: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Bean Scope

Application

Session Session

Conversations

View View ViewView View View

index.xhtml xhtml xhtmlxhtml xhtml

t

index.xhtml

Render

Request

Page 14: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Model●Encapsulates application state

●Responds to state queries

●Exposes application functionality

●Notifies Views of changes

Controller●Defines application behavior

●Maps user actions to model updates

●Selects views for response

●One for each functionality

View●Renders the models

●Requests updates from models

●Sends user actions to controller

●Allow controller to select View

Change Notification

State Query

View Selection

User Actions

State Change

Navigation Handler

View Selection

State Change

ObjectJSF & Model

Page 15: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

JSR-314JavaServer Faces

Newsworthy in 2.0

Page 16: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

View Declaration Language(aka Facelets)

Page 17: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

VDL

Page 18: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

VDL ~ ui:insert

Page 19: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

VDL ~ ui:include

Page 20: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

VDL ~ ui:composition

Page 21: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

VDL ~ ui:param

Page 22: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

VDL ~ ui:define

Page 23: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Is it enough?

Page 24: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Composite Components

Page 25: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

CC ~ interface

Page 26: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

CC ~ implementation

Page 27: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

CC ~ usage

Page 28: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Client Behaviors

Page 29: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Client Behaviors

• Declarative Validation

• Request Queues

• DOM and Style Manipulation

• Visual Effects and Animations

• Tooltips and Hover Content

• Drag-n'-Drop

• Keyboard Shortcuts

• Deferred Data Fetching

Page 30: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Project Stages(development, testing, production)

Page 31: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Resource Loading

Page 32: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Resource Loading

• {war}/resources• {jar}/META-INF/resources

Page 33: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Resource Loading

[locale/][library/][version/]resource[/version]

resources/images/image1.pngresources/images/image2.png/v2resources/de/images/image2.pngresources/de_AT/images/image2.pngresources/styles/header.css/v11resources/scripts/1.0.0.Final/common.jsMETA-INF/resources/jQuery/1.4.4/jQuery-min.js

Page 34: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

System Events

Page 35: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Exception Handling

• ExceptionHandler deals all exceptions– Not caught in JSF life-cycle– Published by system event ExceptionQueuedEvent

Page 36: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Built-In Ajax

Page 37: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

f:ajax

Page 38: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces
Page 39: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

@execute

Page 40: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

@render

Page 41: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

@execute

Page 42: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

@render

Page 43: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

@execute + @render

• Specific component ID

• Keywords: @none, @this, @form, @all

Page 44: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Conceptual Overview

Page 45: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Extended Execution and Rendering

Page 46: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Extended Rendering

• @ajaxRendered• @limitRender

Page 47: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Extended Execution

• <a4j:region />

• New keyword: @region

Page 48: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Request Queues

Page 49: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Limiting Life-Cycle

Page 50: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

@immediateRequest

Restore View

Apply request values

Process validations

Update model values

Invoke application

Model

convert & apply

Response Render response

Navigation Handler

Page 51: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

@bypassUpdatesRequest

Restore View

Apply request values

Process validations

Update model values

Invoke application

Model

convert & apply

validate

Response Render response

Navigation Handler

Page 52: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Rich-Component Set

Page 53: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces
Page 54: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Rich-Component Set

• Server-Side– Listeners

• Client-Side– Event Handlers– JavaScript API– Component Control

Page 55: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Rich-Component Set

• Skinnability– Components richly marked by CSS classes– Additional classes definition

• Standard Component Skinning

Page 56: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Newcomings in 4.0

Page 57: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Push

Page 58: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Bean Validation Integration (JSR-303)

Page 59: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Client-SideBean Validation

Page 60: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Google App Enginehttp://richfaces-showcase.appspot.com/

Page 61: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Component Development Kit

Page 62: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

CKD ~ Best Way of Developing Custom Components

• Processes component class annotations

• Generates descriptors– faces-config.xml– taglib.xml

• Validates descriptors

• maven-cdk-plugin

Page 63: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Contribute & Follow

• Project Page: www.jboss.org/richfaces

• IRC on Freenode: #richfaces

• Source: http://anonsvn.jboss.org/repos/richfaces/

• User forum:– http://community.jboss.org/en/richfaces?

view=discussions

Page 64: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Czech JBoss User Group

Now in your city!

Come to the first session on March 2nd

at 6 p.m., FI MU

Kick-off planned: RESTeasy

Page 65: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

65

Lukáš Fryč12.2.2011

Questions & Answers

Page 66: Behind Myths Revealing JSF 2 and RichFaces 4rvokal.fedorapeople.org/devconf2011/jsf2-richfaces4.pdfAgenda • JavaServer Faces 2.0 De-mystification Newsworthy in 2.0 • RichFaces

Lukáš Fryč12.2.2011

Thank you for attention!