Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

RichFaces 4 webinar #1: Everything You Need To Know


Published on

RichFaces 4 webinar series.
Webinar #1: RichFaces 4 - Everything you need to know.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

RichFaces 4 webinar #1: Everything You Need To Know

  1. 1. ExadelRichFaces 4 Webinar SeriesWebinar #1:RichFaces 4 – Everything You Need ToKnowApril 20, 2011Max KatzCharley CowensExadel
  2. 2. ExadelRichFaces 4 WebinarScheduleMay 11, 2011RichFaces 3 to RichFaces 4 – AClass in Moving UpJune 15, 2011RichFaces 4 – New and AdvancedFeatures
  3. 3. ExadelMax Katz● Senior Systems Engineer● JSF,RichFaces, Java EE consulting, and training● Manages – Exadels open source projects and community● Community manager for – tool for creating and sharing interactive web and mobile HTML prototypes
  4. 4. Exadel 4 Summer 2011 Author of Lead-author ofPractical RichFaces Practical RichFaces, 2/e (Apress) (Apress, June 2011)
  5. 5. Exadel PublishedApril 11, 2011
  6. 6. ExadelExadel is a global softwareengineering company.● Founded in 1998, headquarters in San Francisco Bay Area● 7 development offices in Europe● 350+ employees
  7. 7. ExadelExadel Products● Open Source with JBoss ◦ RichFaces ◦ JBoss Tools/JBoss Developer Studio● ◦ Flamingo ◦ Fiji ◦ jsf4birt ◦ JavaFX Plug-in for Eclipse●– interactive Web and mobile HTML prototypes
  8. 8. ExadelExadel Services● Professional services● Rich enterprise application development● Eclipse development● Custom rich component development● Mobile development● Training
  9. 9. ExadelThe Plan Is Simple1) Ajax features in JSF 22) The new RichFaces 4
  10. 10. ExadelJavaServer 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
  11. 11. ExadelJSF 2● JSF 2 is a major upgrade over JSF 1.x● Many features, ideas taken from projects such as Seam, and RichFaces, and others
  12. 12. ExadelJSF 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
  13. 13. ExadelJSF 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
  14. 14. Exadel<h:form> <h:input value="#{bean.word}"/> <h:commandButton> <f:ajax event="click" 1 execute="@form" 2 listener="#{bean.ajaxListener}" render="out1 out2"/> 3 </h:commandButton> <h:input value="#{bean.text}" id="out1"/> <h:input value="#{bean.phrase}" id="out2"/></h:form>
  15. 15. Exadel<h:form> <h:input value="#{bean.word}"/> <h:selectOneMenu value="#{bean.selected}"> <f:selectItems value="#{bean.items}"/> <f:ajax event="change" 1 execute="@form" 2 listener="#{bean.ajaxListener}" render="@form"/> 3 </h:commandButton> <h:input value="#{bean.text}" id="out1"/> <h:input value="#{bean.phrase}" id="out2"/></h:form>
  16. 16. Exadel Attribute ValueImportant Event on which to fire the<f:ajax> event Ajax requestattributes @all @this (default) @form execute @none ids EL @all @this @form render @none (default) ids EL
  17. 17. Exadel Thats good, but where doyou get rich components and more?A rich component framework is still(?) needed to build real-world Ajax applications.
  18. 18. ExadelRichFaces 4 is a lightweight,open source framework for JSF 2
  19. 19. ExadelRichFaces 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
  20. 20. ExadelGood, now tell me whats newand what features you get in RichFaces 4?
  21. 21. ExadelRichFaces 4 100% built on top of JSF2, just extends functionality in JSF 2
  22. 22. ExadelRichFaces 4 JavaScript is now entirelybased on the popular jQuery library
  23. 23. ExadelRichFaces 4● 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
  24. 24. ExadelRichFaces 4 Zero-configuration.Just drop RichFaces into the application.
  25. 25. ExadelRichFaces 4 New client-side validation based on Bean Validation (JSR 303)
  26. 26. ExadelRichFaces 4 New, and easy to use CDK (Component Development Kit), allows quickly to build yourown custom rich components
  27. 27. ExadelRichFaces 4Run on: Tomcat 6/7, Resin,JBoss AS 6/7, GlassFish 3.x, WebLogic(run on any server when JSF 2 application can be deployed)
  28. 28. ExadelRichFaces 4 Run on: Google App Engine (GAE), Amazon EC2, CloudBees
  29. 29. ExadelRichFaces 4 JSF implementations: Mojarra or Myfaces
  30. 30. ExadelRichFaces 4 Any browser
  31. 31. ExadelRichFaces 4 Tooling support through JBoss Tools, IntelliJ, NetBeans
  32. 32. ExadelJust tell me when RichFaces 4 is going to be released? RichFaces was released on March 29, 2011 (Yes, finally!)
  33. 33. Exadel RichFaces versions Version JSF 1.1 JSF 1.2 JSF 2RichFaces 3.1.x •RichFaces 3.3.3* • •RichFaces 4 •* Note: RichFaces 3.3.3 has basic JSF 2 support
  34. 34. ExadelRichFaces history2005: started by Alexander Smirnov2005-2007: Developed by Exadel Ajax4jsf - open source, free RichFaces - commercial2007: JBoss takes over Exadel team continues to develop the framework, project is known as RichFaces
  35. 35. ExadelRichFaces 4 Lets look at RichFaces features in more detail...
  36. 36. ExadelRichFaces 4 core – sending an Ajax request● a4j:ajax● a4j:commandButton● a4j:commandLink● a4j:jsFunction● a4j:poll● a4j:push
  37. 37. ExadelRichFaces 4Its important to say it again, RichFaces only extends and upgrades JSF 2...
  38. 38. Exadel 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> <f:ajax execute="@form" render="output"/></h:commandButton><h:commandButton> <a4j:ajax execute="@form" render="output"/></h:commandButton>
  39. 39. Exadel <a4j:ajax> attributes Attribute Descriptiononbegin JavaScript to execute before Ajax request JavaScript to execute after responseonbeforedomupdate comes back but before DOM updateoncomplete JavaScript to execute after DOM update Skips Update Model and InvokebypassUpdates Application phases, useful for form validation Skips all <a4j:outputPanellimitRender ajaxRender=”true”> panels. Only renders what is set in current renderstatus Status to display during Ajax request
  40. 40. Exadel <a4j:commandButton/Link> – Ajax button/link/* standard button with f:ajax */<h:commandButton value="Save" action="#{bean.action}"> <f:ajax execute="@form" render="output"/></h:commandButton>/* RichFaces button */<a4j:commandButton value="Save" render="output" action="#{bean.action}" />
  41. 41. Exadel<h:form> <h:inputText> <h:selectOneMenu> Need to set <h:commandButton> execute=”@form” <f:ajax execute="@form"/> (or execute=”id1 id2”) </h:commandButton><h:form><h:form> RichFaces default <h:inputText> <h:selectOneMenu> value for <a4j:commandButton/> button/link<h:form> execute=”@form”
  42. 42. Exadel <a4j:jsFunction> – fire Ajax request from any JavaScript function, HTML event<table> ... <td onmouseover="update(yellow)"/> ...</table><h:form> <a4j:jsFunction name="update" action="#{bean.change}" render="..."> <a4j:param value="param1" assignTo="#{bean.color}"/> </a4j:jsFunction></h:form>
  43. 43. Exadel <a4j:poll> – periodically send an Ajax request<a4j:poll interval="1000" action="#{bean.count}" render="output" enabled="#{bean.pollEnabled}" /><h:panelGrid id="output">...</h:panelGrid>
  44. 44. Exadel <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" ondataavailable="alert(" />
  45. 45. ExadelRichFace 4 core – advancedrendering features● <a4j:outputPanel>● limitRender attribute● render=”{bean.renderList}”
  46. 46. Exadel <a4j:outputPanel> – auto rendered panel<h:selectOneMenu value="#{bean.fruit}"> <a4j:ajax listener="#{bean.change}"/></<h:selectOneMenu><a4j:outputPanel ajaxRendered="true"> <h:panelGrid> ... </h:panelGrid> Rendered on every</a4j:outputPanel> Ajax request
  47. 47. Exadel Advanced rendering options: limitRender<a4j:commandButton render="output"/><a4j:commandButton render="output" limitRender="true"/><h:panelGrid id="output"> Turns off all auto rendered panels,... only renders what is set in current</h:panelGrid> render<a4j:outputPanel ajaxRendered="true">...</a4j:outputPanel>
  48. 48. Exadel render=”#{bean.renderList}”JSF RichFaces1) Ajax request sent 1) Ajax request sent2) Component ids to be 2) Component ids to rendered resolved be rendered3) Component ids are resolved rendered into the page 3) Component ids4) 2nd Ajax request is sent. are rendered In this request the components (resolved in step 2 are sent with request) will be rendered
  49. 49. ExadelRichFace 4 core – advancedexecute features● <a4j:region>● bypassUpdates attribute
  50. 50. Exadel<a4j:region> – declarativelydefine execute region<h:form> Execute <a4j:region> options: <h:inputText /> ● @all <h:inputText /> ● @this <a4j:commandButton execute="@region"/> ● @form <a4j:region></h:form> ● @none ● ids<h:form> ● EL <a4j:region> ● @region <h:inputText /> <h:inputText /> <a4j:commandButton /> <a4j:region></h:form>
  51. 51. ExadelSkippingphaseswhenvalidating1.Restore View2.Apply Request Values3.Process Validation4.Update Model5.Invoke Application6.Render Response <h:inputText id="name" value="#{}"/> <a4j:ajax event="blur" bypassUpdates="true"/> </h:inputText> <rich:message for="name"/>
  52. 52. Exadel JavaScript interactions<h:commandLink value="Link" <f:ajax onevent="ajaxEvent();"></h:commandLink> Called three times: 1) begin 2) success 3) complete<a4j:commandLink value="Link" onbegin="ajaxOnBegin()" onbeforedomupdate="ajaxOnBeforeDomUpdate()" oncomplete="ajaxOnComplete()"></a4j:commandLink> Events are separated for easier development
  53. 53. ExadelJSF 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
  54. 54. ExadelRichFaces queue upgrades● Combine requests from one or more components● Delay firing Ajax request● Cancel DOM updates if “similar” request was fired● Define queue as: ◦ Global (all views have queue) ◦ View-based ◦ Form-based ◦ Named (used by particular components only)
  55. 55. Exadel <a4j:queue> – “combining” events from the same component<a4j:queue requestDelay="2000"/>…<a4j:commandButton value="Button A1"/><a4j:commandButton value="Button AB"/>Events (clicks) from the same componentare “combined” which results in just one requestfrom a component being sent. Prevents sending multiplerequest from the same component.
  56. 56. Exadel <a4j:queue> – “combining” events from different components<a4j:queue requestDelay="2000"/>...<a4j:commandButton> <a4j:attachQueue requestGroupingId="ajaxGroup"/></a4j:commmandButton><a4j:commandButton> <a4j:attachQueue requestGroupingId="ajaxGroup"/></a4j:commmandButton>
  57. 57. Exadel <a4j:queue> delay<a4j:queue requestDelay="2000"/>... Delay request by 2 seconds<a4j:commandButton value="Button1"/><a4j:commandButton value="Button2"/><a4j:queue requestDelay="2000"/>... Overwrite default<a4j:commandButton> delay request by 1 second <a4j:attachQueue requestDelay="1000"/></a4j:commmandButton><a4j:commandButton />Delay is a “wait” to combine similar events (events from thesame components) together.
  58. 58. Exadel <a4j:queue> – ignoring “stale” responses<a4j:queue requestDelay="2000 ingoreDupResponses="true"/><h:inputText value="#{bean.state}"> <a4j:ajax event="keyup" listener="#{bean.load}" render="states"/></h:inputText>
  59. 59. ExadelRichFace 4 core – moreadvanced features● <a4j:status>● <a4j:param>● <a4j:log>● JavaScript interactions
  60. 60. Exadel <a4j:status> – Ajax request status<a4j:status name="ajaxStatus"> <f:facet name="start"> <h:graphicImage value="ajaxStatus.jpg"/> </f:facet></a4j:status><h:form> <a4j:commandButton status="ajaxStatus"/></h:form>
  61. 61. Exadel <a4j:param> ● Similar to <f:param> but simpler as it also assigns the value to a bean property automatically<a4j:commandButton value="Save"> <a4j:param name="product" value="1009"/></a4j:commandButton>public class Bean { private String product; public void setProduct (String product) {...} public String getProduct () {...}}
  62. 62. Exadel<a4j:log> – Ajax requestinformation● Levels: ◦ debug, info, warn, error
  63. 63. ExadelRichFaces UI components● Output, panels● Input● Menu● Data iteration● Tree● Drag and drop● Client side validation● Miscellaneous
  64. 64. Exadelrich:tabrich:accordionrich:progressBar
  65. 65. ExadelMore rich output, panels● rich:panel● rich:togglePanel● rich:popupPanel● rich:collapsiblePanel● rich:toolTip
  66. 66. Exadelrich:calendarrich:inplaceInputrich:inputNumberSliderrich:autocomplete
  67. 67. ExadelMore rich input● rich:inputNumberSpinner● rich:inplaceSelect● rich:select● rich:fileUpload
  68. 68. Exadelrich:panelMenurich:toolBarrich:dropDownMenu
  69. 69. Exadelrich:dataTablerich:dataTable withrich:collapsibleSubTablerich:dataScroller
  70. 70. Exadel Partial table update render="@column" render="@header"render="@row" render="@body" render="@footer" render="cellId" To render from outside the table: render="tableId@header" render="tableId@body" render="tableId@footer"
  71. 71. Exadel Partial table updaterender="tableId:rows(bean.rowsSet)"render="tableId:rows(bean.rowsSet):cellId"
  72. 72. ExadelMore rich data iteration● a4j:repeat● rich:extendedDataTable● rich:collapsibleSubTable● rich:list ◦ list | ordered | definition● rich:dataGrid● rich:column ◦ Column and row spanning ◦ Filtering, sorting
  73. 73. Exadelrich:tree
  74. 74. ExadelDrag and drop
  75. 75. ExadelClient-side validation based on Bean Validation (JSR 303) New in RichFaces 4
  76. 76. Exadel Bean Validation (JSR 303) ● JSF 2 has support for Bean Validation (server-side)public class Bean { @Pattern(regexp="...") private String email;}<h:inputText id="email" value="#{}"> <a4j:ajax event="blur"/></h:inputText><rich:message for="email"/>
  77. 77. Exadel RichFaces client validation <rich:validator>public class Bean { @Pattern(regexp="...") private String email;}<h:inputText id="email" value="#{}"> <rich:validator/></h:inputText><rich:message for="email"/>
  78. 78. Exadel RichFaces client validation <rich:graphValidator><rich:graphValidator value="#{bean}" id="gv"> ... <h:inputText value="#{bean.password1}"/> <h:inputText value="#{bean.password2}"/> <rich:message for="email" for="gv"/></rich:graphValidator>@Size(min=5,max=15,message="...")private String password1;@Size(min=5,max=15,message="...")private String password2;@AssertTrue(message="Passwords dont match")public boolean isPasswordsEquals() { return password1.equals(password1);}
  79. 79. Exadel RichFaces client functions Function Descriptionrich:client(id) Returns component client idrich:element(id) Returns DOM element Returns RichFaces client componentrich:component(id) instance to call JS API methodrich:isUserInRole(role) Returns if the user has specified role Returns component instance for givenrich:findComponent(id) short id
  80. 80. ExadelMany RichFaces componentsprovide client-side JavaScript API<rich:popupPanel> JavaScript APIMethod name Description Return the top co-ordinate for the position ofgetTop() the pop-up panel. Return the left co-ordinate for the position ofgetLeft() the pop-up panel. Move the pop-up panel to the co-ordinatesmoveTo(top,left) specified with the top and left parameters. Resize the pop-up panel to the size specifiedresize(width,height) with the width and height Show the pop-up panel.hide() Hide the pop-up panel.
  81. 81. Exadel Using <rich:component(id)><input type="button" onclick="#{rich:component(popup)}.show();" value="Open" /><rich:popupPanel id="popup"> <h:outputLink value="#" onclick="#{rich:component(popup)}.hide(); return false;"> <h:outputText value="Close"/> </h:outputLink></rich:popupPanel>
  82. 82. ExadelRich miscellaneous● <rich:componentControl>● <rich:hashParam>● <rich:jQuery>
  83. 83. Exadel <rich:componentControl> ● Allows to call JS API on a component in declarative fashion<h:outputLink id="openLink" value="#"> <h:outputText value="Open" /> <rich:componentControl event="click" operation="show" target="popup" /></h:outputLink><rich:popupPanel id="popup">...</rich:popupPanel>
  84. 84. Exadel <rich:hashParam> ● Group client side parameters into a hash map to be passed to component client API<h:commandButton value="Show popup"> <rich:componentControl target="pp" operation="show"> <rich:hashParam> <f:param name="width" value="500" /> <f:param name="height" value="300" /> <f:param name="minWidth" value="300" /> <f:param name="minHeight" value="150" /> </rich:hashParam> </rich:componentControl></h:commandButton
  85. 85. Exadel <rich:jQuery><input type="button" id="changeButton" value="Change title" /><rich:jQuery selector="#changeButton" query="click(function(){ $(#panel #panel_header).text(Capital of Russia);})"/><rich:panel header="Moscow" id="panel"> Moscow is the capital, the most populous ...</rich:panel>
  86. 86. ExadelSkins
  87. 87. ExadelSkins● 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
  88. 88. ExadelReady-to-use skins● classic <context-param> <param-name></param-name>● wine <param-value>ruby</param-value> </context-param>● blueSky● ruby● emeraldTown● deepMarine● plain● japanCherry
  89. 89. Exadel Skin file (just a property file)#ColorsheaderBackgroundColor=#900000headerGradientColor=#DF5858headerTextColor=#FFFFFFheaderWeightFont=boldgeneralBackgroundColor=#f1f1f1generalTextColor=#000000generalSizeFont=11pxgeneralFamilyFont=Arial, Verdana, sans-serifcontrolTextColor=#000000controlBackgroundColor=#ffffffadditionalBackgroundColor=#F9E4E4
  90. 90. ExadelSkins● Modify existing or create your own <context-param> <param-name></param-name> <param-value>myCoolSkin</param-value> </context-param>● Change skins in runtime <context-param> <param-name></param-name> <param-value>#{}</param-value> </context-param>
  91. 91. Exadel Overwriting skins<style> .rf-p-hr { // your custom style, applied to all panels on // on page } .panelHeader { // custom header style }</style><rich:panel id="panel1">...</rich:panel id="panel2"><rich:panel headerClass="panelHeader">...</rich:panel>
  92. 92. Exadel Skinning standard JSF tags and HTML tagsApply to each control:<h:button style="background-color: #{richSkin.tableBackgroundColor}"/>Apply to all standard controls (JSF and HTML):<context-param> <param-name> org.richfaces.enableControlSkinning </param-name> <param-value>true</param-value></context-param>
  93. 93. Exadel Skinning standard JSF tags and HTML tags<context-param> <param-name> org.richfaces.enableControlSkinningClasses </param-name> <param-value>true</param-value></context-param><div class="rfs-ctn"> <h:panelGrid columns="1"> Can be applied to <h:outputText /> <h:panelGrid>, <rich:panel>, <div> <h:inputText /> Any standard controls inside the <h:commandButton /> container will be skinned using </h:panelGrid> standard controls skinning classes.</div>
  94. 94. Exadel Where can I try the new RichFaces 4?
  95. 95. Exadel 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
  96. 96. ExadelThats it for RichFaces, there is one more thing I want to show you.
  97. 97. ExadelTiggr ( is a webapplication for building andsharing interactive web and mobile HTML prototypes
  98. 98. ExadelPowerful prototyping Build interactiveLarge number of web components, HTML prototypes layout containers and jQuery Define navigation, show pop-ups Mobile components. and other event/actions to make the prototype like the real application. Collaborate View and shareCollaborate with colleagues and the HTML prototype customers in real time, get View prototypes in any browser, feedback. share with anyone, get feedback.
  99. 99. ExadelTry this web prototype: Try this mobile
  100. 100. Exadel max@exadel.comThank @maxkatz you!