SlideShare a Scribd company logo
1 of 40
Download to read offline
<Insert Picture Here>




Hyperproductive JSF 2.0
Arun Gupta, Java EE & GlassFish Guy
blogs.sun.com/arungupta, @arungupta
Beijing 2010
December 13–16, 2010




                       2
The following is intended to outline our general
product direction. It is intended for information
purposes only, and may not be incorporated into any
contract. It is not a commitment to deliver any
material, code, or functionality, and should not be
relied upon in making purchasing decisions.
The development, release, and timing of any
features or functionality described for Oracle’s
products remains at the sole discretion of Oracle.




                                                      3
Features, features, features, ...




                                    4
Facelets




           5
Facelets
• Designed for JSF from beginning
• XHTML + CSS
  – Document validation
• Better error handling, including line numbers
• Library prefixes as namespaces
• EL directly in page:
   – #{bean.propertyname}
• Templating made easy
   – ui:composition, ui:define, ui:insert
   – ui:include, ui:repeat


                                                  6
Facelets – Sample Code

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html">
  <h:head>
    <title>Enter Name &amp; Password</title>
  </h:head>
  <h:body>
    <h1>Enter Name &amp; Password</h1>
    <h:form>
      <h:panelGrid columns="2">
        <h:outputText value="Name:"/>
        <h:inputText value="#{simplebean.name}" title="name"
                     id="name" required="true"/>
        <h:outputText value="Password:"/>
        <h:inputText value="#{simplebean.password}" title="password"
                     id="password" required="true"/>
      </h:panelGrid>
      <h:commandButton action="show" value="submit"/>
    </h:form>
  </h:body>
</html>




                                                                       7
Composite Components




                       8
This...




          9
Becomes this...




                  10
Or maybe this:




                 11
Composite Components
• Enable True Abstraction
   – Create a true, reusable, component from an
     arbitrary region of a page
   – Built by composing other components
• “Using” and “Defining” page
• Full support for using attached objects in the
 using page
  – Action methods
  – Validators, etc




                                                   12
Composite Components – Sample Code




                                13
Composite Component – Sample Code

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html">
  <h:head>
    <title>Enter Name &amp; Password</title>
  </h:head>
  <h:body>
    <h1>Enter Name &amp; Password</h1>
    <h:form>
      <h:panelGrid columns="2">
        <h:outputText value="Name:"/>
        <h:inputText value="#{simplebean.name}" title="name"
                     id="name" required="true"/>
        <h:outputText value="Password:"/>
        <h:inputText value="#{simplebean.password}" title="password"
                     id="password" required="true"/>
      </h:panelGrid>
      <h:commandButton action="show" value="submit"/>
    </h:form>
  </h:body>
</html>




                                                                       14
Composite Components - Mapping
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:ez="http://java.sun.com/jsf/composite/ezcomp">
  <h:head>
    <title>Enter Name &amp; Password</title>
  </h:head>
  <h:body>
    <h1>Enter Name &amp; Password</h1>
    <h:form>
      <ez:username-password/>
      <h:commandButton action="show" value="submit"/>
    </h:form>
  </h:body>
</html>

                                                    . . .
                                                    WEB-INF
                                                    index.xhtml
                                                    resources/
                                                      ezcomp/
                                                        username-password.xhtml



 http://blogs.sun.com/arungupta/entry/totd_147_java_server_faces


                                                                             15
Integrated Ajax




                  16
Integrated Ajax

• Inspiration – ADF, RichFaces, IceFaces,
  DynamicFaces
• Two entry points:
 – Declarative: <f:ajax> tag, uses AjaxBehavior
 – Programmatic ajax
   • resource library javax.faces
   • resource name jsf.js
   • JavaScript namespace jsf.ajax.
     – jsf.ajax.request function


                                                  17
Integrated Ajax – Sample Code




<h:commandButton
      actionListener="#{sakilabean.findActors}"
      value="submit">
      <f:ajax execute="length"
          render="actorTable totalActors"/>
</h:commandButton>




http://blogs.sun.com/arungupta/entry/totd_123_f_ajax_bean



                                                            18
Partial State Saving




                       19
Partial State Saving

• Inspired by Trinidad state saving
• Save only the state that's changed since creation
  of the component tree
• Per-view state size up to 4X smaller
• Default for pages written with Facelets
• All standard components implement this feature
 – Default for composite components




                                                20
View Parameters




                  21
View Parameters
• Inspired by Page Parameters from Seam
• Provides a declarative way to map request
 parameters to EL-reachable location
  – <f:viewParam>, <f:metadata>

<f:metadata>
  <f:viewParam name="foo" value="#{bean.foo}"/>
</f:metadata>

page1.xhtml?foo=bar

bean.foo will equal “bar”


                                              22
System Events




                23
System Events

• Inspired by Solaris Dtrace, Linux strace, etc.
• Publish/Subscribe event bus for things that
  happen during the JSF Lifecycle
• Adds to event listening abilities
  – FacesEvent/FacesListener
  – PhaseEvent/PhaseListener
  – SystemEvent/SystemEventListener




                                                   24
System Event Types




                     25
System Events – Sample Code


<h:inputText>
    <f:event type="preValidate"
        listener="#{bean.doSomePreValidation}"/>
</h:inputText>



<h:inputText value="#{myBean.text}">
    <f:event type="beforeRender"
         listener="#{myBean.beforeTextRender}"/>
</h:inputText>




                                               26
Resources




            27
Resources
• Standard way to serve image, JavaScripts,
 CSS, …
 – No need for separate Servlet or Filter
 – Logically related to components, treat them that way
• @ResourceDependency or
  @ResourceDependencies on custom
  components
• Built in support for CSS, Image, JavaScript
  resources
• /resources or /META-INF/resources


                                                          28
Resource EL – Sample Code

• #{resource['<resource>']}
• #{resource['<library>:<resource>']}
• Examples of use
  – <a href="#{resource['header.jpg']}" />
  – <h:graphicImage
    value="#{resource['corp:header.jpg']}" />




                                           29
Behaviors




            30
Behaviors

• A Behavior is an interface and invents a new
  type of “attached object” which takes part in
  decode/encode of a component
• 3 new behaviors – ClientBehavior,
  ClientBehaviorHolder, AjaxBehavior
<h:commandLink
    onclick="return confirm('Really???')"/>
<h:commandLink>
    <foo:confirm message="Really???"/>
</h:commandLink>


                                                  31
Optional “faces-config.xml”

• <managed-bean> → @ManagedBean or @Named
  – Validator, Renderer, Listener, ...
• Default navigation rules – match a view on the
 disk
 – Conditional navigation

 @Named(“simplebean”)
 public class SimpleBean {
 . . .
 }

 <h:commandButton action="show" value="submit"/>


                                                   32
Lot more features ...

• Annotations
• Navigation
• Exceptions
• Validation
• EL
• Scopes
• Project Stage




                        33
Annotations

• @ManagedBean
• @*Scoped (Session, Request, etc)
• @ManagedProperty
• @FacesComponent
• @FacesConverter
• etc.
• With implicit Navigation, may eliminate need
 for faces-config.xml in many cases


                                                 34
Bookmarkable URLs



<h:link outcome="viewEntry" value="Link">
  <f:param name="entry" value="#{aBean.entry}"/>
</h:link>


<a
href="http://localhost:8080/myapp/viewEntry.xhtml
?entry=entry1">Link</a>



                                            35
EL (Expression Langauge)


• #{component}, #{cc} (composite
  component): get the “currently” processed
  component / composite component
• #{component.clientId}
• #{component.messageList}




                                              36
Validation

• Integration with JSR 303: Bean Validation
   – @NotEmpty String name;
   – default validator: javax.faces.Bean –
     automatically applied to all input fields
• Default-validator: hook up a validator for all
  instances of EditableValueHolder
• <f:validateBean>,
  <f:validateRequired>,
  <f:validateRegexp>


                                                   37
Project Stage

• Inspired by Rails
• Development
   – Better error reporting, debugging
• Production
  – Better performance




                                         38
References


• glassfish.org
• blogs.sun.com/theaquarium
• youtube.com/user/GlassFishVideos
• facebook.com/glassfish
• Follow @glassfish




                                     39
<Insert Picture Here>




Hyperproductive JSF 2.0
Arun Gupta, Java EE & GlassFish Guy
blogs.sun.com/arungupta, @arungupta

More Related Content

What's hot

A Peek At The Future: Going Beyond JavaServer Faces 2.0 With RichFaces 4
A Peek At The Future: Going Beyond JavaServer Faces 2.0 With RichFaces 4A Peek At The Future: Going Beyond JavaServer Faces 2.0 With RichFaces 4
A Peek At The Future: Going Beyond JavaServer Faces 2.0 With RichFaces 4balunasj
 
Layouts and Rendering in Rails, Season 2
Layouts and Rendering in Rails, Season 2Layouts and Rendering in Rails, Season 2
Layouts and Rendering in Rails, Season 2RORLAB
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Elena Kolevska
 
Templates
TemplatesTemplates
Templatessoon
 
Expression Language in JSP
Expression Language in JSPExpression Language in JSP
Expression Language in JSPcorneliuskoo
 
ACL in CodeIgniter
ACL in CodeIgniterACL in CodeIgniter
ACL in CodeIgnitermirahman
 
深入淺出 MVC
深入淺出 MVC深入淺出 MVC
深入淺出 MVCJace Ju
 
Jsf2 composite-components
Jsf2 composite-componentsJsf2 composite-components
Jsf2 composite-componentsvinaysbk
 
Mule esb
Mule esbMule esb
Mule esbKhan625
 
Lecture 2: Servlets
Lecture 2:  ServletsLecture 2:  Servlets
Lecture 2: ServletsFahad Golra
 
Java Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom TagsJava Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom TagsIMC Institute
 

What's hot (20)

A Peek At The Future: Going Beyond JavaServer Faces 2.0 With RichFaces 4
A Peek At The Future: Going Beyond JavaServer Faces 2.0 With RichFaces 4A Peek At The Future: Going Beyond JavaServer Faces 2.0 With RichFaces 4
A Peek At The Future: Going Beyond JavaServer Faces 2.0 With RichFaces 4
 
Jsf Ajax
Jsf AjaxJsf Ajax
Jsf Ajax
 
Layouts and Rendering in Rails, Season 2
Layouts and Rendering in Rails, Season 2Layouts and Rendering in Rails, Season 2
Layouts and Rendering in Rails, Season 2
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
 
Templates
TemplatesTemplates
Templates
 
Rails 4.0
Rails 4.0Rails 4.0
Rails 4.0
 
Presentation
PresentationPresentation
Presentation
 
Jsf
JsfJsf
Jsf
 
Expression Language in JSP
Expression Language in JSPExpression Language in JSP
Expression Language in JSP
 
Jsp Notes
Jsp NotesJsp Notes
Jsp Notes
 
Jsp
JspJsp
Jsp
 
ACL in CodeIgniter
ACL in CodeIgniterACL in CodeIgniter
ACL in CodeIgniter
 
Php frameworks
Php frameworksPhp frameworks
Php frameworks
 
Sightly - Part 2
Sightly - Part 2Sightly - Part 2
Sightly - Part 2
 
深入淺出 MVC
深入淺出 MVC深入淺出 MVC
深入淺出 MVC
 
Jsf2 composite-components
Jsf2 composite-componentsJsf2 composite-components
Jsf2 composite-components
 
Mule esb
Mule esbMule esb
Mule esb
 
Lecture 2: Servlets
Lecture 2:  ServletsLecture 2:  Servlets
Lecture 2: Servlets
 
Basic JSTL
Basic JSTLBasic JSTL
Basic JSTL
 
Java Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom TagsJava Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom Tags
 

Viewers also liked

Spark IT 2011 - Context & Dependency Injection in the Java EE 6 Ecosystem
Spark IT 2011 - Context & Dependency Injection in the Java EE 6 EcosystemSpark IT 2011 - Context & Dependency Injection in the Java EE 6 Ecosystem
Spark IT 2011 - Context & Dependency Injection in the Java EE 6 EcosystemArun Gupta
 
Running your Java EE 6 Apps in the Cloud - JavaOne India 2011
Running your Java EE 6 Apps in the Cloud - JavaOne India 2011Running your Java EE 6 Apps in the Cloud - JavaOne India 2011
Running your Java EE 6 Apps in the Cloud - JavaOne India 2011Arun Gupta
 
Java EE 7 Soup to Nuts at JavaOne 2014
Java EE 7 Soup to Nuts at JavaOne 2014Java EE 7 Soup to Nuts at JavaOne 2014
Java EE 7 Soup to Nuts at JavaOne 2014Arun Gupta
 
Java EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerJava EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerArun Gupta
 
Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010Arun Gupta
 
Understanding the nuts & bolts of Java EE 6
Understanding the nuts & bolts of Java EE 6Understanding the nuts & bolts of Java EE 6
Understanding the nuts & bolts of Java EE 6Arun Gupta
 
JavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
JavaOne India 2011 - Running your Java EE 6 Apps in the CloudJavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
JavaOne India 2011 - Running your Java EE 6 Apps in the CloudArun Gupta
 
JAX-RS 2.0: What’s New in JSR 339 ?
JAX-RS 2.0: What’s New in JSR 339 ?JAX-RS 2.0: What’s New in JSR 339 ?
JAX-RS 2.0: What’s New in JSR 339 ?Arun Gupta
 
The Java EE 7 Platform: Productivity++ & Embracing HTML5
The Java EE 7 Platform: Productivity++ & Embracing HTML5The Java EE 7 Platform: Productivity++ & Embracing HTML5
The Java EE 7 Platform: Productivity++ & Embracing HTML5Arun Gupta
 
Understanding
Understanding Understanding
Understanding Arun Gupta
 
PaaSing a Java EE 6 Application at Geecon 2012
PaaSing a Java EE 6 Application at Geecon 2012PaaSing a Java EE 6 Application at Geecon 2012
PaaSing a Java EE 6 Application at Geecon 2012Arun Gupta
 
GlassFish 3.1 – Simplifying your Java EE 6 Development and Deployment @ JAX L...
GlassFish 3.1 – Simplifying your Java EE 6 Development and Deployment @ JAX L...GlassFish 3.1 – Simplifying your Java EE 6 Development and Deployment @ JAX L...
GlassFish 3.1 – Simplifying your Java EE 6 Development and Deployment @ JAX L...Arun Gupta
 
Running your Java EE 6 applications in the Cloud
Running your Java EE 6 applications in the CloudRunning your Java EE 6 applications in the Cloud
Running your Java EE 6 applications in the CloudArun Gupta
 
JAX-RS 2.0: RESTful Web services on steroids at Geecon 2012
JAX-RS 2.0: RESTful Web services on steroids at Geecon 2012JAX-RS 2.0: RESTful Web services on steroids at Geecon 2012
JAX-RS 2.0: RESTful Web services on steroids at Geecon 2012Arun Gupta
 
Jfokus 2012: PaaSing a Java EE Application
Jfokus 2012: PaaSing a Java EE ApplicationJfokus 2012: PaaSing a Java EE Application
Jfokus 2012: PaaSing a Java EE ApplicationArun Gupta
 
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010Arun Gupta
 

Viewers also liked (17)

Spark IT 2011 - Context & Dependency Injection in the Java EE 6 Ecosystem
Spark IT 2011 - Context & Dependency Injection in the Java EE 6 EcosystemSpark IT 2011 - Context & Dependency Injection in the Java EE 6 Ecosystem
Spark IT 2011 - Context & Dependency Injection in the Java EE 6 Ecosystem
 
Running your Java EE 6 Apps in the Cloud - JavaOne India 2011
Running your Java EE 6 Apps in the Cloud - JavaOne India 2011Running your Java EE 6 Apps in the Cloud - JavaOne India 2011
Running your Java EE 6 Apps in the Cloud - JavaOne India 2011
 
Java EE 7 Soup to Nuts at JavaOne 2014
Java EE 7 Soup to Nuts at JavaOne 2014Java EE 7 Soup to Nuts at JavaOne 2014
Java EE 7 Soup to Nuts at JavaOne 2014
 
Java EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerJava EE 6 = Less Code + More Power
Java EE 6 = Less Code + More Power
 
Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010
 
Understanding the nuts & bolts of Java EE 6
Understanding the nuts & bolts of Java EE 6Understanding the nuts & bolts of Java EE 6
Understanding the nuts & bolts of Java EE 6
 
JavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
JavaOne India 2011 - Running your Java EE 6 Apps in the CloudJavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
JavaOne India 2011 - Running your Java EE 6 Apps in the Cloud
 
JAX-RS 2.0: What’s New in JSR 339 ?
JAX-RS 2.0: What’s New in JSR 339 ?JAX-RS 2.0: What’s New in JSR 339 ?
JAX-RS 2.0: What’s New in JSR 339 ?
 
The Java EE 7 Platform: Productivity++ & Embracing HTML5
The Java EE 7 Platform: Productivity++ & Embracing HTML5The Java EE 7 Platform: Productivity++ & Embracing HTML5
The Java EE 7 Platform: Productivity++ & Embracing HTML5
 
Understanding
Understanding Understanding
Understanding
 
PaaSing a Java EE 6 Application at Geecon 2012
PaaSing a Java EE 6 Application at Geecon 2012PaaSing a Java EE 6 Application at Geecon 2012
PaaSing a Java EE 6 Application at Geecon 2012
 
GlassFish 3.1 – Simplifying your Java EE 6 Development and Deployment @ JAX L...
GlassFish 3.1 – Simplifying your Java EE 6 Development and Deployment @ JAX L...GlassFish 3.1 – Simplifying your Java EE 6 Development and Deployment @ JAX L...
GlassFish 3.1 – Simplifying your Java EE 6 Development and Deployment @ JAX L...
 
Running your Java EE 6 applications in the Cloud
Running your Java EE 6 applications in the CloudRunning your Java EE 6 applications in the Cloud
Running your Java EE 6 applications in the Cloud
 
JAX-RS 2.0: RESTful Web services on steroids at Geecon 2012
JAX-RS 2.0: RESTful Web services on steroids at Geecon 2012JAX-RS 2.0: RESTful Web services on steroids at Geecon 2012
JAX-RS 2.0: RESTful Web services on steroids at Geecon 2012
 
Jfokus 2012: PaaSing a Java EE Application
Jfokus 2012: PaaSing a Java EE ApplicationJfokus 2012: PaaSing a Java EE Application
Jfokus 2012: PaaSing a Java EE Application
 
Java E
Java EJava E
Java E
 
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
 

Similar to Hyperproductive JSF 2.0 @ JavaOne Brazil 2010

Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen LjuSkills Matter
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortalJennifer Bourey
 
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
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
RichFaces: rich:* component library
RichFaces: rich:* component libraryRichFaces: rich:* component library
RichFaces: rich:* component libraryMax Katz
 
E2 appspresso hands on lab
E2 appspresso hands on labE2 appspresso hands on lab
E2 appspresso hands on labNAVER D2
 
E3 appspresso hands on lab
E3 appspresso hands on labE3 appspresso hands on lab
E3 appspresso hands on labNAVER D2
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to TornadoGavin Roy
 
SFDC UI - Advanced Visualforce
SFDC UI - Advanced VisualforceSFDC UI - Advanced Visualforce
SFDC UI - Advanced VisualforceSujit Kumar
 
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemAndres Almiray
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVCAlive Kuo
 
Developing your first application using FI-WARE
Developing your first application using FI-WAREDeveloping your first application using FI-WARE
Developing your first application using FI-WAREFermin Galan
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)Doris Chen
 
AnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFacesAnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFacesAnkara JUG
 
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
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterprisejQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterpriseDave Artz
 
Web applications with Catalyst
Web applications with CatalystWeb applications with Catalyst
Web applications with Catalystsvilen.ivanov
 

Similar to Hyperproductive JSF 2.0 @ JavaOne Brazil 2010 (20)

Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen Lju
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortal
 
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
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
RichFaces: rich:* component library
RichFaces: rich:* component libraryRichFaces: rich:* component library
RichFaces: rich:* component library
 
E2 appspresso hands on lab
E2 appspresso hands on labE2 appspresso hands on lab
E2 appspresso hands on lab
 
E3 appspresso hands on lab
E3 appspresso hands on labE3 appspresso hands on lab
E3 appspresso hands on lab
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
 
SFDC UI - Advanced Visualforce
SFDC UI - Advanced VisualforceSFDC UI - Advanced Visualforce
SFDC UI - Advanced Visualforce
 
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX Ecosystem
 
Web-Performance
Web-PerformanceWeb-Performance
Web-Performance
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
 
Developing your first application using FI-WARE
Developing your first application using FI-WAREDeveloping your first application using FI-WARE
Developing your first application using FI-WARE
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
 
Asp.net
Asp.netAsp.net
Asp.net
 
AnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFacesAnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFaces
 
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
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterprisejQuery in the [Aol.] Enterprise
jQuery in the [Aol.] Enterprise
 
Web applications with Catalyst
Web applications with CatalystWeb applications with Catalyst
Web applications with Catalyst
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
 

More from Arun Gupta

5 Skills To Force Multiply Technical Talents.pdf
5 Skills To Force Multiply Technical Talents.pdf5 Skills To Force Multiply Technical Talents.pdf
5 Skills To Force Multiply Technical Talents.pdfArun Gupta
 
Machine Learning using Kubernetes - AI Conclave 2019
Machine Learning using Kubernetes - AI Conclave 2019Machine Learning using Kubernetes - AI Conclave 2019
Machine Learning using Kubernetes - AI Conclave 2019Arun Gupta
 
Machine Learning using Kubeflow and Kubernetes
Machine Learning using Kubeflow and KubernetesMachine Learning using Kubeflow and Kubernetes
Machine Learning using Kubeflow and KubernetesArun Gupta
 
Secure and Fast microVM for Serverless Computing using Firecracker
Secure and Fast microVM for Serverless Computing using FirecrackerSecure and Fast microVM for Serverless Computing using Firecracker
Secure and Fast microVM for Serverless Computing using FirecrackerArun Gupta
 
Building Java in the Open - j.Day at OSCON 2019
Building Java in the Open - j.Day at OSCON 2019Building Java in the Open - j.Day at OSCON 2019
Building Java in the Open - j.Day at OSCON 2019Arun Gupta
 
Why Amazon Cares about Open Source
Why Amazon Cares about Open SourceWhy Amazon Cares about Open Source
Why Amazon Cares about Open SourceArun Gupta
 
Machine learning using Kubernetes
Machine learning using KubernetesMachine learning using Kubernetes
Machine learning using KubernetesArun Gupta
 
Building Cloud Native Applications
Building Cloud Native ApplicationsBuilding Cloud Native Applications
Building Cloud Native ApplicationsArun Gupta
 
Chaos Engineering with Kubernetes
Chaos Engineering with KubernetesChaos Engineering with Kubernetes
Chaos Engineering with KubernetesArun Gupta
 
How to be a mentor to bring more girls to STEAM
How to be a mentor to bring more girls to STEAMHow to be a mentor to bring more girls to STEAM
How to be a mentor to bring more girls to STEAMArun Gupta
 
Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018Arun Gupta
 
The Serverless Tidal Wave - SwampUP 2018 Keynote
The Serverless Tidal Wave - SwampUP 2018 KeynoteThe Serverless Tidal Wave - SwampUP 2018 Keynote
The Serverless Tidal Wave - SwampUP 2018 KeynoteArun Gupta
 
Introduction to Amazon EKS - KubeCon 2018
Introduction to Amazon EKS - KubeCon 2018Introduction to Amazon EKS - KubeCon 2018
Introduction to Amazon EKS - KubeCon 2018Arun Gupta
 
Mastering Kubernetes on AWS - Tel Aviv Summit
Mastering Kubernetes on AWS - Tel Aviv SummitMastering Kubernetes on AWS - Tel Aviv Summit
Mastering Kubernetes on AWS - Tel Aviv SummitArun Gupta
 
Top 10 Technology Trends Changing Developer's Landscape
Top 10 Technology Trends Changing Developer's LandscapeTop 10 Technology Trends Changing Developer's Landscape
Top 10 Technology Trends Changing Developer's LandscapeArun Gupta
 
Container Landscape in 2017
Container Landscape in 2017Container Landscape in 2017
Container Landscape in 2017Arun Gupta
 
Java EE and NoSQL using JBoss EAP 7 and OpenShift
Java EE and NoSQL using JBoss EAP 7 and OpenShiftJava EE and NoSQL using JBoss EAP 7 and OpenShift
Java EE and NoSQL using JBoss EAP 7 and OpenShiftArun Gupta
 
Docker, Kubernetes, and Mesos recipes for Java developers
Docker, Kubernetes, and Mesos recipes for Java developersDocker, Kubernetes, and Mesos recipes for Java developers
Docker, Kubernetes, and Mesos recipes for Java developersArun Gupta
 
Thanks Managers!
Thanks Managers!Thanks Managers!
Thanks Managers!Arun Gupta
 
Migrate your traditional VM-based Clusters to Containers
Migrate your traditional VM-based Clusters to ContainersMigrate your traditional VM-based Clusters to Containers
Migrate your traditional VM-based Clusters to ContainersArun Gupta
 

More from Arun Gupta (20)

5 Skills To Force Multiply Technical Talents.pdf
5 Skills To Force Multiply Technical Talents.pdf5 Skills To Force Multiply Technical Talents.pdf
5 Skills To Force Multiply Technical Talents.pdf
 
Machine Learning using Kubernetes - AI Conclave 2019
Machine Learning using Kubernetes - AI Conclave 2019Machine Learning using Kubernetes - AI Conclave 2019
Machine Learning using Kubernetes - AI Conclave 2019
 
Machine Learning using Kubeflow and Kubernetes
Machine Learning using Kubeflow and KubernetesMachine Learning using Kubeflow and Kubernetes
Machine Learning using Kubeflow and Kubernetes
 
Secure and Fast microVM for Serverless Computing using Firecracker
Secure and Fast microVM for Serverless Computing using FirecrackerSecure and Fast microVM for Serverless Computing using Firecracker
Secure and Fast microVM for Serverless Computing using Firecracker
 
Building Java in the Open - j.Day at OSCON 2019
Building Java in the Open - j.Day at OSCON 2019Building Java in the Open - j.Day at OSCON 2019
Building Java in the Open - j.Day at OSCON 2019
 
Why Amazon Cares about Open Source
Why Amazon Cares about Open SourceWhy Amazon Cares about Open Source
Why Amazon Cares about Open Source
 
Machine learning using Kubernetes
Machine learning using KubernetesMachine learning using Kubernetes
Machine learning using Kubernetes
 
Building Cloud Native Applications
Building Cloud Native ApplicationsBuilding Cloud Native Applications
Building Cloud Native Applications
 
Chaos Engineering with Kubernetes
Chaos Engineering with KubernetesChaos Engineering with Kubernetes
Chaos Engineering with Kubernetes
 
How to be a mentor to bring more girls to STEAM
How to be a mentor to bring more girls to STEAMHow to be a mentor to bring more girls to STEAM
How to be a mentor to bring more girls to STEAM
 
Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018
 
The Serverless Tidal Wave - SwampUP 2018 Keynote
The Serverless Tidal Wave - SwampUP 2018 KeynoteThe Serverless Tidal Wave - SwampUP 2018 Keynote
The Serverless Tidal Wave - SwampUP 2018 Keynote
 
Introduction to Amazon EKS - KubeCon 2018
Introduction to Amazon EKS - KubeCon 2018Introduction to Amazon EKS - KubeCon 2018
Introduction to Amazon EKS - KubeCon 2018
 
Mastering Kubernetes on AWS - Tel Aviv Summit
Mastering Kubernetes on AWS - Tel Aviv SummitMastering Kubernetes on AWS - Tel Aviv Summit
Mastering Kubernetes on AWS - Tel Aviv Summit
 
Top 10 Technology Trends Changing Developer's Landscape
Top 10 Technology Trends Changing Developer's LandscapeTop 10 Technology Trends Changing Developer's Landscape
Top 10 Technology Trends Changing Developer's Landscape
 
Container Landscape in 2017
Container Landscape in 2017Container Landscape in 2017
Container Landscape in 2017
 
Java EE and NoSQL using JBoss EAP 7 and OpenShift
Java EE and NoSQL using JBoss EAP 7 and OpenShiftJava EE and NoSQL using JBoss EAP 7 and OpenShift
Java EE and NoSQL using JBoss EAP 7 and OpenShift
 
Docker, Kubernetes, and Mesos recipes for Java developers
Docker, Kubernetes, and Mesos recipes for Java developersDocker, Kubernetes, and Mesos recipes for Java developers
Docker, Kubernetes, and Mesos recipes for Java developers
 
Thanks Managers!
Thanks Managers!Thanks Managers!
Thanks Managers!
 
Migrate your traditional VM-based Clusters to Containers
Migrate your traditional VM-based Clusters to ContainersMigrate your traditional VM-based Clusters to Containers
Migrate your traditional VM-based Clusters to Containers
 

Hyperproductive JSF 2.0 @ JavaOne Brazil 2010

  • 1. <Insert Picture Here> Hyperproductive JSF 2.0 Arun Gupta, Java EE & GlassFish Guy blogs.sun.com/arungupta, @arungupta
  • 3. The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 3
  • 6. Facelets • Designed for JSF from beginning • XHTML + CSS – Document validation • Better error handling, including line numbers • Library prefixes as namespaces • EL directly in page: – #{bean.propertyname} • Templating made easy – ui:composition, ui:define, ui:insert – ui:include, ui:repeat 6
  • 7. Facelets – Sample Code <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"> <h:head> <title>Enter Name &amp; Password</title> </h:head> <h:body> <h1>Enter Name &amp; Password</h1> <h:form> <h:panelGrid columns="2"> <h:outputText value="Name:"/> <h:inputText value="#{simplebean.name}" title="name" id="name" required="true"/> <h:outputText value="Password:"/> <h:inputText value="#{simplebean.password}" title="password" id="password" required="true"/> </h:panelGrid> <h:commandButton action="show" value="submit"/> </h:form> </h:body> </html> 7
  • 12. Composite Components • Enable True Abstraction – Create a true, reusable, component from an arbitrary region of a page – Built by composing other components • “Using” and “Defining” page • Full support for using attached objects in the using page – Action methods – Validators, etc 12
  • 13. Composite Components – Sample Code 13
  • 14. Composite Component – Sample Code <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"> <h:head> <title>Enter Name &amp; Password</title> </h:head> <h:body> <h1>Enter Name &amp; Password</h1> <h:form> <h:panelGrid columns="2"> <h:outputText value="Name:"/> <h:inputText value="#{simplebean.name}" title="name" id="name" required="true"/> <h:outputText value="Password:"/> <h:inputText value="#{simplebean.password}" title="password" id="password" required="true"/> </h:panelGrid> <h:commandButton action="show" value="submit"/> </h:form> </h:body> </html> 14
  • 15. Composite Components - Mapping <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:ez="http://java.sun.com/jsf/composite/ezcomp"> <h:head> <title>Enter Name &amp; Password</title> </h:head> <h:body> <h1>Enter Name &amp; Password</h1> <h:form> <ez:username-password/> <h:commandButton action="show" value="submit"/> </h:form> </h:body> </html> . . . WEB-INF index.xhtml resources/ ezcomp/ username-password.xhtml http://blogs.sun.com/arungupta/entry/totd_147_java_server_faces 15
  • 17. Integrated Ajax • Inspiration – ADF, RichFaces, IceFaces, DynamicFaces • Two entry points: – Declarative: <f:ajax> tag, uses AjaxBehavior – Programmatic ajax • resource library javax.faces • resource name jsf.js • JavaScript namespace jsf.ajax. – jsf.ajax.request function 17
  • 18. Integrated Ajax – Sample Code <h:commandButton actionListener="#{sakilabean.findActors}" value="submit"> <f:ajax execute="length" render="actorTable totalActors"/> </h:commandButton> http://blogs.sun.com/arungupta/entry/totd_123_f_ajax_bean 18
  • 20. Partial State Saving • Inspired by Trinidad state saving • Save only the state that's changed since creation of the component tree • Per-view state size up to 4X smaller • Default for pages written with Facelets • All standard components implement this feature – Default for composite components 20
  • 22. View Parameters • Inspired by Page Parameters from Seam • Provides a declarative way to map request parameters to EL-reachable location – <f:viewParam>, <f:metadata> <f:metadata> <f:viewParam name="foo" value="#{bean.foo}"/> </f:metadata> page1.xhtml?foo=bar bean.foo will equal “bar” 22
  • 24. System Events • Inspired by Solaris Dtrace, Linux strace, etc. • Publish/Subscribe event bus for things that happen during the JSF Lifecycle • Adds to event listening abilities – FacesEvent/FacesListener – PhaseEvent/PhaseListener – SystemEvent/SystemEventListener 24
  • 26. System Events – Sample Code <h:inputText> <f:event type="preValidate" listener="#{bean.doSomePreValidation}"/> </h:inputText> <h:inputText value="#{myBean.text}"> <f:event type="beforeRender" listener="#{myBean.beforeTextRender}"/> </h:inputText> 26
  • 27. Resources 27
  • 28. Resources • Standard way to serve image, JavaScripts, CSS, … – No need for separate Servlet or Filter – Logically related to components, treat them that way • @ResourceDependency or @ResourceDependencies on custom components • Built in support for CSS, Image, JavaScript resources • /resources or /META-INF/resources 28
  • 29. Resource EL – Sample Code • #{resource['<resource>']} • #{resource['<library>:<resource>']} • Examples of use – <a href="#{resource['header.jpg']}" /> – <h:graphicImage value="#{resource['corp:header.jpg']}" /> 29
  • 30. Behaviors 30
  • 31. Behaviors • A Behavior is an interface and invents a new type of “attached object” which takes part in decode/encode of a component • 3 new behaviors – ClientBehavior, ClientBehaviorHolder, AjaxBehavior <h:commandLink onclick="return confirm('Really???')"/> <h:commandLink> <foo:confirm message="Really???"/> </h:commandLink> 31
  • 32. Optional “faces-config.xml” • <managed-bean> → @ManagedBean or @Named – Validator, Renderer, Listener, ... • Default navigation rules – match a view on the disk – Conditional navigation @Named(“simplebean”) public class SimpleBean { . . . } <h:commandButton action="show" value="submit"/> 32
  • 33. Lot more features ... • Annotations • Navigation • Exceptions • Validation • EL • Scopes • Project Stage 33
  • 34. Annotations • @ManagedBean • @*Scoped (Session, Request, etc) • @ManagedProperty • @FacesComponent • @FacesConverter • etc. • With implicit Navigation, may eliminate need for faces-config.xml in many cases 34
  • 35. Bookmarkable URLs <h:link outcome="viewEntry" value="Link"> <f:param name="entry" value="#{aBean.entry}"/> </h:link> <a href="http://localhost:8080/myapp/viewEntry.xhtml ?entry=entry1">Link</a> 35
  • 36. EL (Expression Langauge) • #{component}, #{cc} (composite component): get the “currently” processed component / composite component • #{component.clientId} • #{component.messageList} 36
  • 37. Validation • Integration with JSR 303: Bean Validation – @NotEmpty String name; – default validator: javax.faces.Bean – automatically applied to all input fields • Default-validator: hook up a validator for all instances of EditableValueHolder • <f:validateBean>, <f:validateRequired>, <f:validateRegexp> 37
  • 38. Project Stage • Inspired by Rails • Development – Better error reporting, debugging • Production – Better performance 38
  • 39. References • glassfish.org • blogs.sun.com/theaquarium • youtube.com/user/GlassFishVideos • facebook.com/glassfish • Follow @glassfish 39
  • 40. <Insert Picture Here> Hyperproductive JSF 2.0 Arun Gupta, Java EE & GlassFish Guy blogs.sun.com/arungupta, @arungupta