www.icefaces.org
ICEfaces is…
ICEfaces is an Ajax framework that allows developers to easily
create rich Internet applications (RIA) in pur...
Agenda

 • Ajax Push Overview
 • Application Programming Basics
 • On the Wire
 • Code Walkthrough
 • Asynchronous Request...
Multi-user AuctionMonitor




                            www.icefaces.org
Multi-user AuctionMonitor




                            www.icefaces.org
Multi-user AuctionMonitor




                            www.icefaces.org
Multi-user Locking




                            Ted selects
                            record for
                    ...
Multi-user Locking




                            Joe selects
                            same record,
                  ...
Multi-user Locking




                            Ted responds,
                            and accepts
                 ...
Push in Portlets




                                 Portal page
                                 with three
            ...
Push in Portlets




                                Joe searches
                                for a city




         ...
Push in Portlets




                                 All three
                                 portlets are
            ...
Ajax Push Illustrated




           Ted




                        Server




           Deryk


                       ...
Ajax Push Illustrated




                         Ajax
                        Request
           Ted




               ...
Ajax Push Illustrated




                        JSF Lifecycle +
                           DOM diff
           Ted




 ...
Ajax Push Illustrated




                          Ajax
                        Response
           Ted




             ...
What is Ajax Push For?

•   Distance learning
•   Collaborative authoring
•   Auctions
•   Shared WebDAV filesystem
•   Bl...
Ajax Programming, Ideally.


          PageBean.java                            Page.xhtml
                               ...
Ajax Push Programming




 To keep track of groups of users:
 SessionRenderer.addCurrentSession(“GlassFishTV”);



 Asynch...
Ajax Push Techniques

 • Poll
    – send a request to the server
      at some interval
    – response is “empty” if there...
Long Polling over HTTP
 GET /auctionMonitor/block/receive-updates?icefacesID=1209765435 HTTP/1.1
 Accept: */*
 Cookie: JSE...
Long Polling over HTTP
 GET /auctionMonitor/block/receive-updates?icefacesID=1209765435 HTTP/1.1
 Accept: */*
 Cookie: JSE...
Long Polling over HTTP
 GET /auctionMonitor/block/receive-updates?icefacesID=1209765435 HTTP/1.1
 Accept: */*
 Cookie: JSE...
webmc.jspx
 <f:view xmlns:f=quot;http://java.sun.com/jsf/corequot;
          xmlns:h=quot;http://java.sun.com/jsf/htmlquot...
UserBean.java
    public class UserBean {

        public String getSlideURL() {
                                         ...
UserBean.java (Ajax Push)

import com.icesoft.faces.async.render.SessionRenderer;

public class UserBean {
    String pres...
Ajax Components with ICEfaces


 • Automatic Ajax updates
 • No JavaScript Development
 • Easy Ajax Component Suite
    – ...
A Thread for Every Client?




• Blocking requests with Servlet 2.5 consumes threads

• GlassFish/Grizzly, Tomcat 6, Jetty...
GlassFish
 Suspend with Grizzly.
      CometContext context =
          CometEngine.getEngine().register(contextPath);
   ...
Multiple Applications and Browser Connection Limits
                 http:// host / ajaxpush /




                       ...
Security for Ajax Push

 • Build security in layers
    – Java
    – JavaServer Faces
    – SSL

 • Script injection
    –...
Custom Components (JSF 1.2)


 • Implement MyComponent.java extending UIInput

 • Implement MyComponentRenderer.java

 • I...
Facelets in JSF 2

  • Facelets now part of JSF standard
  • Also know as the Page Declaration Language (PDL)‫‏‬
  • First...
Custom Components in JSF 2

 • Components built via markup templates
 • Also known as composite components
 • Composite Co...
Custom Components in JSF 2 (Use)




                                   www.icefaces.org
Custom Components in JSF 2 (Definition)




                                 www.icefaces.org
Ajax in JSF 2.0

  • Resource Delivery Mechanism
  • Partial View Processing
  • Partial View Rendering
  • Ajax Client/Se...
Ajax in JSF 2

Partial View Processing
 Ajax Request
 execute:4,5
                               Apply Request            ...
Ajax in JSF 2

Partial View Rendering
 Ajax Request
 render:4,5
                                 Apply Request            ...
Ajax in JSF 2
  • Standard JavaScript API
     – jsf.ajax.request, jsf.ajax.response
     – jsf.ajax.addOnError, jsf.ajax....
Enhancements in JSF 2
 • System Events
    – Represent specific points in time for a JSF application
    – For example, li...
Enhancements in JSF 2
 • Resources
    – Facility for serving resources (CSS, JavaScript, images, etc..)‫‏‬
    – Can be p...
Summary
The Asynchronous Web Revolution is Now
   • Ajax Push will revolutionize human interaction

   • Ajax Push is the ...
Thank You




            Contact Us:
            Toll Free: +1 877 263 3822 USA
            International: +1 403 663 332...
Upcoming SlideShare
Loading in …5
×

ICEfaces and JSF 2.0 on GlassFish

9,920 views

Published on

In depth presentation on ICEfaces/JSF on GlassFish. Also includes how to JSF 2.0 will apply to ICEfaces

Published in: Technology
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
9,920
On SlideShare
0
From Embeds
0
Number of Embeds
83
Actions
Shares
0
Downloads
353
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

ICEfaces and JSF 2.0 on GlassFish

  1. 1. www.icefaces.org
  2. 2. ICEfaces is… ICEfaces is an Ajax framework that allows developers to easily create rich Internet applications (RIA) in pure Java. • Open source • Standards-based • Extends JavaServer Faces • Develop rich Web Applications in pure Java, not JavaScript • Integrated with GlassFish and Friends – Provides NetBeans IDE Plugin • Endorsed migration for Woodstock users – Supports Ajax Push applications via Grizzly – Leverages enterprise capabilities of GlassFish • Security, Scalability: Clustering, Load Balancing and Failover – Integrates with 3rd Party frameworks and middleware • WebSpace, WebStack Easy Ajax for Java developers www.icefaces.org
  3. 3. Agenda • Ajax Push Overview • Application Programming Basics • On the Wire • Code Walkthrough • Asynchronous Request Processing • Security • Custom Components (JSF 1.2 and JSF 2.0) • JSF 2.0 Ajax • JSF 2.0 Notable Enhancements • Summary www.icefaces.org
  4. 4. Multi-user AuctionMonitor www.icefaces.org
  5. 5. Multi-user AuctionMonitor www.icefaces.org
  6. 6. Multi-user AuctionMonitor www.icefaces.org
  7. 7. Multi-user Locking Ted selects record for editing www.icefaces.org
  8. 8. Multi-user Locking Joe selects same record, requests lock www.icefaces.org
  9. 9. Multi-user Locking Ted responds, and accepts or denies www.icefaces.org
  10. 10. Push in Portlets Portal page with three portlets www.icefaces.org
  11. 11. Push in Portlets Joe searches for a city www.icefaces.org
  12. 12. Push in Portlets All three portlets are updated www.icefaces.org
  13. 13. Ajax Push Illustrated Ted Server Deryk www.icefaces.org
  14. 14. Ajax Push Illustrated Ajax Request Ted Server Deryk www.icefaces.org
  15. 15. Ajax Push Illustrated JSF Lifecycle + DOM diff Ted Server Deryk www.icefaces.org
  16. 16. Ajax Push Illustrated Ajax Response Ted Server Ajax Push Deryk www.icefaces.org
  17. 17. What is Ajax Push For? • Distance learning • Collaborative authoring • Auctions • Shared WebDAV filesystem • Blogging and reader comments • SIP-coordinated mobile applications • Hybrid chat/email/discussion forums • Customer assistance on sales/support pages • Multi-step business process made collaborative • Shared trip planner or restaurant selector with maps • Shared calendar, “to do” list, project plan • Games • Enterprise shared record locking and negotiation www.icefaces.org
  18. 18. Ajax Programming, Ideally. PageBean.java Page.xhtml <f:view public class PageBean { xmlns:f=“http://java.sun.com/jsf/core” String message; xmlns:h=quot;http://java.sun.com/jsf/html“ > public String getMessage() { <html> return message; <body> } <h:form> <h:inputText public void value=“#{pageBean.message}” /> setMessage(String message) { </h:form> this.message = message; </body> } </html> } </f:view> Presentation Model Declarative User Interface www.icefaces.org
  19. 19. Ajax Push Programming To keep track of groups of users: SessionRenderer.addCurrentSession(“GlassFishTV”); Asynchronously and elsewhere in the application ... presentation.setSlide(7); SessionRenderer.render(“GlassFishTV”); www.icefaces.org
  20. 20. Ajax Push Techniques • Poll – send a request to the server at some interval – response is “empty” if there is no update • Http Streaming – send a request and wait for response – write “endless” response in chunks • Long Poll – send a request to the server and wait for response – indistinguishable from “slow” server www.icefaces.org
  21. 21. Long Polling over HTTP GET /auctionMonitor/block/receive-updates?icefacesID=1209765435 HTTP/1.1 Accept: */* Cookie: JSESSIONID=75CF2BF3E03F0F9C6D2E8EFE1A6884F4 Connection: keep-alive Host: vorlon.ice:18080 www.icefaces.org
  22. 22. Long Polling over HTTP GET /auctionMonitor/block/receive-updates?icefacesID=1209765435 HTTP/1.1 Accept: */* Cookie: JSESSIONID=75CF2BF3E03F0F9C6D2E8EFE1A6884F4 Connection: keep-alive Host: vorlon.ice:18080 Chat message “Howdy” www.icefaces.org
  23. 23. Long Polling over HTTP GET /auctionMonitor/block/receive-updates?icefacesID=1209765435 HTTP/1.1 Accept: */* Cookie: JSESSIONID=75CF2BF3E03F0F9C6D2E8EFE1A6884F4 Connection: keep-alive Host: vorlon.ice:18080 Chat message “Howdy” HTTP/1.1 200 OK Content-Type: text/xml;charset=UTF-8 Content-Length: 180 Date: Tue, 10 Mar 2009 22:49:49 GMT Server: Sun Java System Application Server 9.1_01 <updates> <update address=quot;_id0:_id5:0:chatTextquot;> <span id=quot;_id0:_id5:0:chatTextquot;>Howdy</span> </update> </updates> www.icefaces.org
  24. 24. webmc.jspx <f:view xmlns:f=quot;http://java.sun.com/jsf/corequot; xmlns:h=quot;http://java.sun.com/jsf/htmlquot;> <html> <head> <title>WebMC</title> </head> <body> <h3>WebMC</h3> <h:form> <h:panelGrid columns=quot;1quot;> <h:outputText value=quot;Presentationquot;/> <h:graphicImage value=quot;#{user.slideURL}quot;/> </h:panelGrid> <h:panelGrid columns=quot;1quot; > <h:outputText value=quot;Chatquot;/> <h:outputText value=quot;#{user.chatLog}quot;/> <h:inputText value=quot;#{user.chatInput}quot;/> <h:commandButton actionListener=quot;#{user.submit}quot;/> </h:panelGrid> www.icefaces.org
  25. 25. UserBean.java public class UserBean { public String getSlideURL() { Set by presentation moderator return slideURL; slide controls } public String getChatLog() { return chatLog; } public String getChatInput() { return chatInput; } public void setChatInput(String text) { chatInput = text; append(chatLog, text); } } www.icefaces.org
  26. 26. UserBean.java (Ajax Push) import com.icesoft.faces.async.render.SessionRenderer; public class UserBean { String presentationName; public UserBean() { presentationName = LoginBean.getPresentationName(); SessionRenderer.addCurrentSession(presentationName); } public void submit() { SessionRenderer.render(presentationName); } } www.icefaces.org
  27. 27. Ajax Components with ICEfaces • Automatic Ajax updates • No JavaScript Development • Easy Ajax Component Suite – No JavaScript component wiring – No manually defined update regions • Ajax transport handled by ICEfaces • Woodstock conversion: utilities and compatible components • --- – Asynchronous application-driven browser updates – All 50+ components are Ajax Push aware www.icefaces.org
  28. 28. A Thread for Every Client? • Blocking requests with Servlet 2.5 consumes threads • GlassFish/Grizzly, Tomcat 6, Jetty, and Servlet 3.0 provide asynchronous request processing • Many connections handled with a small thread pool www.icefaces.org
  29. 29. GlassFish Suspend with Grizzly. CometContext context = CometEngine.getEngine().register(contextPath); context.setExpirationDelay(20 * 1000); SuspendableHandler handler = new SuspendableHandler(); handler.attach(response); cometContext.addCometHandler(handler); class SuspendableHandler implements CometHandler { public void onEvent(CometEvent event) { response.getWriter().println(event.attachment()); cometContext.resumeCometHandler(this); } Asynchronously and elsewhere in the application ... presentation.setSlide(7); cometContext.notify(message); www.icefaces.org
  30. 30. Multiple Applications and Browser Connection Limits http:// host / ajaxpush / Asynchronous Connections Glassfish Grizzly Ajax Push Server ICEfaces ICEfaces JMS Application Application www.icefaces.org
  31. 31. Security for Ajax Push • Build security in layers – Java – JavaServer Faces – SSL • Script injection – JavaScript – SQL • Cross-site request forgery • Cross-site scripting www.icefaces.org
  32. 32. Custom Components (JSF 1.2) • Implement MyComponent.java extending UIInput • Implement MyComponentRenderer.java • Implement MyComponentTag.java • Add component and renderer to faces-config.xml • Add MyComponentTag to TLD www.icefaces.org
  33. 33. Facelets in JSF 2 • Facelets now part of JSF standard • Also know as the Page Declaration Language (PDL)‫‏‬ • First non-JSP PDL designed for JSF • Some differences from JSP: – Pages compiled to abstract structure – Builds JSF component view when executed – Don't need TLD for tag attributes – Page templating • Opens the door for easier component development www.icefaces.org
  34. 34. Custom Components in JSF 2 • Components built via markup templates • Also known as composite components • Composite Component: any Facelet markup file that resides in a resource library • Custom components can also be developed in Java as per JSF 1.2 www.icefaces.org
  35. 35. Custom Components in JSF 2 (Use) www.icefaces.org
  36. 36. Custom Components in JSF 2 (Definition) www.icefaces.org
  37. 37. Ajax in JSF 2.0 • Resource Delivery Mechanism • Partial View Processing • Partial View Rendering • Ajax Client/Server In JSF 2.0 Spec In Component Library • Ajax Enabled Components www.icefaces.org
  38. 38. Ajax in JSF 2 Partial View Processing Ajax Request execute:4,5 Apply Request Process Restore View Validations Values Render Invoke Update Model 1 Response Application Values 2 3 Execute Portion 4 5 www.icefaces.org
  39. 39. Ajax in JSF 2 Partial View Rendering Ajax Request render:4,5 Apply Request Process Restore View Validations Values Render Invoke Update Model 1 Response Application Values 2 3 Render Portion 4 5 www.icefaces.org
  40. 40. Ajax in JSF 2 • Standard JavaScript API – jsf.ajax.request, jsf.ajax.response – jsf.ajax.addOnError, jsf.ajax.addOnEvent – jsf.getProjectStage, jsf.getViewState • Standard Response Format – XML based – “instruction set” for: – updating DOM, attribute changes, script execution – inserting into DOM, deleting DOM nodes, extensions • Standard Subtree Execution and Rendering – frameworks may also plug in their own traversal strategy • Declarative Ajax (f:ajax)‫‏‬ • Net result is Ajax component interoperability www.icefaces.org
  41. 41. Enhancements in JSF 2 • System Events – Represent specific points in time for a JSF application – For example, listen for: – when a component was added to parent – when a component is about to be rendered – Listeners implement javax.faces.event.SystemEventListener • “view” scope – allows attributes to be associated with a view – attributes persist until a new view is navigated to – can be accessed via EL (like request or session)‫‏‬ • Annotations – An alternative to XML configuration – @FacesComponent, @FacesConverter, @ManagedBean – @RequestScoped, @SessionScoped, @ApplicationScoped www.icefaces.org
  42. 42. Enhancements in JSF 2 • Resources – Facility for serving resources (CSS, JavaScript, images, etc..)‫‏‬ – Can be packaged under web application – Under “resources” directory – Or into classpath under META-INF/resources – Typically reside in libraries – Resources can be versioned • Exceptions – Exception handling facility allows queuing of exceptions – Also leverages System Event facility – publish ExceptionEvent(s); subscribe to ExceptionEvent(s)‫‏‬ www.icefaces.org
  43. 43. Summary The Asynchronous Web Revolution is Now • Ajax Push will revolutionize human interaction • Ajax Push is the key to enterprise collaboration for the Web • JSF 2.0 is the language for developing web applications • Ajax Push can scale on GlassFish with Asynchronous Request Processing • ICEfaces provides the high-level capabilities for enterprise collaboration features in your application www.icefaces.org www.icefaces.org ICESOFT TECHNOLOGIES INC.
  44. 44. Thank You Contact Us: Toll Free: +1 877 263 3822 USA International: +1 403 663 3322 product.support@icesoft.com www.icefaces.org 44

×