SlideShare a Scribd company logo
1 of 106
Download to read offline
What You Need for Building
Cool Enterprise Applications
with JSF

Max Katz
Exadel
Oct. 4, 2011
>max@exadel.com
Max Katz                     >@maxkatz
                             >mkblog.exadel.com
Senior Systems Engineer
JSF, RichFaces, Java EE consulting,
and training
Developer Relations for Tiggr Mobile
Apps Builder (http://gotiggr.com)
Exadel is a global software
        engineering company

Founded in 1998, headquarters in
    San Francisco Bay Area

7 Development offices in Europe
[Munich, Moscow, Ekaterinburg, Minsk, Homeyl, Kharkov, Donetsk]


               400+ employees
The Plan Is Simple

1) Ajax features in JSF 2

2) The new RichFaces 4 – or
what you need to build cool
enterprise applications with
JSF
JavaServer Faces™ (JSF) is
 the standard component-
 based user interface (UI)
    framework for the
 Java EE (5 & 6) platform
   JSF 1.2     Java EE 5
   JSF 2       Java EE 6
JSF 2 is a major upgrade
       over JSF 1.x

 Many features, ideas taken
from projects such as Seam,
   RichFaces, and others
JSF 2 new features
● Facelets             ● New   scopes
● Composite              ◦ Flash, View,
 components                custom
● Implicit             ● Configuration

 navigation             via annotations
● GET                  ● Bean Validation
        support
                        support
  ◦ h:link, h:button
                       ● Basic Ajax
● Resource   loading
JSF 2 <f:ajax>
● Very   basic Ajax functionality
● Greatly
        inspired by RichFaces 3
 <a4j:support> tag
● Ajax in   JSF in 3 easy steps:
  1. Sending an Ajax request
  2.Partial view processing
  3.Partial view rendering
<h:form>
 <h:form>
   <h:input value="#{bean.word}"/>
    <h:input value="#{bean.word}"/>
   <h:commandButton>
    <h:commandButton>
      <f:ajax event="click" 1
       <f:ajax event="click"
              execute="@form" 2
               execute="@form"
              listener="#{bean.ajaxListener}"
               listener="#{bean.ajaxListener}"
              render="out1 out2"/> 3
               render="out1 out2"/>
   </h:commandButton>
    </h:commandButton>
</h:form>
 </h:form>
<h:form>
 <h:form>
   <h:input value="#{bean.word}"/>
    <h:input value="#{bean.word}"/>
   <h:selectOneMenu value="#{bean.selected}">
    <h:selectOneMenu value="#{bean.selected}">
      <f:selectItems value="#{bean.items}"/>
       <f:selectItems value="#{bean.items}"/>
      <f:ajax event="change" 1
       <f:ajax event="change"
              execute="@form"
               execute="@form"   2
              listener="#{bean.ajaxListener}"
               listener="#{bean.ajaxListener}"
              render="@form"/> 3
               render="@form"/>
   </h:commandButton>
    </h:commandButton>
</h:form>
 </h:form>
Attribute   Value
Important
                         Event on which to fire the
<f:ajax>     event
                         Ajax request
attributes               @all
                         @this (default)
                         @form
             execute
                         @none
                         id's
                         EL
                         @all
                         @this
                         @form
             render
                         @none (default)
                         id's
                         EL
That's good, but that's all you get.

Where do you get rich components
           and more?

 A rich component framework is
still(?) needed to build real-world
          Ajax applications.
RichFaces 4 is a lightweight,
open source framework for
          JSF 2
RichFaces 4 – rich JSF framework
UI components
 a4j:* tag library (core)
 rich:* tag library (UI)
Components' JavaScript API
Skins
Client-side validation (Bean Validation
based)
CDK – Component Development Kit
100% built on top of JSF2,
just extends functionality in
           JSF 2
JavaScript is now entirely
based on the popular jQuery
          library
RichFaces 4 is a lot faster, consistent,
and optimized

  All components are reviewed for consistency,
  usability
  Redesigned following semantic HTML
  principles
  Server-side and client-side performance
  optimization
  Strict code clean-up and review
New client-side validation
based on Bean Validation
        (JSR 303)

Quickly and easily validate
   input on the client
New, and easy to use CDK
   (Component Development Kit),
 allows quickly to build your
own custom rich components
Pick your server:
Tomcat 6/7, Resin, JBoss AS 6/7,
   GlassFish 3.x, WebLogic
[any server where JSF 2 application can be deployed]
Deploy and run in the cloud:
Google App Engine Amazon
EC2, CloudBees, OpenShift
Pick JSF implementations
        you like:
   Mojarra or MyFaces
Run in any browser
Pick your favorite tooling:
  JBoss Tools, IntelliJ,
        NetBeans
Easy to start. Zero-configuration,
  just drop RichFaces into the
           application
RichFaces versions


       Version             JSF 1.1       JSF 1.2   JSF 2


RichFaces 3.1.x              •
RichFaces 3.3.3*                            •       •
RichFaces 4                                         •
* Note: RichFaces 3.3.3 has basic JSF 2 support
RichFaces history
2005: started by Alexander Smirnov
2005-2007: Developed by Exadel
           Ajax4jsf - open source, free
           RichFaces - commercial
2007: JBoss takes over
      Exadel team continues to develop
      the framework, project is known as
      RichFaces
Let's see what cool
components, and features
 you get with RichFaces...
RichFaces <a4j:ajax>
       ● 100% based on     standard <f:ajax>
       ● Just replace f: with a4j: and get
         exactly the same functionality
       ● But,   you get extra features...
<h:commandButton>
 <h:commandButton>
   <f:ajax execute="@form" render="output"/>
    <f:ajax execute="@form" render="output"/>
</h:commandButton>
 </h:commandButton>

<h:commandButton>
 <h:commandButton>
   <a4j:ajax execute="@form" render="output"/>
    <a4j:ajax execute="@form" render="output"/>
</h:commandButton>
 </h:commandButton>
<a4j:ajax> attributes
Feature/Attribute                  Description

                    JavaScript to execute before Ajax
onbegin
                    request
                    JavaScript to execute after response
onbeforedomupdate
                    comes back but before DOM update

oncomplete          JavaScript to execute after DOM update

                    Allows to skip JSF phases when
bypassUpdates
                    validating

limitRender         Turns off all auto-rendered panels

status              Status to display during Ajax request

Ajax queue          Advanced RichFaces client queue
Components to send Ajax
request
● <a4j:ajax>
● <a4j:commandButton>
● <a4j:commandLink>
● <a4j:jsFunction>
● <a4j:poll>
● <a4j:push>
<a4j:commandButton/Link> –
button and link with built-in Ajax
behavior
<a4j:commandButton value="Save"
 <a4j:commandButton value="Save"
   action="#{bean.action}"
    action="#{bean.action}"
   render="output" />
    render="output" />



<a4j:commandLink value="Save"
 <a4j:commandLink value="Save"
   action="#{bean.action}"
    action="#{bean.action}"
   render="output" />
    render="output" />
When using standard JSF button:
<h:form>
 <h:form>
   <h:inputText>
    <h:inputText>
   <h:selectOneMenu>
                                   Need to set
    <h:selectOneMenu>
   <h:commandButton>
    <h:commandButton>              execute=”@form”
      <f:ajax execute="@form"/>
       <f:ajax execute="@form"/>   (or execute=”id1 id2”)
   </h:commandButton>
    </h:commandButton>
<h:form>
 <h:form>

When using RichFaces button:
<h:form>
 <h:form>                          RichFaces default
   <h:inputText>
    <h:inputText>
   <h:selectOneMenu>
                                   value for
    <h:selectOneMenu>
   <a4j:commandButton/>
    <a4j:commandButton/>
                                   button/link
<h:form>
 <h:form>                          execute=”@form”
<a4j:jsFunction> – fire Ajax request
from any JavaScript function, HTML
event
<table>
 <table>
   ...
    ...
   <td onmouseover="update('yellow')"/>
    <td onmouseover="update('yellow')"/>
   ...
    ...
</table>
 </table>

<h:form>
 <h:form>
 <a4j:jsFunction name="update"
  <a4j:jsFunction name="update"
      action="#{bean.change}" render="...">
       action="#{bean.change}" render="...">
   <a4j:param value="param1" assignTo="#{bean.color}"/>
    <a4j:param value="param1" assignTo="#{bean.color}"/>
 </a4j:jsFunction>
  </a4j:jsFunction>
</h:form>
 </h:form>
If you had to pick just one Ajax
control, you would want
<a4j:jsFunction>
<h:commandButton action="#{bean.change}">
 <h:commandButton action="#{bean.change}">
   <a4j:ajax render="id"/>
    <a4j:ajax render="id"/>
</h:commandButton>
 </h:commandButton>


Is the same as:

 <h:commandButton onclick="sendAjax();"/>
  <h:commandButton onclick="sendAjax();"/>

 <a4j:jsFunction name="sendAjax"
  <a4j:jsFunction name="sendAjax"
       action="#{bean.change}" render="id"/>
        action="#{bean.change}" render="id"/>
<a4j:poll> – periodically send an
Ajax request

<a4j:poll interval="1000"
 <a4j:poll interval="1000"
          action="#{bean.count}"
           action="#{bean.count}"
          render="output"
           render="output"
          enabled="#{bean.pollEnabled}" />
           enabled="#{bean.pollEnabled}" />

<h:panelGrid id="output">
 <h:panelGrid id="output">
...
 ...
</h:panelGrid>
 </h:panelGrid>
<a4j:push>
       ● Server-side  events are pushed to
         client using Comet or WebSockets.
       ● Implemented    using Atmosphere
       ● Providesexcellent integration with
         EE containers, and advanced
         messaging services

<a4j:push address="topic@chat"
 <a4j:push address="topic@chat"
     ondataavailable="alert(event.rf.data)" />
      ondataavailable="alert(event.rf.data)" />
Advanced rendering features
● <a4j:outputPanel>
● limitRender   attribute
● render=”{bean.renderList}”
<a4j:outputPanel> – auto rendered
panel
<a4j:commandButton value="Save" action="#{bean.save}">
 <a4j:commandButton value="Save" action="#{bean.save}">
<a4j:commandButton value="Edit" action="#{bean.edit}">
 <a4j:commandButton value="Edit" action="#{bean.edit}">

<a4j:outputPanel ajaxRendered="true">
 <a4j:outputPanel ajaxRendered="true">
   <h:panelGrid>
    <h:panelGrid>
      ...
       ...
   </h:panelGrid>
    </h:panelGrid>
</a4j:outputPanel>
 </a4j:outputPanel>

<a4j:outputPanel ajaxRendered="true">
 <a4j:outputPanel ajaxRendered="true">
   <rich:dataTable>
    <rich:dataTable>
      ...
       ...
   </rich:dataTable>
    </rich:dataTable>
</a4j:outputPanel>
 </a4j:outputPanel>
Turning off auto rendered panels
<a4j:commandButton value="Save" action="#{bean.save}">
 <a4j:commandButton value="Save" action="#{bean.save}">
<a4j:commandButton value="Edit" action="#{bean.edit}"
 <a4j:commandButton value="Edit" action="#{bean.edit}"
     render="edit" limitRender="true">
      render="edit" limitRender="true">

<a4j:outputPanel ajaxRendered="true">
 <a4j:outputPanel ajaxRendered="true">
   <h:panelGrid>
    <h:panelGrid>
      ...
       ...
   </h:panelGrid>
    </h:panelGrid>
</a4j:outputPanel>
 </a4j:outputPanel>
<h:panelGrid id="edit">
 <h:panelGrid id="edit">
   <rich:dataTable>
    <rich:dataTable>
      ...
       ...
   </rich:dataTable>
    </rich:dataTable>
</h:panelGrid>
 </h:panelGrid>
render=”#{bean.renderList}”
JSF                            RichFaces
1) Ajax request sent           1) Ajax request sent
2) Component id's to be        2) Component id's to
  rendered resolved              be rendered
3) Component id's are            resolved
  rendered into the page       3) Component id's
4) 2nd Ajax request is sent.     are rendered
  In this request the
  components (resolved in
  step 2 are sent with
  request) will be rendered
Advanced execute features
● <a4j:region>
● bypassUpdates   attribute
<a4j:region> – defining execute
region declaratively

<h:form>
 <h:form>
   <a4j:region>
    <a4j:region>
      <h:inputText />
       <h:inputText />
      <h:inputText />
       <h:inputText />
      <h:selectOneMenu />
       <h:selectOneMenu />
      <a4j:commandButton />
       <a4j:commandButton />
   <a4j:region>
    <a4j:region>
</h:form>
 </h:form>
Skipping
phases
when
validating
1.Restore View
2.Apply Request Values
3.Process Validation
4.Update Model
5.Invoke Application
6.Render Response


 <h:inputText id="name" value="#{bean.name}"/>
  <h:inputText id="name" value="#{bean.name}"/>
    <a4j:ajax event="blur" bypassUpdates="true"/>
     <a4j:ajax event="blur" bypassUpdates="true"/>
 </h:inputText>
  </h:inputText>
 <rich:message for="name"/>
  <rich:message for="name"/>
Even more advanced features
and tags
● JavaScript   callbacks
● Queue
● <a4j:status>
● <a4j:param>
● <a4j:log>
Easily use JavaScript callbacks
during Ajax request
<a4j:commandLink value="Link"
 <a4j:commandLink value="Link"
   onbegin="ajaxOnBegin()"
    onbegin="ajaxOnBegin()"
   onbeforedomupdate="ajaxOnBeforeDomUpdate()"
    onbeforedomupdate="ajaxOnBeforeDomUpdate()"
   oncomplete="ajaxOnComplete()">
    oncomplete="ajaxOnComplete()">
</a4j:commandLink>
 </a4j:commandLink>
JSF 2 queue
● JSF2 has very basic queue
 functionality
● Events   are queued and fired one at a
 time
● Only one request is processed on the
 server at a time
<a4j:queue> – “combining” events
from the same component

  While a request is executing
  on the server, all requests
  from button A or button
  B will be combined
  (merged) if the last event in
  the queue is of the same
  type.


<a4j:queue />
 <a4j:queue />
...
 ...
<a4j:commandButton id="buttonA" value="Button A"/>
 <a4j:commandButton id="buttonA" value="Button A"/>
<a4j:commandButton id="buttonB" value="Button B"/>
 <a4j:commandButton id="buttonB" value="Button B"/>
<a4j:queue> – “combining” events
from different components

  While a request is executing
  on the server, all requests
  from button A or button
  B will be combined
  (merged).

<a4j:queue />
 <a4j:queue />
<a4j:commandButton id="buttonA" value="Button A">
 <a4j:commandButton id="buttonA" value="Button A">
  <a4j:attachdQueue requestGroupingId="ajaxGroup"/>
   <a4j:attachdQueue requestGroupingId="ajaxGroup"/>
</a4j:commandButton>
 </a4j:commandButton>
<a4j:commandButton id="buttonB" value="Button B">
 <a4j:commandButton id="buttonB" value="Button B">
   <a4j:attachdQueue requestGroupingId="ajaxGroup"/>
    <a4j:attachdQueue requestGroupingId="ajaxGroup"/>
</a4j:commandButton>
 </a4j:commandButton>
<a4j:queue> – setting request delay
allows “waiting” for requests from
same component in order to merge
events
<a4j:queue requestDelay="1000"/>
 <a4j:queue requestDelay="1000"/>

<a4j:commandButton id="buttonA" value="Button A">
 <a4j:commandButton id="buttonA" value="Button A">
   <a4j:attachdQueue requestDelay="2000"/>
    <a4j:attachdQueue requestDelay="2000"/>
</a4j:commandButton>
 </a4j:commandButton>

<a4j:commandButton id="buttonB" value="Button B"/>
 <a4j:commandButton id="buttonB" value="Button B"/>
<a4j:queue> – ignoring “stale”
responses
<a4j:queue requestDelay="2000
 <a4j:queue requestDelay="2000
           ingoreDupResponses="true"/>
            ingoreDupResponses="true"/>

<h:inputText value="#{bean.state}">
 <h:inputText value="#{bean.state}">
 <a4j:ajax event="keyup" listener="#{bean.load}"
  <a4j:ajax event="keyup" listener="#{bean.load}"
           render="states"/>
            render="states"/>
</h:inputText>
 </h:inputText>
<a4j:status> – Ajax request
      status



<a4j:status name="ajaxStatus">
 <a4j:status name="ajaxStatus">
  <f:facet name="start">
   <f:facet name="start">
    <h:graphicImage value="ajaxStatus.jpg"/>
     <h:graphicImage value="ajaxStatus.jpg"/>
  </f:facet>
   </f:facet>
</a4j:status>
 </a4j:status>

<h:form>
 <h:form>
   <a4j:commandButton status="ajaxStatus"/>
    <a4j:commandButton status="ajaxStatus"/>
</h:form>
 </h:form>
<a4j:param> - like <f:param>, but
simpler as it also assigns the value to
a bean property automatically

<a4j:commandButton value="Save">
 <a4j:commandButton value="Save">
   <a4j:param value="1009" assignTo="#{bean.product}"/>
    <a4j:param value="1009" assignTo="#{bean.product}"/>
</a4j:commandButton>
 </a4j:commandButton>

public class Bean {
 public class Bean {
   private String product;
    private String product;
   public void setProduct (String product) {...}
    public void setProduct (String product) {...}
}}
Another great feature is that
<a4j:param> value can contain any
JavaScript expression or JavaScript
function, when noEscape="true"

<a4j:param name="width"
 <a4j:param name="width"
   value="(jQuery(window).width()/2)"
    value="(jQuery(window).width()/2)"
   assignTo="#{bean.screenWidth}"
    assignTo="#{bean.screenWidth}"
   noEscape="true" />
    noEscape="true" />
<a4j:log> – Ajax request/response
information, logging
RichFaces UI components
● Output, panels
● Input
● Menu
● Data iteration
● Tree
● Drag   and drop
● Client   side validation
● Miscellaneous
rich:tab




rich:accordion




rich:progressBar
More rich output, panels
● rich:panel
● rich:togglePanel
● rich:popupPanel
● rich:collapsiblePanel
● rich:toolTip
<rich:popupPanel> can be modal and
non-modal

<rich:popupPanel modal="false">
  <f:facet name="header">
      Edit User
  </f:facet>
  ...
  ...
</rich:popupPanel>
rich:calendar




rich:inplaceInput


rich:inputNumberSlider


rich:autocomplete
More rich input
● rich:inputNumberSpinner
● rich:inplaceSelect
● rich:select
● rich:fileUpload
rich:panelMenu




rich:toolBar


rich:dropDownMenu
rich:dataTable




rich:dataTable with
rich:collapsibleSubTable



rich:dataScroller
RichFaces data iteration components
support partial updates
                    render="@column"
                                                         render="@header"


                                                          render="@body"



                                                         render="@footer"

                                       render="cellId"
To render from outside the table:
render="tableId@header"
render="tableId@body"
render="tableId@footer"
Deciding what rows/cell to update in
 run-time
render="tableId:rows(bean.rowsSet)"




render="tableId:rows(bean.rowsSet):cellId"
New collapsible sub table component
<rich:dataTable> supports column
and row spanning
<rich:extendedDataTable> provides
lazy loading, column resizing, reorder
and more
More rich data iteration
● a4j:repeat
● rich:extendedDataTable
● rich:collapsibleSubTable
● rich:list

  ◦ list | ordered | definition
● rich:dataGrid
● rich:column

  ◦ Column and row spanning
  ◦ Filtering, sorting
rich:tree
Drag and drop
Many RichFaces components
provide client-side JavaScript API
<rich:popupPanel> JavaScript API
Method name            Description
                       Return the top co-ordinate for the position of
getTop()
                       the pop-up panel.
                       Return the left co-ordinate for the position of
getLeft()
                       the pop-up panel.
                       Move the pop-up panel to the co-ordinates
moveTo(top,left)
                       specified with the top and left parameters.
                       Resize the pop-up panel to the size specified
resize(width,height)
                       with the width and height parameters.
show()                 Show the pop-up panel.
hide()                 Hide the pop-up panel.
Invoking component JavaScript API
using #{rich:component(id)}
function

<input type="button"
 <input type="button"
       onclick="#{rich:component('popup')}.show();"
        onclick="#{rich:component('popup')}.show();"
       value="Open" />
        value="Open" />

<rich:popupPanel id="popup">
 <rich:popupPanel id="popup">
   <h:outputLink value="#"
    <h:outputLink value="#"
        onclick="#{rich:component('popup')}.hide();
         onclick="#{rich:component('popup')}.hide();
           return false;">
            return false;">
          <h:outputText value="Close"/>
           <h:outputText value="Close"/>
    </h:outputLink>
     </h:outputLink>
</rich:popupPanel>
 </rich:popupPanel>
Invoking component JavaScript API
using <rich:componentControl>
component
<h:outputLink value="#">
 <h:outputLink value="#">
   <h:outputText value="Open" />
    <h:outputText value="Open" />
   <rich:componentControl event="click"
    <rich:componentControl event="click"
         target="popup" operation="show" />
          target="popup" operation="show" />
</h:outputLink>
 </h:outputLink>

<rich:popupPanel header="RichFaces" id="popup">
 <rich:popupPanel header="RichFaces" id="popup">
   <h:outputLink value="#">
    <h:outputLink value="#">
      <h:outputText value="Close" />
       <h:outputText value="Close" />
         <rich:componentControl event="click"
          <rich:componentControl event="click"
               target="popup" operation="hide" />
                target="popup" operation="hide" />
   </h:outputLink>
    </h:outputLink>
</rich:popupPanel>
 </rich:popupPanel>
<rich:accordion id="c">
 <rich:accordion id="c">
 <rich:accordionItem header="New York" name="nyc">
  <rich:accordionItem header="New York" name="nyc">
   <h:outputText value="You selected New York"/>
    <h:outputText value="You selected New York"/>
 </rich:accordionItem>
  </rich:accordionItem>
 <rich:accordionItem header="San Francisco" name="sf">
  <rich:accordionItem header="San Francisco" name="sf">
   <h:outputText value="You selected San Francisco"/>
    <h:outputText value="You selected San Francisco"/>
 </rich:accordionItem>
  </rich:accordionItem>
 ...
  ...
</rich:accordion>
 </rich:accordion>
<input type="button" value="New York City"
 <input type="button" value="New York City"
  onclick="#{rich:component('c')}.switchToItem('nyc')"/>
   onclick="#{rich:component('c')}.switchToItem('nyc')"/>
<input type="button" value="San Francisco"
 <input type="button" value="San Francisco"
   onclick="#{rich:component('c')}.switchToItem('sf')"/>
    onclick="#{rich:component('c')}.switchToItem('sf')"/>
<input type="button" value="Los Angeles"
 <input type="button" value="Los Angeles"
  onclick="#{rich:component('c')}.switchToItem('la')"/>
   onclick="#{rich:component('c')}.switchToItem('la')"/>



<input type="button" value="First"
 <input type="button" value="First"
   onclick="#{rich:component('c')}.switchToItem('@first')"/>
    onclick="#{rich:component('c')}.switchToItem('@first')"/>
<input type="button" value="Next"
 <input type="button" value="Next"
   onclick="#{rich:component('c')}.switchToItem('@next')"/>
    onclick="#{rich:component('c')}.switchToItem('@next')"/>
<input type="button" value="Previous"
 <input type="button" value="Previous"
  onclick="#{rich:component('c')}.switchToItem('@prev')"/>
   onclick="#{rich:component('c')}.switchToItem('@prev')"/>
<input type="button" value="Last"
 <input type="button" value="Last"
  onclick="#{rich:component('c')}.switchToItem('@last')"/>
   onclick="#{rich:component('c')}.switchToItem('@last')"/>
RichFaces client functions
         Function                        Description

rich:client(id)           Returns component client id
rich:element(id)          Returns DOM element
                          Returns RichFaces client component
rich:component(id)
                          instance to call JS API method
rich:isUserInRole(role)   Returns if the user has specified role
                          Returns component instance for given
rich:findComponent(id)
                          short id
Standard Java EE security with
#{rich:isUserInRole(role)} function
<rich:panel header="Admin panel"
 <rich:panel header="Admin panel"
   rendered="#{rich:isUserInRole('admin')}">
    rendered="#{rich:isUserInRole('admin')}">
  Very sensitive information
   Very sensitive information
</rich:panel>
 </rich:panel>

 <rich:panel header="User panel">
  <rich:panel header="User panel">
   General information
    General information
</rich:panel>
 </rich:panel>

●   Calls facesContext.getExternalContext.getUserInRole(role)
●   What's good is that security roles can be defined anywhere
Client-side validation based
    on Bean Validation
         (JSR 303)

    New in RichFaces 4
Bean Validation (JSR 303)
JSF 2 has support for Bean Validation
(validation done on server)
Bean:
public class Bean {
 public class Bean {
   @Pattern(regexp="...")
    @Pattern(regexp="...")
   private String email;
    private String email;
}}

JSF page:
<h:inputText id="email" value="#{bean.email}">
 <h:inputText id="email" value="#{bean.email}">
    <a4j:ajax event="blur"/>
     <a4j:ajax event="blur"/>
</h:inputText>
 </h:inputText>
<rich:message for="email"/>
 <rich:message for="email"/>
Client-Validation Based on Bean
Validation
Validation is performed on the client. If no client
implementation available, validation automatically falls
back to standard, server validation
Bean:
public class Bean {
 public class Bean {
   @Pattern(regexp="...")
    @Pattern(regexp="...")
   private String email;
    private String email;
}}

JSF page:
<h:inputText id="email" value="#{bean.email}">
 <h:inputText id="email" value="#{bean.email}">
    <rich:validator />
     <rich:validator />
</h:inputText>
 </h:inputText>
<rich:message for="email"/>
 <rich:message for="email"/>
Object validation with
<rich:graphValidator>
@Size(min=5,max=15)
 @Size(min=5,max=15)
private String password1;
 private String password1;
@Size(min=5,max=15)
 @Size(min=5,max=15)
private String password2;
 private String password2;

@AssertTrue(message="Passwords don't match")
 @AssertTrue(message="Passwords don't match")
public boolean checkPassword() {
 public boolean checkPassword() {
   return password1.equals(password1);
    return password1.equals(password1);
}}

<rich:graphValidator value="#{bean}" id="crossField">
 <rich:graphValidator value="#{bean}" id="crossField">
   <h:inputText value="#{bean.password1}"/>
    <h:inputText value="#{bean.password1}"/>
   <h:inputText value="#{bean.password2}"/>
    <h:inputText value="#{bean.password2}"/>
   <rich:message for="email" for="crossField"/>
    <rich:message for="email" for="crossField"/>
</rich:graphValidator>
 </rich:graphValidator>
Rich miscellaneous
● <rich:componentControl>
● <rich:hashParam>
● <rich:jQuery>
<rich:componentControl>
       ● Allows  to call JS API on a component
         in declarative fashion
<h:outputLink id="openLink" value="#">
 <h:outputLink id="openLink" value="#">
   <h:outputText value="Open" />
    <h:outputText value="Open" />
   <rich:componentControl event="click"
    <rich:componentControl event="click"
                           operation="show"
                            operation="show"
                           target="popup" />
                            target="popup" />
</h:outputLink>
 </h:outputLink>

<rich:popupPanel id="popup">
 <rich:popupPanel id="popup">
...
 ...
</rich:popupPanel>
 </rich:popupPanel>
<rich:hashParam> - creates
JavaScript hash, can be passed to
another client function.

<h:commandButton value="Show popup">
 <h:commandButton value="Show popup">
   <rich:componentControl target="pp" operation="show">
    <rich:componentControl target="pp" operation="show">
      <rich:hashParam>
       <rich:hashParam>
         <f:param name="width" value="500" />
          <f:param name="width" value="500" />
         <f:param name="height" value="300" />
          <f:param name="height" value="300" />
         <f:param name="minWidth" value="300" />
          <f:param name="minWidth" value="300" />
         <f:param name="minHeight" value="150" />
          <f:param name="minHeight" value="150" />
      </rich:hashParam>
       </rich:hashParam>
   </rich:componentControl>
    </rich:componentControl>
</h:commandButton
 </h:commandButton
Using jQuery with <rich:jQuery>



<input type="button" id=" value="Update panel"/>
 <input type="button" id=" value="Update panel"/>
<rich:jQuery selector="#changeButton" event="click"
 <rich:jQuery selector="#changeButton" event="click"
 query="$('#nycInfo .rf-p-hdr').text('New York City');
  query="$('#nycInfo .rf-p-hdr').text('New York City');
        $('.rf-p-b').css('color', 'blue');" />
         $('.rf-p-b').css('color', 'blue');" />
Using jQuery when page rendered to
create zebra-like styling for table
<style>
 <style>
   .even-row {
    .even-row {
      background-color: #FCFFFE;
       background-color: #FCFFFE;
   }}
   .odd-row {
    .odd-row {
      background-color: #ECF3FE;
       background-color: #ECF3FE;
   }}
</style>
 </style>

<rich:dataTable id="gamesTable">
 <rich:dataTable id="gamesTable">
   // columns
    // columns
</rich:dataTable>
 </rich:dataTable>

<rich:jQuery selector="#gamesTable tr:odd"
 <rich:jQuery selector="#gamesTable tr:odd"
   query="addClass('odd-row')" />
    query="addClass('odd-row')" />
<rich:jQuery selector="#gamesTable tr:even"
 <rich:jQuery selector="#gamesTable tr:even"
   query="addClass('even-row')" />
    query="addClass('even-row')" />
Invoking <rich:jQuery> as a regular
JavaScript function
             with mouse over




<h:graphicImage width="100" value="/images/venice.png"
 <h:graphicImage width="100" value="/images/venice.png"
   onmouseover="larger(this, {})"
    onmouseover="larger(this, {})"
   onmouseout="normal(this, {})" />
    onmouseout="normal(this, {})" />

<rich:jQuery name="larger"
 <rich:jQuery name="larger"
   query="animate({width:'241px'})" />
    query="animate({width:'241px'})" />
<rich:jQuery name="normal"
 <rich:jQuery name="normal"
   query="animate({width:'100px'})"/>
    query="animate({width:'100px'})"/>
Skins
Skins
● Lightweight   extension on top of CSS
● Change
       look and feel of all rich
 component with a few minor changes
● Can
    be applied to standard JSF and
 HTML tags as well
Ready-to-use skins
● classic
● wine
● blueSky
● ruby
● emeraldTown
● deepMarine
                <context-param>
● plain          <context-param>
                  <param-name>org.richfaces.skin</param-name>
                   <param-name>org.richfaces.skin</param-name>
                  <param-value>ruby</param-value>
● japanCherry      <param-value>ruby</param-value>
                </context-param>
                 </context-param>
RichFaces Skin file
#Colors
 #Colors
headerBackgroundColor=#900000
 headerBackgroundColor=#900000
headerGradientColor=#DF5858
 headerGradientColor=#DF5858
headerTextColor=#FFFFFF
 headerTextColor=#FFFFFF
headerWeightFont=bold
 headerWeightFont=bold

generalBackgroundColor=#f1f1f1
 generalBackgroundColor=#f1f1f1
generalTextColor=#000000
 generalTextColor=#000000
generalSizeFont=11px
 generalSizeFont=11px
generalFamilyFont=Arial, Verdana, sans-serif
 generalFamilyFont=Arial, Verdana, sans-serif

controlTextColor=#000000
 controlTextColor=#000000
controlBackgroundColor=#ffffff
 controlBackgroundColor=#ffffff
additionalBackgroundColor=#F9E4E4
 additionalBackgroundColor=#F9E4E4
Skins
● Modify   existing or create your own
  <context-param>
   <context-param>
    <param-name>org.richfaces.skin</param-name>
     <param-name>org.richfaces.skin</param-name>
    <param-value>myCoolSkin</param-value>
     <param-value>myCoolSkin</param-value>
  </context-param>
   </context-param>

● Change   skins in runtime
  <context-param>
   <context-param>
    <param-name>org.richfaces.skin</param-name>
     <param-name>org.richfaces.skin</param-name>
    <param-value>#{bean.skin}</param-value>
     <param-value>#{bean.skin}</param-value>
  </context-param>
   </context-param>
Overwriting Skin CSS
<style>
 <style>
.rf-p-hdr {
 .rf-p-hdr {
   color: …
    color: …
   font-size: …
    font-size: …
   font-weight: …
    font-weight: …
   font-family: …
    font-family: …
}}
</style>
 </style>
<rich:panel>...</rich:panel>
 <rich:panel>...</rich:panel>
Overwriting Skin CSS
<style>
 <style>
.rf-p-hdr {
 .rf-p-hdr {
    // overwrite skin CSS properties
     // overwrite skin CSS properties
}}
.specialHeader {
 .specialHeader {
   // define custom CSS for specific panel
    // define custom CSS for specific panel
}}
</style>
 </style>

<rich:panel id="panel1">
 <rich:panel id="panel1">
...
 ...
<rich:panel>
 <rich:panel>
<rich:panel id="panel2" headerClass="specialHeader">
 <rich:panel id="panel2" headerClass="specialHeader">
...
 ...
<rich:panel>
 <rich:panel>
Skinning standard JSF tags and
HTML tags

Apply to each control:
<h:button style="background-color:
 <h:button style="background-color:
               '#{richSkin.tableBackgroundColor}'"/>
                '#{richSkin.tableBackgroundColor}'"/>
Skinning standard JSF tags and
HTML tags automatically

Apply to all standard controls (JSF and HTML):
<context-param>
 <context-param>
   <param-name>
    <param-name>
      org.richfaces.enableControlSkinning
       org.richfaces.enableControlSkinning
   </param-name>
    </param-name>
   <param-value>true</param-value>
    <param-value>true</param-value>
</context-param>
 </context-param>
Skinning standard JSF tags and
HTML tags only when special CSS
class is applied to parent container
<context-param>
 <context-param>
   <param-name>
    <param-name>
      org.richfaces.enableControlSkinningClasses
       org.richfaces.enableControlSkinningClasses
   </param-name>
    </param-name>
   <param-value>true</param-value>
    <param-value>true</param-value>
</context-param>
 </context-param>


<div class="rfs-ctn">
 <div class="rfs-ctn">
   <h:outputText />
    <h:outputText />
   <h:inputText />
    <h:inputText />
   <h:commandButton />
    <h:commandButton />
</div>
 </div>
Where can I try the new
       RichFaces 4?
http://richfaces.org/showcase
RichFaces 4.1 (Late 2011)

Mobile support

New components:
 Pick list
 Ordering list
 Rich text editor
How can we help with RichFaces
● Web development
 with RichFaces
                                     Training      Days
● Version   3 to 4 migration   JSF 1.2, 2          1-2
● Performance    tune-up       RichFaces 3, 4      1-2
                               JSF and RichFaces   2-3
● Custom    component          RichFaces 3 to 4    1-2

 development
● On-site training
RichFaces
Rich, flexible, robust, and
proven enterprise-level
framework to JSF 2
Tiggr is a Web-based mobile apps builder.
Super fast, and easy to build mobile Web and
                 native apps
Build your mobile app at http://gotiggr.com
Export or build the app as mobile Web or
 generate native app (for Android, iOS)
Thank you!
How to get in touch with me:
>max@exadel.com
>@maxkatz
>mkblog.exadel.com

Build your mobile app in the
cloud: http://gotiggr.com

More Related Content

What's hot

Ajax Applications with JSF2 and New RichFaces 4 at JAX 2011
Ajax Applications with JSF2 and New RichFaces 4 at JAX 2011Ajax Applications with JSF2 and New RichFaces 4 at JAX 2011
Ajax Applications with JSF2 and New RichFaces 4 at JAX 2011Max Katz
 
A Complete Tour of JSF 2
A Complete Tour of JSF 2A Complete Tour of JSF 2
A Complete Tour of JSF 2Jim Driscoll
 
Introduction to JSF
Introduction toJSFIntroduction toJSF
Introduction to JSFSoftServe
 
JSF Component Behaviors
JSF Component BehaviorsJSF Component Behaviors
JSF Component BehaviorsAndy Schwartz
 
JSF basics
JSF basicsJSF basics
JSF basicsairbo
 
Spring MVC
Spring MVCSpring MVC
Spring MVCyuvalb
 
Spring as a Cloud Platform (Developer Summit 2011 17-C-5)
Spring as a Cloud Platform (Developer Summit 2011 17-C-5)Spring as a Cloud Platform (Developer Summit 2011 17-C-5)
Spring as a Cloud Platform (Developer Summit 2011 17-C-5)Kazuyuki Kawamura
 
25+ Reasons to use OmniFaces in JSF applications
25+ Reasons to use OmniFaces in JSF applications25+ Reasons to use OmniFaces in JSF applications
25+ Reasons to use OmniFaces in JSF applicationsAnghel Leonard
 
Mastering OmniFaces - A Problem to Solution Approach
Mastering OmniFaces - A Problem to Solution ApproachMastering OmniFaces - A Problem to Solution Approach
Mastering OmniFaces - A Problem to Solution ApproachAnghel Leonard
 
Lecture 10 - Java Server Faces (JSF)
Lecture 10 - Java Server Faces (JSF)Lecture 10 - Java Server Faces (JSF)
Lecture 10 - Java Server Faces (JSF)Fahad Golra
 
Using the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service ClientsUsing the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service ClientsSalesforce Developers
 
Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6Arun Gupta
 

What's hot (20)

Ajax Applications with JSF2 and New RichFaces 4 at JAX 2011
Ajax Applications with JSF2 and New RichFaces 4 at JAX 2011Ajax Applications with JSF2 and New RichFaces 4 at JAX 2011
Ajax Applications with JSF2 and New RichFaces 4 at JAX 2011
 
A Complete Tour of JSF 2
A Complete Tour of JSF 2A Complete Tour of JSF 2
A Complete Tour of JSF 2
 
Jsf
JsfJsf
Jsf
 
Introduction to JSF
Introduction toJSFIntroduction toJSF
Introduction to JSF
 
JSF Component Behaviors
JSF Component BehaviorsJSF Component Behaviors
JSF Component Behaviors
 
Introduction to jsf 2
Introduction to jsf 2Introduction to jsf 2
Introduction to jsf 2
 
Jsf intro
Jsf introJsf intro
Jsf intro
 
Jsf presentation
Jsf presentationJsf presentation
Jsf presentation
 
JSF basics
JSF basicsJSF basics
JSF basics
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Spring as a Cloud Platform (Developer Summit 2011 17-C-5)
Spring as a Cloud Platform (Developer Summit 2011 17-C-5)Spring as a Cloud Platform (Developer Summit 2011 17-C-5)
Spring as a Cloud Platform (Developer Summit 2011 17-C-5)
 
25+ Reasons to use OmniFaces in JSF applications
25+ Reasons to use OmniFaces in JSF applications25+ Reasons to use OmniFaces in JSF applications
25+ Reasons to use OmniFaces in JSF applications
 
Mastering OmniFaces - A Problem to Solution Approach
Mastering OmniFaces - A Problem to Solution ApproachMastering OmniFaces - A Problem to Solution Approach
Mastering OmniFaces - A Problem to Solution Approach
 
Lecture 10 - Java Server Faces (JSF)
Lecture 10 - Java Server Faces (JSF)Lecture 10 - Java Server Faces (JSF)
Lecture 10 - Java Server Faces (JSF)
 
Java server faces
Java server facesJava server faces
Java server faces
 
OmniFaces validators
OmniFaces validatorsOmniFaces validators
OmniFaces validators
 
DataFX - JavaOne 2013
DataFX - JavaOne 2013DataFX - JavaOne 2013
DataFX - JavaOne 2013
 
Using the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service ClientsUsing the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service Clients
 
Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6
 
The JavaFX Ecosystem
The JavaFX EcosystemThe JavaFX Ecosystem
The JavaFX Ecosystem
 

Similar to Build Cool Apps with JSF and RichFaces

RichFaces: rich:* component library
RichFaces: rich:* component libraryRichFaces: rich:* component library
RichFaces: rich:* component libraryMax Katz
 
Hands On With Rich Faces 4 - JavaOne 2010
Hands On With Rich Faces 4 - JavaOne 2010Hands On With Rich Faces 4 - JavaOne 2010
Hands On With Rich Faces 4 - JavaOne 2010Max Katz
 
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
 
Ajax Applications with JSF 2 and new RichFaces 4 - Herbstcampus
Ajax Applications with JSF 2 and new RichFaces 4 - HerbstcampusAjax Applications with JSF 2 and new RichFaces 4 - Herbstcampus
Ajax Applications with JSF 2 and new RichFaces 4 - HerbstcampusMax Katz
 
Introduction to RichFaces
Introduction to RichFacesIntroduction to RichFaces
Introduction to RichFacesMax Katz
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen LjuSkills Matter
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen LjuSkills Matter
 
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
 
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
 
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
 
Hyperproductive JSF 2.0 @ JavaOne Brazil 2010
Hyperproductive JSF 2.0 @ JavaOne Brazil 2010Hyperproductive JSF 2.0 @ JavaOne Brazil 2010
Hyperproductive JSF 2.0 @ JavaOne Brazil 2010Arun Gupta
 
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
 
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
 
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
 
JSF 2.0 (JavaEE Webinar)
JSF 2.0 (JavaEE Webinar)JSF 2.0 (JavaEE Webinar)
JSF 2.0 (JavaEE Webinar)Roger Kitain
 
AnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFacesAnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFacesAnkara JUG
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortalJennifer Bourey
 

Similar to Build Cool Apps with JSF and RichFaces (20)

RichFaces: rich:* component library
RichFaces: rich:* component libraryRichFaces: rich:* component library
RichFaces: rich:* component library
 
Hands On With Rich Faces 4 - JavaOne 2010
Hands On With Rich Faces 4 - JavaOne 2010Hands On With Rich Faces 4 - JavaOne 2010
Hands On With Rich Faces 4 - JavaOne 2010
 
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
 
Ajax Applications with JSF 2 and new RichFaces 4 - Herbstcampus
Ajax Applications with JSF 2 and new RichFaces 4 - HerbstcampusAjax Applications with JSF 2 and new RichFaces 4 - Herbstcampus
Ajax Applications with JSF 2 and new RichFaces 4 - Herbstcampus
 
Introduction to RichFaces
Introduction to RichFacesIntroduction to RichFaces
Introduction to RichFaces
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen Lju
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen Lju
 
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
 
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
 
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
 
Hyperproductive JSF 2.0 @ JavaOne Brazil 2010
Hyperproductive JSF 2.0 @ JavaOne Brazil 2010Hyperproductive JSF 2.0 @ JavaOne Brazil 2010
Hyperproductive JSF 2.0 @ JavaOne Brazil 2010
 
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
 
JSF 2.0 Preview
JSF 2.0 PreviewJSF 2.0 Preview
JSF 2.0 Preview
 
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
 
Jsf
JsfJsf
Jsf
 
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
 
JSF 2.0 (JavaEE Webinar)
JSF 2.0 (JavaEE Webinar)JSF 2.0 (JavaEE Webinar)
JSF 2.0 (JavaEE Webinar)
 
AnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFacesAnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFaces
 
Jsf Ajax
Jsf AjaxJsf Ajax
Jsf Ajax
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortal
 

More from Max Katz

Using cloud tools to build enterprise mobile apps with APIs fast
Using cloud tools to build enterprise mobile apps with APIs fast Using cloud tools to build enterprise mobile apps with APIs fast
Using cloud tools to build enterprise mobile apps with APIs fast Max Katz
 
Wolters Kluwer Tech. Conference: Disrupting Mobile Development
Wolters Kluwer Tech. Conference: Disrupting Mobile DevelopmentWolters Kluwer Tech. Conference: Disrupting Mobile Development
Wolters Kluwer Tech. Conference: Disrupting Mobile DevelopmentMax Katz
 
Tiggzi at DC jQuery Meetup
Tiggzi at DC jQuery MeetupTiggzi at DC jQuery Meetup
Tiggzi at DC jQuery MeetupMax Katz
 
Learn How to Build Mobile Apps Using Cloud Services
Learn How to Build Mobile Apps Using Cloud ServicesLearn How to Build Mobile Apps Using Cloud Services
Learn How to Build Mobile Apps Using Cloud ServicesMax Katz
 
Tiggr Mobile Apps Builder at Silicon Valley HTML5 Group Meetup
Tiggr Mobile Apps Builder at Silicon Valley HTML5 Group MeetupTiggr Mobile Apps Builder at Silicon Valley HTML5 Group Meetup
Tiggr Mobile Apps Builder at Silicon Valley HTML5 Group MeetupMax Katz
 
Tiggr - Web-based IDE for Mobile Web And Native Apps
Tiggr - Web-based IDE for Mobile Web And Native AppsTiggr - Web-based IDE for Mobile Web And Native Apps
Tiggr - Web-based IDE for Mobile Web And Native AppsMax Katz
 
Building Mobile Apps With jQuery For Any Device In The Cloud
Building Mobile Apps With jQuery For Any Device In The Cloud Building Mobile Apps With jQuery For Any Device In The Cloud
Building Mobile Apps With jQuery For Any Device In The Cloud Max Katz
 
Mobile Development Choices: Native Apps vs. Web Apps at JAX 2011
Mobile Development Choices: Native Apps vs. Web Apps at JAX 2011Mobile Development Choices: Native Apps vs. Web Apps at JAX 2011
Mobile Development Choices: Native Apps vs. Web Apps at JAX 2011Max Katz
 
Devoxx2010 - Mobile Development Choices: Native Apps vs Web Apps
Devoxx2010 - Mobile Development Choices: Native Apps vs Web AppsDevoxx2010 - Mobile Development Choices: Native Apps vs Web Apps
Devoxx2010 - Mobile Development Choices: Native Apps vs Web AppsMax Katz
 
RichFaces skins
RichFaces skinsRichFaces skins
RichFaces skinsMax Katz
 
RichFaces: more concepts and features
RichFaces: more concepts and featuresRichFaces: more concepts and features
RichFaces: more concepts and featuresMax Katz
 
Rich Enterprise Applications with JavaFX
Rich Enterprise Applications with JavaFXRich Enterprise Applications with JavaFX
Rich Enterprise Applications with JavaFXMax Katz
 
Building RIA Applications with JavaFX
Building RIA Applications with JavaFXBuilding RIA Applications with JavaFX
Building RIA Applications with JavaFXMax Katz
 
Building RIA Applications with RichFaces
Building RIA Applications with RichFacesBuilding RIA Applications with RichFaces
Building RIA Applications with RichFacesMax Katz
 

More from Max Katz (14)

Using cloud tools to build enterprise mobile apps with APIs fast
Using cloud tools to build enterprise mobile apps with APIs fast Using cloud tools to build enterprise mobile apps with APIs fast
Using cloud tools to build enterprise mobile apps with APIs fast
 
Wolters Kluwer Tech. Conference: Disrupting Mobile Development
Wolters Kluwer Tech. Conference: Disrupting Mobile DevelopmentWolters Kluwer Tech. Conference: Disrupting Mobile Development
Wolters Kluwer Tech. Conference: Disrupting Mobile Development
 
Tiggzi at DC jQuery Meetup
Tiggzi at DC jQuery MeetupTiggzi at DC jQuery Meetup
Tiggzi at DC jQuery Meetup
 
Learn How to Build Mobile Apps Using Cloud Services
Learn How to Build Mobile Apps Using Cloud ServicesLearn How to Build Mobile Apps Using Cloud Services
Learn How to Build Mobile Apps Using Cloud Services
 
Tiggr Mobile Apps Builder at Silicon Valley HTML5 Group Meetup
Tiggr Mobile Apps Builder at Silicon Valley HTML5 Group MeetupTiggr Mobile Apps Builder at Silicon Valley HTML5 Group Meetup
Tiggr Mobile Apps Builder at Silicon Valley HTML5 Group Meetup
 
Tiggr - Web-based IDE for Mobile Web And Native Apps
Tiggr - Web-based IDE for Mobile Web And Native AppsTiggr - Web-based IDE for Mobile Web And Native Apps
Tiggr - Web-based IDE for Mobile Web And Native Apps
 
Building Mobile Apps With jQuery For Any Device In The Cloud
Building Mobile Apps With jQuery For Any Device In The Cloud Building Mobile Apps With jQuery For Any Device In The Cloud
Building Mobile Apps With jQuery For Any Device In The Cloud
 
Mobile Development Choices: Native Apps vs. Web Apps at JAX 2011
Mobile Development Choices: Native Apps vs. Web Apps at JAX 2011Mobile Development Choices: Native Apps vs. Web Apps at JAX 2011
Mobile Development Choices: Native Apps vs. Web Apps at JAX 2011
 
Devoxx2010 - Mobile Development Choices: Native Apps vs Web Apps
Devoxx2010 - Mobile Development Choices: Native Apps vs Web AppsDevoxx2010 - Mobile Development Choices: Native Apps vs Web Apps
Devoxx2010 - Mobile Development Choices: Native Apps vs Web Apps
 
RichFaces skins
RichFaces skinsRichFaces skins
RichFaces skins
 
RichFaces: more concepts and features
RichFaces: more concepts and featuresRichFaces: more concepts and features
RichFaces: more concepts and features
 
Rich Enterprise Applications with JavaFX
Rich Enterprise Applications with JavaFXRich Enterprise Applications with JavaFX
Rich Enterprise Applications with JavaFX
 
Building RIA Applications with JavaFX
Building RIA Applications with JavaFXBuilding RIA Applications with JavaFX
Building RIA Applications with JavaFX
 
Building RIA Applications with RichFaces
Building RIA Applications with RichFacesBuilding RIA Applications with RichFaces
Building RIA Applications with RichFaces
 

Recently uploaded

"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
 
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
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
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
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
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
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 

Recently uploaded (20)

"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
 
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
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
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
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
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
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 

Build Cool Apps with JSF and RichFaces

  • 1. What You Need for Building Cool Enterprise Applications with JSF Max Katz Exadel Oct. 4, 2011
  • 2. >max@exadel.com Max Katz >@maxkatz >mkblog.exadel.com Senior Systems Engineer JSF, RichFaces, Java EE consulting, and training Developer Relations for Tiggr Mobile Apps Builder (http://gotiggr.com)
  • 3. Exadel is a global software engineering company Founded in 1998, headquarters in San Francisco Bay Area 7 Development offices in Europe [Munich, Moscow, Ekaterinburg, Minsk, Homeyl, Kharkov, Donetsk] 400+ employees
  • 4. The Plan Is Simple 1) Ajax features in JSF 2 2) The new RichFaces 4 – or what you need to build cool enterprise applications with JSF
  • 5. JavaServer Faces™ (JSF) is the standard component- based user interface (UI) framework for the Java EE (5 & 6) platform JSF 1.2 Java EE 5 JSF 2 Java EE 6
  • 6. JSF 2 is a major upgrade over JSF 1.x Many features, ideas taken from projects such as Seam, RichFaces, and others
  • 7. JSF 2 new features ● Facelets ● New scopes ● Composite ◦ Flash, View, components custom ● Implicit ● Configuration navigation via annotations ● GET ● Bean Validation support support ◦ h:link, h:button ● Basic Ajax ● Resource loading
  • 8. JSF 2 <f:ajax> ● Very basic Ajax functionality ● Greatly inspired by RichFaces 3 <a4j:support> tag ● Ajax in JSF in 3 easy steps: 1. Sending an Ajax request 2.Partial view processing 3.Partial view rendering
  • 9. <h:form> <h:form> <h:input value="#{bean.word}"/> <h:input value="#{bean.word}"/> <h:commandButton> <h:commandButton> <f:ajax event="click" 1 <f:ajax event="click" execute="@form" 2 execute="@form" listener="#{bean.ajaxListener}" listener="#{bean.ajaxListener}" render="out1 out2"/> 3 render="out1 out2"/> </h:commandButton> </h:commandButton> </h:form> </h:form>
  • 10. <h:form> <h:form> <h:input value="#{bean.word}"/> <h:input value="#{bean.word}"/> <h:selectOneMenu value="#{bean.selected}"> <h:selectOneMenu value="#{bean.selected}"> <f:selectItems value="#{bean.items}"/> <f:selectItems value="#{bean.items}"/> <f:ajax event="change" 1 <f:ajax event="change" execute="@form" execute="@form" 2 listener="#{bean.ajaxListener}" listener="#{bean.ajaxListener}" render="@form"/> 3 render="@form"/> </h:commandButton> </h:commandButton> </h:form> </h:form>
  • 11. Attribute Value Important Event on which to fire the <f:ajax> event Ajax request attributes @all @this (default) @form execute @none id's EL @all @this @form render @none (default) id's EL
  • 12. That's good, but that's all you get. Where do you get rich components and more? A rich component framework is still(?) needed to build real-world Ajax applications.
  • 13. RichFaces 4 is a lightweight, open source framework for JSF 2
  • 14. RichFaces 4 – rich JSF framework UI components a4j:* tag library (core) rich:* tag library (UI) Components' JavaScript API Skins Client-side validation (Bean Validation based) CDK – Component Development Kit
  • 15. 100% built on top of JSF2, just extends functionality in JSF 2
  • 16. JavaScript is now entirely based on the popular jQuery library
  • 17. RichFaces 4 is a lot faster, consistent, and optimized All components are reviewed for consistency, usability Redesigned following semantic HTML principles Server-side and client-side performance optimization Strict code clean-up and review
  • 18. New client-side validation based on Bean Validation (JSR 303) Quickly and easily validate input on the client
  • 19. New, and easy to use CDK (Component Development Kit), allows quickly to build your own custom rich components
  • 20. Pick your server: Tomcat 6/7, Resin, JBoss AS 6/7, GlassFish 3.x, WebLogic [any server where JSF 2 application can be deployed]
  • 21. Deploy and run in the cloud: Google App Engine Amazon EC2, CloudBees, OpenShift
  • 22. Pick JSF implementations you like: Mojarra or MyFaces
  • 23. Run in any browser
  • 24. Pick your favorite tooling: JBoss Tools, IntelliJ, NetBeans
  • 25. Easy to start. Zero-configuration, just drop RichFaces into the application
  • 26. RichFaces versions Version JSF 1.1 JSF 1.2 JSF 2 RichFaces 3.1.x • RichFaces 3.3.3* • • RichFaces 4 • * Note: RichFaces 3.3.3 has basic JSF 2 support
  • 27. RichFaces history 2005: started by Alexander Smirnov 2005-2007: Developed by Exadel Ajax4jsf - open source, free RichFaces - commercial 2007: JBoss takes over Exadel team continues to develop the framework, project is known as RichFaces
  • 28. Let's see what cool components, and features you get with RichFaces...
  • 29. RichFaces <a4j:ajax> ● 100% based on standard <f:ajax> ● Just replace f: with a4j: and get exactly the same functionality ● But, you get extra features... <h:commandButton> <h:commandButton> <f:ajax execute="@form" render="output"/> <f:ajax execute="@form" render="output"/> </h:commandButton> </h:commandButton> <h:commandButton> <h:commandButton> <a4j:ajax execute="@form" render="output"/> <a4j:ajax execute="@form" render="output"/> </h:commandButton> </h:commandButton>
  • 30. <a4j:ajax> attributes Feature/Attribute Description JavaScript to execute before Ajax onbegin request JavaScript to execute after response onbeforedomupdate comes back but before DOM update oncomplete JavaScript to execute after DOM update Allows to skip JSF phases when bypassUpdates validating limitRender Turns off all auto-rendered panels status Status to display during Ajax request Ajax queue Advanced RichFaces client queue
  • 31. Components to send Ajax request ● <a4j:ajax> ● <a4j:commandButton> ● <a4j:commandLink> ● <a4j:jsFunction> ● <a4j:poll> ● <a4j:push>
  • 32. <a4j:commandButton/Link> – button and link with built-in Ajax behavior <a4j:commandButton value="Save" <a4j:commandButton value="Save" action="#{bean.action}" action="#{bean.action}" render="output" /> render="output" /> <a4j:commandLink value="Save" <a4j:commandLink value="Save" action="#{bean.action}" action="#{bean.action}" render="output" /> render="output" />
  • 33. When using standard JSF button: <h:form> <h:form> <h:inputText> <h:inputText> <h:selectOneMenu> Need to set <h:selectOneMenu> <h:commandButton> <h:commandButton> execute=”@form” <f:ajax execute="@form"/> <f:ajax execute="@form"/> (or execute=”id1 id2”) </h:commandButton> </h:commandButton> <h:form> <h:form> When using RichFaces button: <h:form> <h:form> RichFaces default <h:inputText> <h:inputText> <h:selectOneMenu> value for <h:selectOneMenu> <a4j:commandButton/> <a4j:commandButton/> button/link <h:form> <h:form> execute=”@form”
  • 34. <a4j:jsFunction> – fire Ajax request from any JavaScript function, HTML event <table> <table> ... ... <td onmouseover="update('yellow')"/> <td onmouseover="update('yellow')"/> ... ... </table> </table> <h:form> <h:form> <a4j:jsFunction name="update" <a4j:jsFunction name="update" action="#{bean.change}" render="..."> action="#{bean.change}" render="..."> <a4j:param value="param1" assignTo="#{bean.color}"/> <a4j:param value="param1" assignTo="#{bean.color}"/> </a4j:jsFunction> </a4j:jsFunction> </h:form> </h:form>
  • 35. If you had to pick just one Ajax control, you would want <a4j:jsFunction> <h:commandButton action="#{bean.change}"> <h:commandButton action="#{bean.change}"> <a4j:ajax render="id"/> <a4j:ajax render="id"/> </h:commandButton> </h:commandButton> Is the same as: <h:commandButton onclick="sendAjax();"/> <h:commandButton onclick="sendAjax();"/> <a4j:jsFunction name="sendAjax" <a4j:jsFunction name="sendAjax" action="#{bean.change}" render="id"/> action="#{bean.change}" render="id"/>
  • 36. <a4j:poll> – periodically send an Ajax request <a4j:poll interval="1000" <a4j:poll interval="1000" action="#{bean.count}" action="#{bean.count}" render="output" render="output" enabled="#{bean.pollEnabled}" /> enabled="#{bean.pollEnabled}" /> <h:panelGrid id="output"> <h:panelGrid id="output"> ... ... </h:panelGrid> </h:panelGrid>
  • 37. <a4j:push> ● Server-side events are pushed to client using Comet or WebSockets. ● Implemented using Atmosphere ● Providesexcellent integration with EE containers, and advanced messaging services <a4j:push address="topic@chat" <a4j:push address="topic@chat" ondataavailable="alert(event.rf.data)" /> ondataavailable="alert(event.rf.data)" />
  • 38. Advanced rendering features ● <a4j:outputPanel> ● limitRender attribute ● render=”{bean.renderList}”
  • 39. <a4j:outputPanel> – auto rendered panel <a4j:commandButton value="Save" action="#{bean.save}"> <a4j:commandButton value="Save" action="#{bean.save}"> <a4j:commandButton value="Edit" action="#{bean.edit}"> <a4j:commandButton value="Edit" action="#{bean.edit}"> <a4j:outputPanel ajaxRendered="true"> <a4j:outputPanel ajaxRendered="true"> <h:panelGrid> <h:panelGrid> ... ... </h:panelGrid> </h:panelGrid> </a4j:outputPanel> </a4j:outputPanel> <a4j:outputPanel ajaxRendered="true"> <a4j:outputPanel ajaxRendered="true"> <rich:dataTable> <rich:dataTable> ... ... </rich:dataTable> </rich:dataTable> </a4j:outputPanel> </a4j:outputPanel>
  • 40. Turning off auto rendered panels <a4j:commandButton value="Save" action="#{bean.save}"> <a4j:commandButton value="Save" action="#{bean.save}"> <a4j:commandButton value="Edit" action="#{bean.edit}" <a4j:commandButton value="Edit" action="#{bean.edit}" render="edit" limitRender="true"> render="edit" limitRender="true"> <a4j:outputPanel ajaxRendered="true"> <a4j:outputPanel ajaxRendered="true"> <h:panelGrid> <h:panelGrid> ... ... </h:panelGrid> </h:panelGrid> </a4j:outputPanel> </a4j:outputPanel> <h:panelGrid id="edit"> <h:panelGrid id="edit"> <rich:dataTable> <rich:dataTable> ... ... </rich:dataTable> </rich:dataTable> </h:panelGrid> </h:panelGrid>
  • 41. render=”#{bean.renderList}” JSF RichFaces 1) Ajax request sent 1) Ajax request sent 2) Component id's to be 2) Component id's to rendered resolved be rendered 3) Component id's are resolved rendered into the page 3) Component id's 4) 2nd Ajax request is sent. are rendered In this request the components (resolved in step 2 are sent with request) will be rendered
  • 42. Advanced execute features ● <a4j:region> ● bypassUpdates attribute
  • 43. <a4j:region> – defining execute region declaratively <h:form> <h:form> <a4j:region> <a4j:region> <h:inputText /> <h:inputText /> <h:inputText /> <h:inputText /> <h:selectOneMenu /> <h:selectOneMenu /> <a4j:commandButton /> <a4j:commandButton /> <a4j:region> <a4j:region> </h:form> </h:form>
  • 44. Skipping phases when validating 1.Restore View 2.Apply Request Values 3.Process Validation 4.Update Model 5.Invoke Application 6.Render Response <h:inputText id="name" value="#{bean.name}"/> <h:inputText id="name" value="#{bean.name}"/> <a4j:ajax event="blur" bypassUpdates="true"/> <a4j:ajax event="blur" bypassUpdates="true"/> </h:inputText> </h:inputText> <rich:message for="name"/> <rich:message for="name"/>
  • 45. Even more advanced features and tags ● JavaScript callbacks ● Queue ● <a4j:status> ● <a4j:param> ● <a4j:log>
  • 46. Easily use JavaScript callbacks during Ajax request <a4j:commandLink value="Link" <a4j:commandLink value="Link" onbegin="ajaxOnBegin()" onbegin="ajaxOnBegin()" onbeforedomupdate="ajaxOnBeforeDomUpdate()" onbeforedomupdate="ajaxOnBeforeDomUpdate()" oncomplete="ajaxOnComplete()"> oncomplete="ajaxOnComplete()"> </a4j:commandLink> </a4j:commandLink>
  • 47. JSF 2 queue ● JSF2 has very basic queue functionality ● Events are queued and fired one at a time ● Only one request is processed on the server at a time
  • 48. <a4j:queue> – “combining” events from the same component While a request is executing on the server, all requests from button A or button B will be combined (merged) if the last event in the queue is of the same type. <a4j:queue /> <a4j:queue /> ... ... <a4j:commandButton id="buttonA" value="Button A"/> <a4j:commandButton id="buttonA" value="Button A"/> <a4j:commandButton id="buttonB" value="Button B"/> <a4j:commandButton id="buttonB" value="Button B"/>
  • 49. <a4j:queue> – “combining” events from different components While a request is executing on the server, all requests from button A or button B will be combined (merged). <a4j:queue /> <a4j:queue /> <a4j:commandButton id="buttonA" value="Button A"> <a4j:commandButton id="buttonA" value="Button A"> <a4j:attachdQueue requestGroupingId="ajaxGroup"/> <a4j:attachdQueue requestGroupingId="ajaxGroup"/> </a4j:commandButton> </a4j:commandButton> <a4j:commandButton id="buttonB" value="Button B"> <a4j:commandButton id="buttonB" value="Button B"> <a4j:attachdQueue requestGroupingId="ajaxGroup"/> <a4j:attachdQueue requestGroupingId="ajaxGroup"/> </a4j:commandButton> </a4j:commandButton>
  • 50. <a4j:queue> – setting request delay allows “waiting” for requests from same component in order to merge events <a4j:queue requestDelay="1000"/> <a4j:queue requestDelay="1000"/> <a4j:commandButton id="buttonA" value="Button A"> <a4j:commandButton id="buttonA" value="Button A"> <a4j:attachdQueue requestDelay="2000"/> <a4j:attachdQueue requestDelay="2000"/> </a4j:commandButton> </a4j:commandButton> <a4j:commandButton id="buttonB" value="Button B"/> <a4j:commandButton id="buttonB" value="Button B"/>
  • 51. <a4j:queue> – ignoring “stale” responses <a4j:queue requestDelay="2000 <a4j:queue requestDelay="2000 ingoreDupResponses="true"/> ingoreDupResponses="true"/> <h:inputText value="#{bean.state}"> <h:inputText value="#{bean.state}"> <a4j:ajax event="keyup" listener="#{bean.load}" <a4j:ajax event="keyup" listener="#{bean.load}" render="states"/> render="states"/> </h:inputText> </h:inputText>
  • 52. <a4j:status> – Ajax request status <a4j:status name="ajaxStatus"> <a4j:status name="ajaxStatus"> <f:facet name="start"> <f:facet name="start"> <h:graphicImage value="ajaxStatus.jpg"/> <h:graphicImage value="ajaxStatus.jpg"/> </f:facet> </f:facet> </a4j:status> </a4j:status> <h:form> <h:form> <a4j:commandButton status="ajaxStatus"/> <a4j:commandButton status="ajaxStatus"/> </h:form> </h:form>
  • 53. <a4j:param> - like <f:param>, but simpler as it also assigns the value to a bean property automatically <a4j:commandButton value="Save"> <a4j:commandButton value="Save"> <a4j:param value="1009" assignTo="#{bean.product}"/> <a4j:param value="1009" assignTo="#{bean.product}"/> </a4j:commandButton> </a4j:commandButton> public class Bean { public class Bean { private String product; private String product; public void setProduct (String product) {...} public void setProduct (String product) {...} }}
  • 54. Another great feature is that <a4j:param> value can contain any JavaScript expression or JavaScript function, when noEscape="true" <a4j:param name="width" <a4j:param name="width" value="(jQuery(window).width()/2)" value="(jQuery(window).width()/2)" assignTo="#{bean.screenWidth}" assignTo="#{bean.screenWidth}" noEscape="true" /> noEscape="true" />
  • 55. <a4j:log> – Ajax request/response information, logging
  • 56. RichFaces UI components ● Output, panels ● Input ● Menu ● Data iteration ● Tree ● Drag and drop ● Client side validation ● Miscellaneous
  • 58. More rich output, panels ● rich:panel ● rich:togglePanel ● rich:popupPanel ● rich:collapsiblePanel ● rich:toolTip
  • 59. <rich:popupPanel> can be modal and non-modal <rich:popupPanel modal="false"> <f:facet name="header"> Edit User </f:facet> ... ... </rich:popupPanel>
  • 61. More rich input ● rich:inputNumberSpinner ● rich:inplaceSelect ● rich:select ● rich:fileUpload
  • 64. RichFaces data iteration components support partial updates render="@column" render="@header" render="@body" render="@footer" render="cellId" To render from outside the table: render="tableId@header" render="tableId@body" render="tableId@footer"
  • 65. Deciding what rows/cell to update in run-time render="tableId:rows(bean.rowsSet)" render="tableId:rows(bean.rowsSet):cellId"
  • 66. New collapsible sub table component
  • 68. <rich:extendedDataTable> provides lazy loading, column resizing, reorder and more
  • 69. More rich data iteration ● a4j:repeat ● rich:extendedDataTable ● rich:collapsibleSubTable ● rich:list ◦ list | ordered | definition ● rich:dataGrid ● rich:column ◦ Column and row spanning ◦ Filtering, sorting
  • 72. Many RichFaces components provide client-side JavaScript API <rich:popupPanel> JavaScript API Method name Description Return the top co-ordinate for the position of getTop() the pop-up panel. Return the left co-ordinate for the position of getLeft() the pop-up panel. Move the pop-up panel to the co-ordinates moveTo(top,left) specified with the top and left parameters. Resize the pop-up panel to the size specified resize(width,height) with the width and height parameters. show() Show the pop-up panel. hide() Hide the pop-up panel.
  • 73. Invoking component JavaScript API using #{rich:component(id)} function <input type="button" <input type="button" onclick="#{rich:component('popup')}.show();" onclick="#{rich:component('popup')}.show();" value="Open" /> value="Open" /> <rich:popupPanel id="popup"> <rich:popupPanel id="popup"> <h:outputLink value="#" <h:outputLink value="#" onclick="#{rich:component('popup')}.hide(); onclick="#{rich:component('popup')}.hide(); return false;"> return false;"> <h:outputText value="Close"/> <h:outputText value="Close"/> </h:outputLink> </h:outputLink> </rich:popupPanel> </rich:popupPanel>
  • 74. Invoking component JavaScript API using <rich:componentControl> component <h:outputLink value="#"> <h:outputLink value="#"> <h:outputText value="Open" /> <h:outputText value="Open" /> <rich:componentControl event="click" <rich:componentControl event="click" target="popup" operation="show" /> target="popup" operation="show" /> </h:outputLink> </h:outputLink> <rich:popupPanel header="RichFaces" id="popup"> <rich:popupPanel header="RichFaces" id="popup"> <h:outputLink value="#"> <h:outputLink value="#"> <h:outputText value="Close" /> <h:outputText value="Close" /> <rich:componentControl event="click" <rich:componentControl event="click" target="popup" operation="hide" /> target="popup" operation="hide" /> </h:outputLink> </h:outputLink> </rich:popupPanel> </rich:popupPanel>
  • 75. <rich:accordion id="c"> <rich:accordion id="c"> <rich:accordionItem header="New York" name="nyc"> <rich:accordionItem header="New York" name="nyc"> <h:outputText value="You selected New York"/> <h:outputText value="You selected New York"/> </rich:accordionItem> </rich:accordionItem> <rich:accordionItem header="San Francisco" name="sf"> <rich:accordionItem header="San Francisco" name="sf"> <h:outputText value="You selected San Francisco"/> <h:outputText value="You selected San Francisco"/> </rich:accordionItem> </rich:accordionItem> ... ... </rich:accordion> </rich:accordion>
  • 76. <input type="button" value="New York City" <input type="button" value="New York City" onclick="#{rich:component('c')}.switchToItem('nyc')"/> onclick="#{rich:component('c')}.switchToItem('nyc')"/> <input type="button" value="San Francisco" <input type="button" value="San Francisco" onclick="#{rich:component('c')}.switchToItem('sf')"/> onclick="#{rich:component('c')}.switchToItem('sf')"/> <input type="button" value="Los Angeles" <input type="button" value="Los Angeles" onclick="#{rich:component('c')}.switchToItem('la')"/> onclick="#{rich:component('c')}.switchToItem('la')"/> <input type="button" value="First" <input type="button" value="First" onclick="#{rich:component('c')}.switchToItem('@first')"/> onclick="#{rich:component('c')}.switchToItem('@first')"/> <input type="button" value="Next" <input type="button" value="Next" onclick="#{rich:component('c')}.switchToItem('@next')"/> onclick="#{rich:component('c')}.switchToItem('@next')"/> <input type="button" value="Previous" <input type="button" value="Previous" onclick="#{rich:component('c')}.switchToItem('@prev')"/> onclick="#{rich:component('c')}.switchToItem('@prev')"/> <input type="button" value="Last" <input type="button" value="Last" onclick="#{rich:component('c')}.switchToItem('@last')"/> onclick="#{rich:component('c')}.switchToItem('@last')"/>
  • 77. RichFaces client functions Function Description rich:client(id) Returns component client id rich:element(id) Returns DOM element Returns RichFaces client component rich:component(id) instance to call JS API method rich:isUserInRole(role) Returns if the user has specified role Returns component instance for given rich:findComponent(id) short id
  • 78. Standard Java EE security with #{rich:isUserInRole(role)} function <rich:panel header="Admin panel" <rich:panel header="Admin panel" rendered="#{rich:isUserInRole('admin')}"> rendered="#{rich:isUserInRole('admin')}"> Very sensitive information Very sensitive information </rich:panel> </rich:panel> <rich:panel header="User panel"> <rich:panel header="User panel"> General information General information </rich:panel> </rich:panel> ● Calls facesContext.getExternalContext.getUserInRole(role) ● What's good is that security roles can be defined anywhere
  • 79. Client-side validation based on Bean Validation (JSR 303) New in RichFaces 4
  • 80. Bean Validation (JSR 303) JSF 2 has support for Bean Validation (validation done on server) Bean: public class Bean { public class Bean { @Pattern(regexp="...") @Pattern(regexp="...") private String email; private String email; }} JSF page: <h:inputText id="email" value="#{bean.email}"> <h:inputText id="email" value="#{bean.email}"> <a4j:ajax event="blur"/> <a4j:ajax event="blur"/> </h:inputText> </h:inputText> <rich:message for="email"/> <rich:message for="email"/>
  • 81. Client-Validation Based on Bean Validation Validation is performed on the client. If no client implementation available, validation automatically falls back to standard, server validation Bean: public class Bean { public class Bean { @Pattern(regexp="...") @Pattern(regexp="...") private String email; private String email; }} JSF page: <h:inputText id="email" value="#{bean.email}"> <h:inputText id="email" value="#{bean.email}"> <rich:validator /> <rich:validator /> </h:inputText> </h:inputText> <rich:message for="email"/> <rich:message for="email"/>
  • 82. Object validation with <rich:graphValidator> @Size(min=5,max=15) @Size(min=5,max=15) private String password1; private String password1; @Size(min=5,max=15) @Size(min=5,max=15) private String password2; private String password2; @AssertTrue(message="Passwords don't match") @AssertTrue(message="Passwords don't match") public boolean checkPassword() { public boolean checkPassword() { return password1.equals(password1); return password1.equals(password1); }} <rich:graphValidator value="#{bean}" id="crossField"> <rich:graphValidator value="#{bean}" id="crossField"> <h:inputText value="#{bean.password1}"/> <h:inputText value="#{bean.password1}"/> <h:inputText value="#{bean.password2}"/> <h:inputText value="#{bean.password2}"/> <rich:message for="email" for="crossField"/> <rich:message for="email" for="crossField"/> </rich:graphValidator> </rich:graphValidator>
  • 83. Rich miscellaneous ● <rich:componentControl> ● <rich:hashParam> ● <rich:jQuery>
  • 84. <rich:componentControl> ● Allows to call JS API on a component in declarative fashion <h:outputLink id="openLink" value="#"> <h:outputLink id="openLink" value="#"> <h:outputText value="Open" /> <h:outputText value="Open" /> <rich:componentControl event="click" <rich:componentControl event="click" operation="show" operation="show" target="popup" /> target="popup" /> </h:outputLink> </h:outputLink> <rich:popupPanel id="popup"> <rich:popupPanel id="popup"> ... ... </rich:popupPanel> </rich:popupPanel>
  • 85. <rich:hashParam> - creates JavaScript hash, can be passed to another client function. <h:commandButton value="Show popup"> <h:commandButton value="Show popup"> <rich:componentControl target="pp" operation="show"> <rich:componentControl target="pp" operation="show"> <rich:hashParam> <rich:hashParam> <f:param name="width" value="500" /> <f:param name="width" value="500" /> <f:param name="height" value="300" /> <f:param name="height" value="300" /> <f:param name="minWidth" value="300" /> <f:param name="minWidth" value="300" /> <f:param name="minHeight" value="150" /> <f:param name="minHeight" value="150" /> </rich:hashParam> </rich:hashParam> </rich:componentControl> </rich:componentControl> </h:commandButton </h:commandButton
  • 86. Using jQuery with <rich:jQuery> <input type="button" id=" value="Update panel"/> <input type="button" id=" value="Update panel"/> <rich:jQuery selector="#changeButton" event="click" <rich:jQuery selector="#changeButton" event="click" query="$('#nycInfo .rf-p-hdr').text('New York City'); query="$('#nycInfo .rf-p-hdr').text('New York City'); $('.rf-p-b').css('color', 'blue');" /> $('.rf-p-b').css('color', 'blue');" />
  • 87. Using jQuery when page rendered to create zebra-like styling for table
  • 88. <style> <style> .even-row { .even-row { background-color: #FCFFFE; background-color: #FCFFFE; }} .odd-row { .odd-row { background-color: #ECF3FE; background-color: #ECF3FE; }} </style> </style> <rich:dataTable id="gamesTable"> <rich:dataTable id="gamesTable"> // columns // columns </rich:dataTable> </rich:dataTable> <rich:jQuery selector="#gamesTable tr:odd" <rich:jQuery selector="#gamesTable tr:odd" query="addClass('odd-row')" /> query="addClass('odd-row')" /> <rich:jQuery selector="#gamesTable tr:even" <rich:jQuery selector="#gamesTable tr:even" query="addClass('even-row')" /> query="addClass('even-row')" />
  • 89. Invoking <rich:jQuery> as a regular JavaScript function with mouse over <h:graphicImage width="100" value="/images/venice.png" <h:graphicImage width="100" value="/images/venice.png" onmouseover="larger(this, {})" onmouseover="larger(this, {})" onmouseout="normal(this, {})" /> onmouseout="normal(this, {})" /> <rich:jQuery name="larger" <rich:jQuery name="larger" query="animate({width:'241px'})" /> query="animate({width:'241px'})" /> <rich:jQuery name="normal" <rich:jQuery name="normal" query="animate({width:'100px'})"/> query="animate({width:'100px'})"/>
  • 90. Skins
  • 91. Skins ● Lightweight extension on top of CSS ● Change look and feel of all rich component with a few minor changes ● Can be applied to standard JSF and HTML tags as well
  • 92. Ready-to-use skins ● classic ● wine ● blueSky ● ruby ● emeraldTown ● deepMarine <context-param> ● plain <context-param> <param-name>org.richfaces.skin</param-name> <param-name>org.richfaces.skin</param-name> <param-value>ruby</param-value> ● japanCherry <param-value>ruby</param-value> </context-param> </context-param>
  • 93. RichFaces Skin file #Colors #Colors headerBackgroundColor=#900000 headerBackgroundColor=#900000 headerGradientColor=#DF5858 headerGradientColor=#DF5858 headerTextColor=#FFFFFF headerTextColor=#FFFFFF headerWeightFont=bold headerWeightFont=bold generalBackgroundColor=#f1f1f1 generalBackgroundColor=#f1f1f1 generalTextColor=#000000 generalTextColor=#000000 generalSizeFont=11px generalSizeFont=11px generalFamilyFont=Arial, Verdana, sans-serif generalFamilyFont=Arial, Verdana, sans-serif controlTextColor=#000000 controlTextColor=#000000 controlBackgroundColor=#ffffff controlBackgroundColor=#ffffff additionalBackgroundColor=#F9E4E4 additionalBackgroundColor=#F9E4E4
  • 94. Skins ● Modify existing or create your own <context-param> <context-param> <param-name>org.richfaces.skin</param-name> <param-name>org.richfaces.skin</param-name> <param-value>myCoolSkin</param-value> <param-value>myCoolSkin</param-value> </context-param> </context-param> ● Change skins in runtime <context-param> <context-param> <param-name>org.richfaces.skin</param-name> <param-name>org.richfaces.skin</param-name> <param-value>#{bean.skin}</param-value> <param-value>#{bean.skin}</param-value> </context-param> </context-param>
  • 95. Overwriting Skin CSS <style> <style> .rf-p-hdr { .rf-p-hdr { color: … color: … font-size: … font-size: … font-weight: … font-weight: … font-family: … font-family: … }} </style> </style> <rich:panel>...</rich:panel> <rich:panel>...</rich:panel>
  • 96. Overwriting Skin CSS <style> <style> .rf-p-hdr { .rf-p-hdr { // overwrite skin CSS properties // overwrite skin CSS properties }} .specialHeader { .specialHeader { // define custom CSS for specific panel // define custom CSS for specific panel }} </style> </style> <rich:panel id="panel1"> <rich:panel id="panel1"> ... ... <rich:panel> <rich:panel> <rich:panel id="panel2" headerClass="specialHeader"> <rich:panel id="panel2" headerClass="specialHeader"> ... ... <rich:panel> <rich:panel>
  • 97. Skinning standard JSF tags and HTML tags Apply to each control: <h:button style="background-color: <h:button style="background-color: '#{richSkin.tableBackgroundColor}'"/> '#{richSkin.tableBackgroundColor}'"/>
  • 98. Skinning standard JSF tags and HTML tags automatically Apply to all standard controls (JSF and HTML): <context-param> <context-param> <param-name> <param-name> org.richfaces.enableControlSkinning org.richfaces.enableControlSkinning </param-name> </param-name> <param-value>true</param-value> <param-value>true</param-value> </context-param> </context-param>
  • 99. Skinning standard JSF tags and HTML tags only when special CSS class is applied to parent container <context-param> <context-param> <param-name> <param-name> org.richfaces.enableControlSkinningClasses org.richfaces.enableControlSkinningClasses </param-name> </param-name> <param-value>true</param-value> <param-value>true</param-value> </context-param> </context-param> <div class="rfs-ctn"> <div class="rfs-ctn"> <h:outputText /> <h:outputText /> <h:inputText /> <h:inputText /> <h:commandButton /> <h:commandButton /> </div> </div>
  • 100. Where can I try the new RichFaces 4? http://richfaces.org/showcase
  • 101. RichFaces 4.1 (Late 2011) Mobile support New components: Pick list Ordering list Rich text editor
  • 102. How can we help with RichFaces ● Web development with RichFaces Training Days ● Version 3 to 4 migration JSF 1.2, 2 1-2 ● Performance tune-up RichFaces 3, 4 1-2 JSF and RichFaces 2-3 ● Custom component RichFaces 3 to 4 1-2 development ● On-site training
  • 103. RichFaces Rich, flexible, robust, and proven enterprise-level framework to JSF 2
  • 104. Tiggr is a Web-based mobile apps builder. Super fast, and easy to build mobile Web and native apps Build your mobile app at http://gotiggr.com
  • 105. Export or build the app as mobile Web or generate native app (for Android, iOS)
  • 106. Thank you! How to get in touch with me: >max@exadel.com >@maxkatz >mkblog.exadel.com Build your mobile app in the cloud: http://gotiggr.com