JSF and Seam

12,611 views

Published on

JSF & Seam by Roi Aldag from AlphaCSP
www.alphacsp.com

Published in: Business, Technology
1 Comment
14 Likes
Statistics
Notes
No Downloads
Views
Total views
12,611
On SlideShare
0
From Embeds
0
Number of Embeds
5,363
Actions
Shares
0
Downloads
458
Comments
1
Likes
14
Embeds 0
No embeds

No notes for slide
  • JSF and Seam

    1. 2. Java Server Faces adopting the standard Roi Aldaag Consultant, AlphaCSP
    2. 3. Agenda <ul><li>Introduction </li></ul><ul><li>Architecture </li></ul><ul><li>Configuration </li></ul><ul><li>Features </li></ul><ul><li>Pros & Cons </li></ul>
    3. 4. Introduction <ul><li>Not so long ago, if you “Googled“ </li></ul><ul><li>the word JSF , you probably would </li></ul><ul><li>have come across … </li></ul>
    4. 5. Introduction The F-35 J oint S trike F ighter (JSF) …
    5. 6. Introduction <ul><li>Today you’d find… </li></ul>JavaServer Faces Technology
    6. 7. Introduction :: What is JSF? <ul><li>What is JSF ? </li></ul><ul><ul><li>Specification </li></ul></ul><ul><ul><li>UI framework </li></ul></ul><ul><ul><li>Component based </li></ul></ul><ul><ul><li>Server side </li></ul></ul><ul><ul><li>Java web applications </li></ul></ul>
    7. 8. Introduction :: Motivation <ul><li>9 Billion Reasons for JSF… </li></ul>
    8. 9. Introduction :: Motivation <ul><li>JCP Standard </li></ul><ul><ul><li>JSF 1.0/1.1 JSR 127 May 2005 </li></ul></ul><ul><ul><ul><li>JSF 1.2 JSR 252 May 2006 </li></ul></ul></ul><ul><ul><ul><li>JSF 2.0 JSR 314 Q4 2008 ? </li></ul></ul></ul><ul><ul><ul><li>/ JEE6 </li></ul></ul></ul>
    9. 10. Introduction :: Motivation <ul><li>Vendor adoption </li></ul><ul><ul><li>JSF RI </li></ul></ul><ul><ul><li>MyFaces </li></ul></ul>
    10. 11. Introduction :: Motivation <ul><li>Popularity </li></ul><ul><ul><li>Commercial Projects </li></ul></ul><ul><ul><li>Open Source Projects </li></ul></ul><ul><ul><li>Market </li></ul></ul><ul><ul><li>Documentation </li></ul></ul>
    11. 12. Introduction :: Motivation <ul><li>IDE integration </li></ul><ul><ul><li>Visual tool support </li></ul></ul><ul><ul><li>Drag & Drop </li></ul></ul><ul><ul><li>Auto-complete </li></ul></ul>
    12. 13. Introduction :: Motivation <ul><li>Tools </li></ul><ul><ul><li>Component Libraries </li></ul></ul><ul><ul><ul><li>IceFaces </li></ul></ul></ul><ul><ul><ul><li>RichFaces </li></ul></ul></ul><ul><ul><ul><li>ADF / Trinidad </li></ul></ul></ul><ul><ul><ul><li>Tomahawk </li></ul></ul></ul><ul><ul><li>Extensions </li></ul></ul><ul><ul><ul><li>Facelets </li></ul></ul></ul><ul><ul><ul><li>Ajax4Jsf </li></ul></ul></ul><ul><ul><ul><li>DinoFaces </li></ul></ul></ul>
    13. 14. Introduction :: Motivation <ul><li>View Technology </li></ul><ul><ul><li>JSP / Servlet </li></ul></ul><ul><ul><li>Other template engines </li></ul></ul><ul><ul><ul><li>Facelets </li></ul></ul></ul><ul><ul><ul><li>JSFTemplating </li></ul></ul></ul><ul><ul><li>Multiple rendering output from same pages </li></ul></ul>
    14. 15. Introduction :: What is Seam? <ul><li>What is Seam ? </li></ul><ul><ul><li>A lightweight framework for JEE5 </li></ul></ul><ul><ul><li>Unifies JSF and EJB models (Web Beans / JSR 299) </li></ul></ul><ul><ul><li>Integrates JSF, POJOs, JPA, jBMP, Drools </li></ul></ul><ul><ul><li>Annotation / EL based </li></ul></ul><ul><ul><li>Extends JSF </li></ul></ul><ul><ul><li>JBoss OS (LGPL) </li></ul></ul><ul><ul><li>Release at 2006 </li></ul></ul><ul><ul><li>Current version 2.0.2 SP1 </li></ul></ul>
    15. 16. Introduction :: What is Seam? <ul><li>Misconceptions </li></ul><ul><ul><li>Can be used without EJB3 </li></ul></ul><ul><ul><li>Does not need a container </li></ul></ul><ul><ul><li>Has a small footprint </li></ul></ul><ul><ul><li>Easy integration </li></ul></ul>
    16. 17. Introduction :: Why JSF+Seam? <ul><li>Why JSF + Seam? </li></ul><ul><ul><li>JSF has some weaknesses… </li></ul></ul><ul><ul><li>Seam extends and enhances JSF </li></ul></ul><ul><ul><ul><li>Reduces boilerplate code </li></ul></ul></ul><ul><ul><ul><li>Annotations </li></ul></ul></ul><ul><ul><ul><li>RESTful URLs </li></ul></ul></ul><ul><ul><ul><li>JSF Lifecycle </li></ul></ul></ul><ul><ul><ul><li>Contextual state management </li></ul></ul></ul><ul><ul><ul><li>Ajax Remoting </li></ul></ul></ul><ul><ul><ul><li>Exception Handling </li></ul></ul></ul><ul><ul><li>Simple Integration </li></ul></ul><ul><ul><ul><li>EJB3 / jBMP/ Drools / Spring </li></ul></ul></ul>
    17. 18. Introduction :: Seam in action
    18. 19. Agenda <ul><li>Introduction </li></ul><ul><li>Architecture </li></ul><ul><li>Configuration </li></ul><ul><li>Features </li></ul><ul><li>Pros & Cons </li></ul>
    19. 20. Architecture :: JSF MVC <ul><li>Model </li></ul><ul><li>View </li></ul><ul><li>Controller </li></ul>
    20. 21. Architecture :: JSF MVC <ul><li>Model </li></ul><ul><li>POJO’s </li></ul>
    21. 22. Architecture :: JSF MVC <ul><li>Controller </li></ul><ul><li>Front Servlet </li></ul><ul><li>Configuration </li></ul><ul><li>Event Listeners </li></ul>
    22. 23. Architecture :: JSF MVC <ul><li>View </li></ul><ul><li>Component Tree </li></ul><ul><li>Component Model </li></ul><ul><li>Delegates </li></ul><ul><li>Resources </li></ul>
    23. 24. Architecture :: Component Tree ... <f:view> <h:form> <h:panelGrid columns = &quot;2&quot;> <h:inputText/> <h:inputSecret/> </panelGrid> </h:form> </f:view> .. HTML JSP WML XML Markup <ul><ul><li>Component Tree </li></ul></ul>JSF tags
    24. 25. Architecture :: JSF Lifecycle <ul><li>JSF Lifecycle </li></ul><ul><li>Restore view </li></ul><ul><li>Apply request values </li></ul><ul><li>Process validations </li></ul><ul><li>Update model values </li></ul><ul><li>Invoke application </li></ul><ul><li>Render response </li></ul>
    25. 26. Architecture :: Seam Lifecycle <ul><li>Seam Lifecycle </li></ul><ul><li>Restore view </li></ul><ul><li>Restore Conversation </li></ul><ul><li>Apply Page Parameters </li></ul><ul><li>Apply request values </li></ul><ul><li>Process validations </li></ul><ul><li>Update model values </li></ul><ul><li>Invoke application </li></ul><ul><li>Process Selection </li></ul><ul><li>Store Conversation </li></ul><ul><li>Render response </li></ul>
    26. 27. Architecture :: Seam Concepts <ul><li>Seam Concepts </li></ul><ul><li>Three Tier </li></ul><ul><li>POJOs and annotations </li></ul><ul><li>IoC and bijection </li></ul><ul><li>Contextual state management </li></ul><ul><li>Interceptors </li></ul>
    27. 28. Agenda <ul><li>Introduction </li></ul><ul><li>Architecture </li></ul><ul><li>Configuration </li></ul><ul><li>Features </li></ul><ul><li>Pros & Cons </li></ul>
    28. 29. Configuration :: JSF <ul><li>faces-config.xml </li></ul>
    29. 30. Configuration :: Seam <ul><li>faces-config.xml </li></ul>
    30. 31. Configuration :: JSF <ul><li>web.xml </li></ul>
    31. 32. Configuration :: Seam <ul><li>web.xml </li></ul>
    32. 33. Agenda <ul><li>Introduction </li></ul><ul><li>Architecture </li></ul><ul><li>Configuration </li></ul><ul><li>Features </li></ul><ul><li>Pros & Cons </li></ul>
    33. 34. Features :: Demo JSF Project LoginBean.java MasterDetailBean.java jsfLogin.jsp jsfMasterDetail.jsp faces-config.xml web.xml XML XML JSP JSP
    34. 35. Features :: Demo Seam Project LoginBean.java MasterDetailBean.java jsfLogin.jsp jsfMasterDetail.jsp faces-config.xml web.xml XML XML JSP JSP seam.properties jboss-seam.jar jboss-seam-ui.jar components.xml
    35. 36. Features :: Demo Login page jsfLogin.jsp UIViewRoot UIPanel UIOutput UIPanel UIInput UIForm UIOutput UIInput UICommand UIPanel
    36. 37. Features :: JSF Value Binding LoginBean.java jsfLogin.jsp faces-config.xml Unified EL Managed Bean
    37. 38. Features :: JSF Method Binding LoginBean.java jsfLogin.jsp Invoke Application Phase
    38. 39. Features :: JSF State Management jsfLogin.jsp jsfMasterDetail.jsp User Dependency Injection
    39. 40. Features :: Seam State Management <ul><li>Contextual state management </li></ul><ul><ul><li>Bijection </li></ul></ul><ul><ul><ul><li>@In - Injection </li></ul></ul></ul><ul><ul><ul><li>@Out – Outjection </li></ul></ul></ul><ul><ul><ul><li>Dynamic, contextual, bidirectional </li></ul></ul></ul><ul><ul><li>Context Scope </li></ul></ul><ul><ul><ul><li>Event < Page < Conversation < Business Process < Session < Application </li></ul></ul></ul><ul><ul><li>Conversation </li></ul></ul><ul><ul><ul><li>Temporary conversation </li></ul></ul></ul><ul><ul><ul><li>Long-running conversation </li></ul></ul></ul><ul><ul><ul><li>ConversationId </li></ul></ul></ul>
    40. 41. Features :: Seam State Management MasterDetailBean.java
    41. 42. Features :: JSF Page Flow LoginBean.java jsfLogin.jsp jsfMasterDetail.jsp faces-config.xml
    42. 43. Features :: Seam Page Flow <ul><li>Page Actions </li></ul><ul><ul><li>HTTP GET </li></ul></ul><ul><ul><li>Bookmarking </li></ul></ul><ul><ul><li>RESTful URLs </li></ul></ul>HTTP POST HTTP GET
    43. 44. Features :: Seam Page Flow <ul><li>Page Flow </li></ul><ul><ul><li>JBoss Business Process Management (jBPM) </li></ul></ul><ul><ul><li>Used to define process workflow / page flow </li></ul></ul><ul><ul><li>Define transition between pages </li></ul></ul><ul><ul><li>Define navigation rules for each page </li></ul></ul><ul><ul><li>Flow is based on events and conditions </li></ul></ul><ul><li>Back button </li></ul><ul><ul><li>In conversation mode, back button is disallowed </li></ul></ul><ul><ul><li>Undefined transition </li></ul></ul><ul><ul><li>Seam blocks actions from “stale” pages </li></ul></ul><ul><ul><li>Redirects to relevant page </li></ul></ul>
    44. 45. Features :: JSF Validations MasterDetailBean.java jsfMasterDetail.jsp
    45. 46. Features :: Seam Validations jsfMasterDetail.jsp MasterDetailBean.java @org.hibernate.validator.Email
    46. 47. Features :: JSF Error Handling javax.servlet.ServletException: javax/servlet/jsp/tagext/JspIdConsumer
    47. 48. Features :: Seam Error Handling
    48. 49. Features :: Seam Error Handling <ul><li>Exception Annotations </li></ul>
    49. 50. Features :: Demo MasterDetail page jsfMasterDetail.jsp MasterDetailBean.java
    50. 51. Features :: Demo MasterDetail page jsfMasterDetail.jsp - continued HtmlDataTable HtmlColumn HtmlColumn HtmlOutputText HtmlOutputText
    51. 52. Features :: JSF Ajax <ul><li>Ajax: Page Wide </li></ul><ul><ul><li>Page wide support (region, zone) ‏ </li></ul></ul><ul><ul><li>Add support to existing components </li></ul></ul><ul><ul><li>Sub view processing </li></ul></ul><ul><ul><li>Partial tree rendering </li></ul></ul><ul><ul><li>Normal lifecycle </li></ul></ul><ul><ul><li>Partial page refresh </li></ul></ul><ul><ul><li>Example: </li></ul></ul><ul><ul><ul><li>Ajax4Jsf, Dynamic Faces </li></ul></ul></ul>
    52. 53. Features :: JSF Ajax <ul><li>Ajax: Component Wide </li></ul><ul><ul><li>Ajaxified components </li></ul></ul><ul><ul><li>Client validations </li></ul></ul><ul><ul><li>Client component interaction </li></ul></ul><ul><ul><li>Custom lifecycle </li></ul></ul><ul><ul><li>Example: </li></ul></ul><ul><ul><ul><li>RichFaces, IceFaces, ADF (Trinidad) ‏ </li></ul></ul></ul>
    53. 54. Features :: Seam Ajax <ul><li>Ajax Remoting </li></ul><ul><ul><li>Similar to DWR </li></ul></ul><ul><ul><li>Access seam components from JS </li></ul></ul><ul><ul><li>JavaScript APIs </li></ul></ul><ul><ul><ul><li>Seam.Component </li></ul></ul></ul><ul><ul><ul><li>Seam.Remote </li></ul></ul></ul><ul><ul><li>Expose server side components </li></ul></ul><ul><ul><ul><li>@WebRemote </li></ul></ul></ul><ul><ul><li>Compatible with Ajax4Jsf </li></ul></ul><ul><ul><li>Dojo / GWT integration </li></ul></ul>
    54. 55. Features :: Documentation <ul><li>JSF </li></ul><ul><ul><li>Specification </li></ul></ul><ul><ul><li>Forums </li></ul></ul><ul><ul><li>Books </li></ul></ul><ul><li>Seam </li></ul><ul><ul><li>Reference </li></ul></ul><ul><ul><li>Forums </li></ul></ul><ul><ul><li>Books </li></ul></ul>
    55. 56. Agenda <ul><li>Introduction </li></ul><ul><li>Architecture </li></ul><ul><li>Configuration </li></ul><ul><li>Features </li></ul><ul><li>Pros & Cons </li></ul>
    56. 57. Pros & Cons <ul><li>Seam Sweet spots </li></ul><ul><ul><li>Seam Gen (RoR) </li></ul></ul><ul><ul><li>Security (Role / Rule based) </li></ul></ul><ul><ul><li>Spring Integration </li></ul></ul><ul><ul><li>Integrated testing FW (TestNG) </li></ul></ul>
    57. 58. Pros & Cons <ul><li>JSF Shortcomings </li></ul><ul><ul><li>Too much wiring </li></ul></ul><ul><ul><li>HTTP GET / REST is hard </li></ul></ul><ul><ul><li>Complicated Lifecycle </li></ul></ul><ul><ul><li>Slow learning curve </li></ul></ul><ul><ul><li>Writing new components </li></ul></ul><ul><ul><li>Poor exception handling </li></ul></ul>
    58. 59. References <ul><li>JSF </li></ul><ul><ul><li>http://www.jcp.org/en/jsr/detail?id=252 </li></ul></ul><ul><ul><li>http://jcp.org/en/jsr/detail?id=314 </li></ul></ul><ul><ul><li>http://myfaces.apache.org/ </li></ul></ul><ul><li>Seam </li></ul><ul><ul><li>http://www.jboss.com/products/seam </li></ul></ul><ul><ul><li>http://www.seamframework.org/ </li></ul></ul>
    59. 60. <ul><li>Thank </li></ul><ul><li>You ! </li></ul>

    ×