SlideShare une entreprise Scribd logo
1  sur  33
Enhancing The JavaServer Faces 2.0 Component Model Roger Kitain Staff Engineer/Sun Microosystens
We will explore the JSF 2.0 Component  Model and learn how we can enhance  components with JSF 2.0 features.
Agenda ,[object Object]
Composite Components
Enhancing JSF 2.0 Components
Demos
Component Model
JSF 2.0 Component Model Why Do We Need It? ,[object Object]
Renderer
Tag class
Tld
faces-config.xml
......
JSF 2.0 Component Model ,[object Object]
XHTML and tags
Eliminates translation/compilation
Templating ,[object Object],[object Object]
Composite Components
JSF 2.0 Component Model ,[object Object]
Enhanced to work with JSF 2.0 component building ,[object Object]
Namespaces created “automagically” – no more taglibs ,[object Object]
It's in the specification !
Composite Components
Composite Components ,[object Object]
True abstraction: ,[object Object]
Composite Components Using Page (XHTML) <html … xlms:my=”http....”> <my:comp value=”yes” />   </html> Component (XHTML)
Composite Components ,[object Object]
Library name is directory name
Tag name is file name
Composite Components <html  xmlns=”http:///www/w3/org/1999/xhtml” xmlns:h=” http://java.sun.com/jsf/html ” xmlns:f=” http://java.sun.com/jsf/core ” xmlns: my =” http://java.sun.com/jsf/composite/comp ”> On disk: <context root>/resources/ comp / out .xhtml < my : out  value=”yes”/>
Composite Components What's Inside The Black Box? ,[object Object],[object Object]
Everything page author needs to know to use component ,[object Object]
Composite Components <html... xmlns:ui=&quot;http://java.sun.com/jsf/facelets&quot; xmlns: cc =&quot;http://java.sun.com/jsf/composite&quot;>  … <h:body> <cc:interface> <cc:attribute name=”userVal” required=”true” ”/> <cc:attribute name=”passValue” required=”true” /> </cc:interface> <cc:implementation> <div> Username: <h:inputText id=”userId”” value=” #{cc.attrs.userVal }”/> </div> <div>Password:  <h:inputSecret id=”passId” value=” #{cc.attrs.passVal} ” /></div> <div> <h:commandButton value=”Login” id=”loginButton” /> </div> </cc:implementation> .... </h:body> ... <context-root>resources/ezcomp/LoginPanel.xhtml

Contenu connexe

Tendances

Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVCMaarten Balliauw
 
Vaadin Components @ Angular U
Vaadin Components @ Angular UVaadin Components @ Angular U
Vaadin Components @ Angular UJoonas Lehtinen
 
Introduction To ASP.NET MVC
Introduction To ASP.NET MVCIntroduction To ASP.NET MVC
Introduction To ASP.NET MVCAlan Dean
 
AngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsAngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsRapidValue
 
Introduction to React for Frontend Developers
Introduction to React for Frontend DevelopersIntroduction to React for Frontend Developers
Introduction to React for Frontend DevelopersSergio Nakamura
 
AngularJS for Beginners
AngularJS for BeginnersAngularJS for Beginners
AngularJS for BeginnersEdureka!
 
ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introductionTomi Juhola
 
AngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPIAngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPIEric Wise
 
Angular components
Angular componentsAngular components
Angular componentsSultan Ahmed
 
02 asp.net session02
02 asp.net session0202 asp.net session02
02 asp.net session02Mani Chaubey
 
Angular 8
Angular 8 Angular 8
Angular 8 Sunil OS
 
OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial IntroPamela Fox
 
Hands on SPA development
Hands on SPA developmentHands on SPA development
Hands on SPA developmentShawn Constance
 
Implementing auto complete using JQuery
Implementing auto complete using JQueryImplementing auto complete using JQuery
Implementing auto complete using JQueryBhushan Mulmule
 
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점Jeado Ko
 

Tendances (20)

Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
Vaadin Components @ Angular U
Vaadin Components @ Angular UVaadin Components @ Angular U
Vaadin Components @ Angular U
 
Introduction To ASP.NET MVC
Introduction To ASP.NET MVCIntroduction To ASP.NET MVC
Introduction To ASP.NET MVC
 
AngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsAngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue Solutions
 
Vaadin Components
Vaadin ComponentsVaadin Components
Vaadin Components
 
Introduction to React for Frontend Developers
Introduction to React for Frontend DevelopersIntroduction to React for Frontend Developers
Introduction to React for Frontend Developers
 
AngularJS for Beginners
AngularJS for BeginnersAngularJS for Beginners
AngularJS for Beginners
 
Training On Angular Js
Training On Angular JsTraining On Angular Js
Training On Angular Js
 
ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introduction
 
AngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPIAngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPI
 
Angular components
Angular componentsAngular components
Angular components
 
02 asp.net session02
02 asp.net session0202 asp.net session02
02 asp.net session02
 
Angular 8
Angular 8 Angular 8
Angular 8
 
OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial Intro
 
Hands on SPA development
Hands on SPA developmentHands on SPA development
Hands on SPA development
 
Angular Seminar-js
Angular Seminar-jsAngular Seminar-js
Angular Seminar-js
 
Implementing auto complete using JQuery
Implementing auto complete using JQueryImplementing auto complete using JQuery
Implementing auto complete using JQuery
 
Vaadin & Web Components
Vaadin & Web ComponentsVaadin & Web Components
Vaadin & Web Components
 
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
 
React django
React djangoReact django
React django
 

Similaire à Devoxx 09 (Belgium)

Introduction to JSF
Introduction toJSFIntroduction toJSF
Introduction to JSFSoftServe
 
Building Cool apps with flex
Building Cool apps with flexBuilding Cool apps with flex
Building Cool apps with flexJoseph Khan
 
Ajax Applications with RichFaces and JSF 2
Ajax Applications with RichFaces and JSF 2Ajax Applications with RichFaces and JSF 2
Ajax Applications with RichFaces and JSF 2Max Katz
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web ToolkitsYiguang Hu
 
Mashups as Collection of Widgets
Mashups as Collection of WidgetsMashups as Collection of Widgets
Mashups as Collection of Widgetsgiurca
 
Yahoo Mobile Widgets
Yahoo Mobile WidgetsYahoo Mobile Widgets
Yahoo Mobile WidgetsJose Palazon
 
JSF Component Behaviors
JSF Component BehaviorsJSF Component Behaviors
JSF Component BehaviorsAndy Schwartz
 
Java Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAXJava Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAXIMC Institute
 
Flex_rest_optimization
Flex_rest_optimizationFlex_rest_optimization
Flex_rest_optimizationKhou Suylong
 
What You Need To Build Cool Enterprise Applications With JSF
What You Need To Build Cool Enterprise Applications With JSFWhat You Need To Build Cool Enterprise Applications With JSF
What You Need To Build Cool Enterprise Applications With JSFMax Katz
 
Widgets: Making Your Site Great and Letting Others Help - WordCamp Victoria
Widgets: Making Your Site Great and Letting Others Help - WordCamp VictoriaWidgets: Making Your Site Great and Letting Others Help - WordCamp Victoria
Widgets: Making Your Site Great and Letting Others Help - WordCamp VictoriaJeff Richards
 
Struts2
Struts2Struts2
Struts2yuvalb
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedBG Java EE Course
 

Similaire à Devoxx 09 (Belgium) (20)

Rich faces
Rich facesRich faces
Rich faces
 
Introduction to JSF
Introduction toJSFIntroduction toJSF
Introduction to JSF
 
Os Johnson
Os JohnsonOs Johnson
Os Johnson
 
Building Cool apps with flex
Building Cool apps with flexBuilding Cool apps with flex
Building Cool apps with flex
 
Ajax Applications with RichFaces and JSF 2
Ajax Applications with RichFaces and JSF 2Ajax Applications with RichFaces and JSF 2
Ajax Applications with RichFaces and JSF 2
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
 
Mashups as Collection of Widgets
Mashups as Collection of WidgetsMashups as Collection of Widgets
Mashups as Collection of Widgets
 
BluePrint Mobile Framework
BluePrint Mobile FrameworkBluePrint Mobile Framework
BluePrint Mobile Framework
 
Yahoo Mobile Widgets
Yahoo Mobile WidgetsYahoo Mobile Widgets
Yahoo Mobile Widgets
 
JSF Component Behaviors
JSF Component BehaviorsJSF Component Behaviors
JSF Component Behaviors
 
EPiServer Web Parts
EPiServer Web PartsEPiServer Web Parts
EPiServer Web Parts
 
Facelets
FaceletsFacelets
Facelets
 
Facelets
FaceletsFacelets
Facelets
 
Java Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAXJava Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAX
 
Flex_rest_optimization
Flex_rest_optimizationFlex_rest_optimization
Flex_rest_optimization
 
Jsfsunum
JsfsunumJsfsunum
Jsfsunum
 
What You Need To Build Cool Enterprise Applications With JSF
What You Need To Build Cool Enterprise Applications With JSFWhat You Need To Build Cool Enterprise Applications With JSF
What You Need To Build Cool Enterprise Applications With JSF
 
Widgets: Making Your Site Great and Letting Others Help - WordCamp Victoria
Widgets: Making Your Site Great and Letting Others Help - WordCamp VictoriaWidgets: Making Your Site Great and Letting Others Help - WordCamp Victoria
Widgets: Making Your Site Great and Letting Others Help - WordCamp Victoria
 
Struts2
Struts2Struts2
Struts2
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advanced
 

Devoxx 09 (Belgium)

  • 1. Enhancing The JavaServer Faces 2.0 Component Model Roger Kitain Staff Engineer/Sun Microosystens
  • 2. We will explore the JSF 2.0 Component Model and learn how we can enhance components with JSF 2.0 features.
  • 3.
  • 5. Enhancing JSF 2.0 Components
  • 8.
  • 11. Tld
  • 14.
  • 17.
  • 19.
  • 20.
  • 21.
  • 22. It's in the specification !
  • 24.
  • 25.
  • 26. Composite Components Using Page (XHTML) <html … xlms:my=”http....”> <my:comp value=”yes” /> </html> Component (XHTML)
  • 27.
  • 28. Library name is directory name
  • 29. Tag name is file name
  • 30. Composite Components <html xmlns=”http:///www/w3/org/1999/xhtml” xmlns:h=” http://java.sun.com/jsf/html ” xmlns:f=” http://java.sun.com/jsf/core ” xmlns: my =” http://java.sun.com/jsf/composite/comp ”> On disk: <context root>/resources/ comp / out .xhtml < my : out value=”yes”/>
  • 31.
  • 32.
  • 33. Composite Components <html... xmlns:ui=&quot;http://java.sun.com/jsf/facelets&quot; xmlns: cc =&quot;http://java.sun.com/jsf/composite&quot;> … <h:body> <cc:interface> <cc:attribute name=”userVal” required=”true” ”/> <cc:attribute name=”passValue” required=”true” /> </cc:interface> <cc:implementation> <div> Username: <h:inputText id=”userId”” value=” #{cc.attrs.userVal }”/> </div> <div>Password: <h:inputSecret id=”passId” value=” #{cc.attrs.passVal} ” /></div> <div> <h:commandButton value=”Login” id=”loginButton” /> </div> </cc:implementation> .... </h:body> ... <context-root>resources/ezcomp/LoginPanel.xhtml
  • 34. Composite Components <html... xmlns:ui=&quot;http://java.sun.com/jsf/facelets&quot; xmlns: cc =&quot;http://java.sun.com/jsf/composite&quot;> … <h:body> <cc:interface> <cc:attribute name=”userVal” required=”true” ”/> <cc:attribute name=”passValue” required=”true” /> <cc:actionSource name=&quot;loginAction” targets=”loginButton” /> </cc:interface> <cc:implementation> <div> Username: <h:inputText id=”userId”” value=” #{cc.attrs.userVal }”/> </div> <div>Password: <h:inputSecret id=”passId” value=” #{cc.attrs.passVal} ” /></div> <div> <h:commandButton value=”Login” id=” loginButton ” /> </div> </cc:implementation> .... </h:body> ... <context-root>resources/ezcomp/LoginPanel.xhtml
  • 35.
  • 36.
  • 37. Rendered location may be different than the tag placement in the view
  • 38. <cc:interface...> … </cc:interface> <cc:implementation> <h:outputScript name=”script.js” library=”edit/script.js” target=”head”/> <h:outputStyleSheet name=”edit/styles.css”/> … </cc:implementation>
  • 39. Composite Components Nested Components <cc:interface...> <cc:attribute name=”location” required=”true”/> </cc:interface> <cc:implementation> <place:map title=”Map”/> </cc:implementation> <cc:interface> < cc:attribute name=”title” /> </cc:interface> <cc:implementation> <h:outputText value= ”#{cc.attrs.title}” /> <h:outputText value= ”#{cc.parent.attrs.location}” /> </cc:implementation>
  • 40. Enhancing JSF 2.0 Components
  • 41.
  • 42.
  • 43.
  • 44. Useful for making JSF Ajax calls from JavaScript
  • 45. Control component processing on the server and component rendering at the client
  • 46.
  • 47. Enhancing JSF 2.0 Components Ajax : Declarative Solution : Nested <f:ajax /> <h:commandButton ...> <h:commandButton...> <f:ajax event=”action” /> <f:ajax /> </h:commandButton> </h:commandButton> Do exactly the same thing since “action” is the default event for commandButton components. <h:commandButton...> <h:commandButton...> <f:ajax event=”valueChange”/> <f:ajax event=”mouseover”/> </h:commandButton> </h:commandbutton> Error: valueChange is not a supported event for commandButton components! JavaScript events supported too.
  • 48. Enhancing JSF 2.0 Components Ajax : Declarative Solution : <f:ajax /> Regions <f:ajax> <h:panelGrid> <h:inputText id=”text1”/> <h:commandButton id=”button1” /> </h:panelGrid> </f:ajax> Ajax applied to “text1” and “button1”. Ajax not applied to panelGrid since there is no default event associated with it.
  • 49. Enhancing JSF 2.0 Components Ajax : Declarative Solution : <f:ajax /> Combined <f:ajax event=”click”> <h:panelGrid id=”grid1”> <h:inputText id=”text1”/> <h:commandButton id=”button1”> <f:ajax event=”mouseover”/> </h:commandButton> </h:panelGrid> </f:ajax> Ajax applied to “grid1” and “text1” for “onlick” event. Ajax applied to “button1” for “mouseover” event as well.
  • 50.
  • 51.
  • 52.
  • 53. Ajax is a behavior (AjaxBehavior)
  • 54.
  • 55.
  • 57.
  • 58.
  • 59.
  • 60. Facelets is the foundation for JSF 2.0 components
  • 61. Most everything done in XHTML (Facelets) markup
  • 62. Enhance components using JSF 2.0 features such as Ajax and Behaviors
  • 63.
  • 64.