SlideShare a Scribd company logo
1 of 27
Download to read offline
Ian Hlavats | Tarantula Consulting Inc.


                 JSF2
Composite Components Workshop
Ian Hlavats
•    JSF Consultant
•    info@tarantulaconsulting.com
•    Author, JSF 1.2 Components (Packt)
•    JSFToolbox for Dreamweaver
     (www.jsftoolbox.com)
JSF2 Composite Components
            Workshop
•  Goals:
  –  To review new features in JSF2
  –  To understand composite components,
     how they work, what problem they solve,
     when to use them, etc.
  –  To gain experience writing JSF2 composite
     components with several examples
Overview: JSF2
•  What’s new in JSF2?
  – Facelets integration (VDL)
  – Composite components
  – Resource libraries
  – EL 2.2 (method params)
  – Standardized Ajax
  – @ManagedBean
  – New scopes
  – Much more
Overview: JSF2
•  Why focus on composite components?
  –  Exciting new feature
  –  Requires Facelets
  –  Fully declarative UI components
  –  Great potential for simplifying JSF
  –  Unlock developer productivity
Composite Components
•  What problem do they solve?
  –  Lightweight, rapid UI development
  –  Traditional JSF component development is
     cumbersome (component, renderer, TLD,
     taglib.xml, faces-config.xml, web.xml)
•  Developers need a faster way to build/
   reuse user interface elements
Composite Components
•  How do they work?
   –    Define with new <composite> JSF tags
   –    Uses naming convention (namespace prefix, URI)
   –    No configuration needed
   –    Facelets only (no JSP)
   –    Can be packaged/deployed as a jar
   –    Can use resources (images, stylesheets, scripts, etc.)
   –    Special EL objects: #{cc}, #{resource}
•  Some terminology:
   –  Using page: the file that uses the composite
      component
   –  Component definition: the file that declares the
      composite component
Composite Components
•  Important naming convention:

<html
  xmlns:foo=“http://java.sun.com/jsf/composite/foo”>
<body>
<foo:hello />
</body>
</html>

•  The component is defined in
   /resources/foo/hello.xhtml
•  JSF 2 automatically detects and renders the
   component
JSF 2.1 <composite> taglib
<composite:actionSource>
<composite:attribute>
<composite:clientBehavior />
<composite:editableValueHolder>
<composite:extension>
<composite:facet>
<composite:implementation>
<composite:insertChildren>
<composite:insertFacet>
<composite:interface>
<composite:renderFacet>
<composite:valueHolder>
<composite:interface>
•  Declares the usage contract of the
   component

<composite:interface>
 …
</composite:interface>
<composite:implementation>
•  Defines the component implementation

<composite:interface />
<composite:implementation>
 <h:outputText value=“Hello World” />
</composite:implementation>
…
<foo:hello />
<composite:attribute>
•  Defines a tag attribute exposed to developer

<composite:interface>
 <composite:attribute name=“message”
required=“true” default=“Howdy” />
</composite:interface>
<composite:implementation>
 <h:outputText value=“#{cc.attrs.message}” />
</composite:implementation>
…
<foo:hello message=“Hello World” />
<composite:facet>
•  Defines a custom facet supported by this component

<composite:interface>
 <composite:facet name=“header” />
</composite:interface>
<composite:implementation>
 <composite:renderFacet name=“header” />
</composite:implementation>
…
<foo:facetExample>
 <f:facet name=“header”>
    <h:outputText value=“My Header” />
 </f:facet>
</foo:facetExample>
<composite:renderFacet>
•  Renders the facet’s content

<composite:implementation>
 <div class=“content”>
   <composite:renderFacet name=“content” />
 </div>
</composite:implementation>
…
<foo:myComponent>
 <f:facet name=“content”>
   <h:outputText value=“My Content” />
 </f:facet>
</foo:myComponent>
<composite:insertFacet>
•    Inserts the facet into the component subtree

<composite:implementation>
 <h:dataTable …>
   <composite:insertFacet name=“header” />
   <composite:insertFacet name=“footer” />
 </h:dataTable>
</composite:implementation>
…
<foo:myComponent>
 <f:facet name=“header”>
   <h:outputText value=“My Header” />
 </f:facet>
<f:facet name=“footer”>
   <h:outputText value=“My Footer” />
 </f:facet>
</foo:myComponent>
<composite:actionSource>
•  Defines ActionListener event published by the component

<composite:interface>
 <composite:actionSource name=“helloButton”
targets=“helloButton” />
</composite:interface>
<composite:implementation>
 <h:commandButton id=“helloButton” value=“Say Hello” />
</composite:implementation>
…
<foo:myComponent>
 <f:actionListener for=“helloButton”
binding=“#{bean.sayHello(ActionEvent)}” />
</foo:myComponent>
<composite:valueHolder>
•  Exposes a component’s non-editable value to the page author
   for registering a converter or validator

<composite:interface>
 <composite:valueHolder name=“country” />
</composite:interface>

<composite:implementation>
 <h:outputText value=“#{countryBean.country}” />
</composite:implementation>
…
<foo:country>
 <f:converter for=“country” converterId=“test.CountryConverter” />
</foo:country>
<composite:editableValueHolder>
•    Enables registration of a ValueChangeListener, Converter or Validator
     on one or more components within the composite component

<composite:interface>
 <composite:editableValueHolder name=“country” targets=“country” />
</composite:interface>
<composite:implementation>
 <h:selectOneMenu id=“country” value=“#{country}”>
   <f:selectItems value=“#{countryList}” />
 </h:selectOneMenu>
</composite:implementation>
…
<foo:countries>
 <f:converter for=“country” converterId=“countryConverter” />
 <f:validator for=“country” validatorId=“countryValidator” />
</foo:countries>
<composite:insertChildren>
•  Inserts the child UI components into the component
   subtree

<composite:implementation>
 <span style=“font-weight:bold”>
   <composite:insertChildren />
 </span>
</composite:implementation>
…
<foo:myComponent>
 <h:outputText value=“Hello ” />
 <h:outputText value=“World” />
</foo:myComponent>
<composite:clientBehavior>
•  Declares Ajax events that can be handled by the page author

<composite:interface>
 <composite:clientBehavior name=“speak” event=“action”
targets=“speakButton” />
</composite:interface>
<composite:implementation>
 <h:commandButton value=“Speak” id=“speakButton” />
 <h:commandButton value=“Don’t Speak” id=“noSpeakButton” />
</composite:implementation>
…
<foo:speak>
 <f:ajax event=”speak" onevent=”alert(‘Hello’)"/>
</foo:speak>
<composite:extension>
•  Enables design-time metadata to be
   included in the component interface

<composite:interface>
 <composite:attribute name=“message”>
  <composite:extension>
    <!-- Metadata XML here -->
  </composite:extension>
 </composite:attribute>
</composite:interface>
Composite Component
        Implicit EL Object
•  #{cc}
   –  Refers to the current composite component
•  #{cc.attrs}
   –  Refers to attributes map of composite component,
      e.g.
      #{cc.attrs.message} is reference to <foo:hello
      message=“Hello” />
•  #{cc.resourceBundleMap.key}
   –  Refers to composite component’s resource bundle
   –  Must be in same dir and have same name as
      component definition file:
      /resources/foo/hello.xhtml
      /resources/foo/hello.properties
Lab Exercises
1.  Hello World Component
2.  Country List Component
3.  Customer Info Panel Component
4.  Customer Registration Wizard
Hello World Component
1.  Write a JSF2 composite component
    that prints “Hello World”.
2.  Use this component from another
    page.
3.  Deploy and test using JBoss 7.
Country List Component
1.  Write a JSF2 composite component
    that renders a list of countries for
    selection.
2.  Use this component from another
    page.
3.  Implement the TODO comments.
4.  Deploy and test using JBoss 7.
Customer Info Panel
          Component
1.  Write a JSF2 composite component
    that receives input for a new customer.
2.  Include the country list component
    from lab #2.
3.  Use this component from another
    page.
4.  Implement the TODO comments.
5.  Deploy and test using JBoss 7.
Customer Registration Wizard
1.  Write a JSF2 composite component
    that uses the PrimeFaces Wizard
    component.
2.  Reuse the customer info panel
    component from lab 3.
3.  Implement a Feedback tab.
4.  Implement the TODO comments.
5.  Deploy and test using JBoss 7.

More Related Content

What's hot

Simple module Development in Joomla! 2.5
Simple module Development in Joomla! 2.5Simple module Development in Joomla! 2.5
Simple module Development in Joomla! 2.5Vishwash Gaur
 
jsf2-composite-components
jsf2-composite-componentsjsf2-composite-components
jsf2-composite-componentsEdward Burns
 
Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0
Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0
Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0Arun Gupta
 
Component Framework Primer for JSF Users
Component Framework Primer for JSF UsersComponent Framework Primer for JSF Users
Component Framework Primer for JSF UsersAndy Schwartz
 
JSF 2 and beyond: Keeping progress coming
JSF 2 and beyond: Keeping progress comingJSF 2 and beyond: Keeping progress coming
JSF 2 and beyond: Keeping progress comingAndy Schwartz
 
JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011Arun Gupta
 
Building a custom Oracle ADF Component
Building a custom Oracle ADF ComponentBuilding a custom Oracle ADF Component
Building a custom Oracle ADF ComponentWilfred van der Deijl
 
Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introductioncherukumilli2
 
Jsp elements
Jsp elementsJsp elements
Jsp elementsNuha Noor
 
Jsf2 composite-components
Jsf2 composite-componentsJsf2 composite-components
Jsf2 composite-componentsvinaysbk
 
Java Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsJava Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsBG Java EE Course
 

What's hot (18)

Simple module Development in Joomla! 2.5
Simple module Development in Joomla! 2.5Simple module Development in Joomla! 2.5
Simple module Development in Joomla! 2.5
 
jsf2-composite-components
jsf2-composite-componentsjsf2-composite-components
jsf2-composite-components
 
Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0
Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0
Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0
 
Component Framework Primer for JSF Users
Component Framework Primer for JSF UsersComponent Framework Primer for JSF Users
Component Framework Primer for JSF Users
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
 
Jsp
JspJsp
Jsp
 
JSF 2 and beyond: Keeping progress coming
JSF 2 and beyond: Keeping progress comingJSF 2 and beyond: Keeping progress coming
JSF 2 and beyond: Keeping progress coming
 
JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011
 
Building a custom Oracle ADF Component
Building a custom Oracle ADF ComponentBuilding a custom Oracle ADF Component
Building a custom Oracle ADF Component
 
Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introduction
 
JSP Directives
JSP DirectivesJSP Directives
JSP Directives
 
Jsp chapter 1
Jsp chapter 1Jsp chapter 1
Jsp chapter 1
 
Jsp lecture
Jsp lectureJsp lecture
Jsp lecture
 
Jsp elements
Jsp elementsJsp elements
Jsp elements
 
Jsf2 composite-components
Jsf2 composite-componentsJsf2 composite-components
Jsf2 composite-components
 
Java Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsJava Server Faces (JSF) - Basics
Java Server Faces (JSF) - Basics
 
Extend sdk
Extend sdkExtend sdk
Extend sdk
 
Jsp
JspJsp
Jsp
 

Viewers also liked

MVC on the Server and on the Client: How to Integrate Spring MVC and Backbone...
MVC on the Server and on the Client: How to Integrate Spring MVC and Backbone...MVC on the Server and on the Client: How to Integrate Spring MVC and Backbone...
MVC on the Server and on the Client: How to Integrate Spring MVC and Backbone...jaxconf
 
Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...
Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...
Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...jaxconf
 
Architecting Android Apps: Marko Gargenta
Architecting Android Apps: Marko GargentaArchitecting Android Apps: Marko Gargenta
Architecting Android Apps: Marko Gargentajaxconf
 
The Evolution of Java Persistence in EclipseLink: Shaun Smith
The Evolution of Java Persistence in EclipseLink: Shaun SmithThe Evolution of Java Persistence in EclipseLink: Shaun Smith
The Evolution of Java Persistence in EclipseLink: Shaun Smithjaxconf
 
From Tomcat to Java EE, making the transition with TomEE
From Tomcat to Java EE, making the transition with TomEEFrom Tomcat to Java EE, making the transition with TomEE
From Tomcat to Java EE, making the transition with TomEEjaxconf
 
Understanding Java Garbage Collection and What You Can Do About It: Gil Tene
Understanding Java Garbage Collection and What You Can Do About It: Gil TeneUnderstanding Java Garbage Collection and What You Can Do About It: Gil Tene
Understanding Java Garbage Collection and What You Can Do About It: Gil Tenejaxconf
 
The Spring 4 Update - Josh Long
The Spring 4 Update - Josh LongThe Spring 4 Update - Josh Long
The Spring 4 Update - Josh Longjaxconf
 
Building an Impenetrable ZooKeeper - Kathleen Ting
Building an Impenetrable ZooKeeper - Kathleen TingBuilding an Impenetrable ZooKeeper - Kathleen Ting
Building an Impenetrable ZooKeeper - Kathleen Tingjaxconf
 
What you need to know about Lambdas - Jamie Allen
What you need to know about Lambdas - Jamie AllenWhat you need to know about Lambdas - Jamie Allen
What you need to know about Lambdas - Jamie Allenjaxconf
 
The economies of scaling software - Abdel Remani
The economies of scaling software - Abdel RemaniThe economies of scaling software - Abdel Remani
The economies of scaling software - Abdel Remanijaxconf
 
Future of the Web - Yehuda Katz
Future of the Web - Yehuda KatzFuture of the Web - Yehuda Katz
Future of the Web - Yehuda Katzjaxconf
 
Getting started with Websocket and Server-sent Events using Java - Arun Gupta
Getting started with Websocket and Server-sent Events using Java - Arun Gupta Getting started with Websocket and Server-sent Events using Java - Arun Gupta
Getting started with Websocket and Server-sent Events using Java - Arun Gupta jaxconf
 
Multi Client Development with Spring - Josh Long
Multi Client Development with Spring - Josh Long Multi Client Development with Spring - Josh Long
Multi Client Development with Spring - Josh Long jaxconf
 
The New Reality: the Role of PaaS in Technology Innovation - Franklin Herbas
The New Reality: the Role of PaaS in Technology Innovation - Franklin HerbasThe New Reality: the Role of PaaS in Technology Innovation - Franklin Herbas
The New Reality: the Role of PaaS in Technology Innovation - Franklin Herbasjaxconf
 
Java PaaS Comparisons - Khanderao Kand
Java PaaS Comparisons - Khanderao KandJava PaaS Comparisons - Khanderao Kand
Java PaaS Comparisons - Khanderao Kandjaxconf
 
Apache Hadoop and its role in Big Data architecture - Himanshu Bari
Apache Hadoop and its role in Big Data architecture - Himanshu BariApache Hadoop and its role in Big Data architecture - Himanshu Bari
Apache Hadoop and its role in Big Data architecture - Himanshu Barijaxconf
 

Viewers also liked (16)

MVC on the Server and on the Client: How to Integrate Spring MVC and Backbone...
MVC on the Server and on the Client: How to Integrate Spring MVC and Backbone...MVC on the Server and on the Client: How to Integrate Spring MVC and Backbone...
MVC on the Server and on the Client: How to Integrate Spring MVC and Backbone...
 
Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...
Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...
Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...
 
Architecting Android Apps: Marko Gargenta
Architecting Android Apps: Marko GargentaArchitecting Android Apps: Marko Gargenta
Architecting Android Apps: Marko Gargenta
 
The Evolution of Java Persistence in EclipseLink: Shaun Smith
The Evolution of Java Persistence in EclipseLink: Shaun SmithThe Evolution of Java Persistence in EclipseLink: Shaun Smith
The Evolution of Java Persistence in EclipseLink: Shaun Smith
 
From Tomcat to Java EE, making the transition with TomEE
From Tomcat to Java EE, making the transition with TomEEFrom Tomcat to Java EE, making the transition with TomEE
From Tomcat to Java EE, making the transition with TomEE
 
Understanding Java Garbage Collection and What You Can Do About It: Gil Tene
Understanding Java Garbage Collection and What You Can Do About It: Gil TeneUnderstanding Java Garbage Collection and What You Can Do About It: Gil Tene
Understanding Java Garbage Collection and What You Can Do About It: Gil Tene
 
The Spring 4 Update - Josh Long
The Spring 4 Update - Josh LongThe Spring 4 Update - Josh Long
The Spring 4 Update - Josh Long
 
Building an Impenetrable ZooKeeper - Kathleen Ting
Building an Impenetrable ZooKeeper - Kathleen TingBuilding an Impenetrable ZooKeeper - Kathleen Ting
Building an Impenetrable ZooKeeper - Kathleen Ting
 
What you need to know about Lambdas - Jamie Allen
What you need to know about Lambdas - Jamie AllenWhat you need to know about Lambdas - Jamie Allen
What you need to know about Lambdas - Jamie Allen
 
The economies of scaling software - Abdel Remani
The economies of scaling software - Abdel RemaniThe economies of scaling software - Abdel Remani
The economies of scaling software - Abdel Remani
 
Future of the Web - Yehuda Katz
Future of the Web - Yehuda KatzFuture of the Web - Yehuda Katz
Future of the Web - Yehuda Katz
 
Getting started with Websocket and Server-sent Events using Java - Arun Gupta
Getting started with Websocket and Server-sent Events using Java - Arun Gupta Getting started with Websocket and Server-sent Events using Java - Arun Gupta
Getting started with Websocket and Server-sent Events using Java - Arun Gupta
 
Multi Client Development with Spring - Josh Long
Multi Client Development with Spring - Josh Long Multi Client Development with Spring - Josh Long
Multi Client Development with Spring - Josh Long
 
The New Reality: the Role of PaaS in Technology Innovation - Franklin Herbas
The New Reality: the Role of PaaS in Technology Innovation - Franklin HerbasThe New Reality: the Role of PaaS in Technology Innovation - Franklin Herbas
The New Reality: the Role of PaaS in Technology Innovation - Franklin Herbas
 
Java PaaS Comparisons - Khanderao Kand
Java PaaS Comparisons - Khanderao KandJava PaaS Comparisons - Khanderao Kand
Java PaaS Comparisons - Khanderao Kand
 
Apache Hadoop and its role in Big Data architecture - Himanshu Bari
Apache Hadoop and its role in Big Data architecture - Himanshu BariApache Hadoop and its role in Big Data architecture - Himanshu Bari
Apache Hadoop and its role in Big Data architecture - Himanshu Bari
 

Similar to JSF2 Composite Components Workshop

Andy Bosch - JavaServer Faces in the cloud
Andy Bosch -  JavaServer Faces in the cloudAndy Bosch -  JavaServer Faces in the cloud
Andy Bosch - JavaServer Faces in the cloudAndy Bosch
 
RichFaces 4: Rich Ajax Components For Your JSF Applications
RichFaces 4: Rich Ajax Components For Your JSF ApplicationsRichFaces 4: Rich Ajax Components For Your JSF Applications
RichFaces 4: Rich Ajax Components For Your JSF ApplicationsMax Katz
 
Extending eZ Platform v2 with Symfony and React
Extending eZ Platform v2 with Symfony and ReactExtending eZ Platform v2 with Symfony and React
Extending eZ Platform v2 with Symfony and ReacteZ Systems
 
Devoxx 09 (Belgium)
Devoxx 09 (Belgium)Devoxx 09 (Belgium)
Devoxx 09 (Belgium)Roger Kitain
 
Web Components v1
Web Components v1Web Components v1
Web Components v1Mike Wilcox
 
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложенияCodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложенияCodeFest
 
What's new and exciting with JSF 2.0
What's new and exciting with JSF 2.0What's new and exciting with JSF 2.0
What's new and exciting with JSF 2.0Michael Fons
 
Going Above JSF 2.0 with RichFaces and Seam
Going Above JSF 2.0 with RichFaces and SeamGoing Above JSF 2.0 with RichFaces and Seam
Going Above JSF 2.0 with RichFaces and SeamLincoln III
 
RichFaces 4 Webinar - New and Advanced Features
RichFaces 4 Webinar - New and Advanced FeaturesRichFaces 4 Webinar - New and Advanced Features
RichFaces 4 Webinar - New and Advanced FeaturesMax Katz
 
Training in Android with Maven
Training in Android with MavenTraining in Android with Maven
Training in Android with MavenArcadian Learning
 
In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces
In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces
In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces Skills Matter
 
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
 
Enhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order componentEnhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order componentYao Nien Chung
 
RichFaces CDK: Rapid JSF Component Development
RichFaces CDK: Rapid JSF Component DevelopmentRichFaces CDK: Rapid JSF Component Development
RichFaces CDK: Rapid JSF Component DevelopmentLukáš Fryč
 
Refactoring Large Web Applications with Backbone.js
Refactoring Large Web Applications with Backbone.jsRefactoring Large Web Applications with Backbone.js
Refactoring Large Web Applications with Backbone.jsStacy London
 
Refactor Large applications with Backbone
Refactor Large applications with BackboneRefactor Large applications with Backbone
Refactor Large applications with BackboneColdFusionConference
 
Refactor Large apps with Backbone
Refactor Large apps with BackboneRefactor Large apps with Backbone
Refactor Large apps with BackbonedevObjective
 
OttawaJS - React
OttawaJS - ReactOttawaJS - React
OttawaJS - Reactrbl002
 

Similar to JSF2 Composite Components Workshop (20)

Andy Bosch - JavaServer Faces in the cloud
Andy Bosch -  JavaServer Faces in the cloudAndy Bosch -  JavaServer Faces in the cloud
Andy Bosch - JavaServer Faces in the cloud
 
RichFaces 4: Rich Ajax Components For Your JSF Applications
RichFaces 4: Rich Ajax Components For Your JSF ApplicationsRichFaces 4: Rich Ajax Components For Your JSF Applications
RichFaces 4: Rich Ajax Components For Your JSF Applications
 
Extending eZ Platform v2 with Symfony and React
Extending eZ Platform v2 with Symfony and ReactExtending eZ Platform v2 with Symfony and React
Extending eZ Platform v2 with Symfony and React
 
Devoxx 09 (Belgium)
Devoxx 09 (Belgium)Devoxx 09 (Belgium)
Devoxx 09 (Belgium)
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
 
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложенияCodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
 
Jsf
JsfJsf
Jsf
 
What's new and exciting with JSF 2.0
What's new and exciting with JSF 2.0What's new and exciting with JSF 2.0
What's new and exciting with JSF 2.0
 
Going Above JSF 2.0 with RichFaces and Seam
Going Above JSF 2.0 with RichFaces and SeamGoing Above JSF 2.0 with RichFaces and Seam
Going Above JSF 2.0 with RichFaces and Seam
 
RichFaces 4 Webinar - New and Advanced Features
RichFaces 4 Webinar - New and Advanced FeaturesRichFaces 4 Webinar - New and Advanced Features
RichFaces 4 Webinar - New and Advanced Features
 
Training in Android with Maven
Training in Android with MavenTraining in Android with Maven
Training in Android with Maven
 
In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces
In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces
In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces
 
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
 
Enhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order componentEnhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order component
 
RichFaces CDK: Rapid JSF Component Development
RichFaces CDK: Rapid JSF Component DevelopmentRichFaces CDK: Rapid JSF Component Development
RichFaces CDK: Rapid JSF Component Development
 
Refactoring Large Web Applications with Backbone.js
Refactoring Large Web Applications with Backbone.jsRefactoring Large Web Applications with Backbone.js
Refactoring Large Web Applications with Backbone.js
 
Refactor Large applications with Backbone
Refactor Large applications with BackboneRefactor Large applications with Backbone
Refactor Large applications with Backbone
 
Refactor Large apps with Backbone
Refactor Large apps with BackboneRefactor Large apps with Backbone
Refactor Large apps with Backbone
 
Creation&imitation
Creation&imitationCreation&imitation
Creation&imitation
 
OttawaJS - React
OttawaJS - ReactOttawaJS - React
OttawaJS - React
 

Recently uploaded

The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 

Recently uploaded (20)

The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 

JSF2 Composite Components Workshop

  • 1. Ian Hlavats | Tarantula Consulting Inc. JSF2 Composite Components Workshop
  • 2. Ian Hlavats •  JSF Consultant •  info@tarantulaconsulting.com •  Author, JSF 1.2 Components (Packt) •  JSFToolbox for Dreamweaver (www.jsftoolbox.com)
  • 3. JSF2 Composite Components Workshop •  Goals: –  To review new features in JSF2 –  To understand composite components, how they work, what problem they solve, when to use them, etc. –  To gain experience writing JSF2 composite components with several examples
  • 4. Overview: JSF2 •  What’s new in JSF2? – Facelets integration (VDL) – Composite components – Resource libraries – EL 2.2 (method params) – Standardized Ajax – @ManagedBean – New scopes – Much more
  • 5. Overview: JSF2 •  Why focus on composite components? –  Exciting new feature –  Requires Facelets –  Fully declarative UI components –  Great potential for simplifying JSF –  Unlock developer productivity
  • 6. Composite Components •  What problem do they solve? –  Lightweight, rapid UI development –  Traditional JSF component development is cumbersome (component, renderer, TLD, taglib.xml, faces-config.xml, web.xml) •  Developers need a faster way to build/ reuse user interface elements
  • 7. Composite Components •  How do they work? –  Define with new <composite> JSF tags –  Uses naming convention (namespace prefix, URI) –  No configuration needed –  Facelets only (no JSP) –  Can be packaged/deployed as a jar –  Can use resources (images, stylesheets, scripts, etc.) –  Special EL objects: #{cc}, #{resource} •  Some terminology: –  Using page: the file that uses the composite component –  Component definition: the file that declares the composite component
  • 8. Composite Components •  Important naming convention: <html xmlns:foo=“http://java.sun.com/jsf/composite/foo”> <body> <foo:hello /> </body> </html> •  The component is defined in /resources/foo/hello.xhtml •  JSF 2 automatically detects and renders the component
  • 9. JSF 2.1 <composite> taglib <composite:actionSource> <composite:attribute> <composite:clientBehavior /> <composite:editableValueHolder> <composite:extension> <composite:facet> <composite:implementation> <composite:insertChildren> <composite:insertFacet> <composite:interface> <composite:renderFacet> <composite:valueHolder>
  • 10. <composite:interface> •  Declares the usage contract of the component <composite:interface> … </composite:interface>
  • 11. <composite:implementation> •  Defines the component implementation <composite:interface /> <composite:implementation> <h:outputText value=“Hello World” /> </composite:implementation> … <foo:hello />
  • 12. <composite:attribute> •  Defines a tag attribute exposed to developer <composite:interface> <composite:attribute name=“message” required=“true” default=“Howdy” /> </composite:interface> <composite:implementation> <h:outputText value=“#{cc.attrs.message}” /> </composite:implementation> … <foo:hello message=“Hello World” />
  • 13. <composite:facet> •  Defines a custom facet supported by this component <composite:interface> <composite:facet name=“header” /> </composite:interface> <composite:implementation> <composite:renderFacet name=“header” /> </composite:implementation> … <foo:facetExample> <f:facet name=“header”> <h:outputText value=“My Header” /> </f:facet> </foo:facetExample>
  • 14. <composite:renderFacet> •  Renders the facet’s content <composite:implementation> <div class=“content”> <composite:renderFacet name=“content” /> </div> </composite:implementation> … <foo:myComponent> <f:facet name=“content”> <h:outputText value=“My Content” /> </f:facet> </foo:myComponent>
  • 15. <composite:insertFacet> •  Inserts the facet into the component subtree <composite:implementation> <h:dataTable …> <composite:insertFacet name=“header” /> <composite:insertFacet name=“footer” /> </h:dataTable> </composite:implementation> … <foo:myComponent> <f:facet name=“header”> <h:outputText value=“My Header” /> </f:facet> <f:facet name=“footer”> <h:outputText value=“My Footer” /> </f:facet> </foo:myComponent>
  • 16. <composite:actionSource> •  Defines ActionListener event published by the component <composite:interface> <composite:actionSource name=“helloButton” targets=“helloButton” /> </composite:interface> <composite:implementation> <h:commandButton id=“helloButton” value=“Say Hello” /> </composite:implementation> … <foo:myComponent> <f:actionListener for=“helloButton” binding=“#{bean.sayHello(ActionEvent)}” /> </foo:myComponent>
  • 17. <composite:valueHolder> •  Exposes a component’s non-editable value to the page author for registering a converter or validator <composite:interface> <composite:valueHolder name=“country” /> </composite:interface> <composite:implementation> <h:outputText value=“#{countryBean.country}” /> </composite:implementation> … <foo:country> <f:converter for=“country” converterId=“test.CountryConverter” /> </foo:country>
  • 18. <composite:editableValueHolder> •  Enables registration of a ValueChangeListener, Converter or Validator on one or more components within the composite component <composite:interface> <composite:editableValueHolder name=“country” targets=“country” /> </composite:interface> <composite:implementation> <h:selectOneMenu id=“country” value=“#{country}”> <f:selectItems value=“#{countryList}” /> </h:selectOneMenu> </composite:implementation> … <foo:countries> <f:converter for=“country” converterId=“countryConverter” /> <f:validator for=“country” validatorId=“countryValidator” /> </foo:countries>
  • 19. <composite:insertChildren> •  Inserts the child UI components into the component subtree <composite:implementation> <span style=“font-weight:bold”> <composite:insertChildren /> </span> </composite:implementation> … <foo:myComponent> <h:outputText value=“Hello ” /> <h:outputText value=“World” /> </foo:myComponent>
  • 20. <composite:clientBehavior> •  Declares Ajax events that can be handled by the page author <composite:interface> <composite:clientBehavior name=“speak” event=“action” targets=“speakButton” /> </composite:interface> <composite:implementation> <h:commandButton value=“Speak” id=“speakButton” /> <h:commandButton value=“Don’t Speak” id=“noSpeakButton” /> </composite:implementation> … <foo:speak> <f:ajax event=”speak" onevent=”alert(‘Hello’)"/> </foo:speak>
  • 21. <composite:extension> •  Enables design-time metadata to be included in the component interface <composite:interface> <composite:attribute name=“message”> <composite:extension> <!-- Metadata XML here --> </composite:extension> </composite:attribute> </composite:interface>
  • 22. Composite Component Implicit EL Object •  #{cc} –  Refers to the current composite component •  #{cc.attrs} –  Refers to attributes map of composite component, e.g. #{cc.attrs.message} is reference to <foo:hello message=“Hello” /> •  #{cc.resourceBundleMap.key} –  Refers to composite component’s resource bundle –  Must be in same dir and have same name as component definition file: /resources/foo/hello.xhtml /resources/foo/hello.properties
  • 23. Lab Exercises 1.  Hello World Component 2.  Country List Component 3.  Customer Info Panel Component 4.  Customer Registration Wizard
  • 24. Hello World Component 1.  Write a JSF2 composite component that prints “Hello World”. 2.  Use this component from another page. 3.  Deploy and test using JBoss 7.
  • 25. Country List Component 1.  Write a JSF2 composite component that renders a list of countries for selection. 2.  Use this component from another page. 3.  Implement the TODO comments. 4.  Deploy and test using JBoss 7.
  • 26. Customer Info Panel Component 1.  Write a JSF2 composite component that receives input for a new customer. 2.  Include the country list component from lab #2. 3.  Use this component from another page. 4.  Implement the TODO comments. 5.  Deploy and test using JBoss 7.
  • 27. Customer Registration Wizard 1.  Write a JSF2 composite component that uses the PrimeFaces Wizard component. 2.  Reuse the customer info panel component from lab 3. 3.  Implement a Feedback tab. 4.  Implement the TODO comments. 5.  Deploy and test using JBoss 7.