SlideShare una empresa de Scribd logo
1 de 37
Descargar para leer sin conexión
Web 2.0 and AJAX

Jim Driscoll
Manager, Java Web Tier
Agenda                              JGD




• Definitions: Web 2.0, AJAX
 > Wikis, RSS/Blogs, and REST
 > AJAX Overview
• Guidelines
• JSF Approach
• AJAX BluePrints




                                2
A Little Web History                         JGD




•   CGI / Perl & C
•   Servlets
•   JSP / ASP / PHP
•   Other scripting
    > Python, Ruby
• Java based web frameworks
    > Struts, JSF, (many) others
• Scripting based frameworks
• But all these kept the same (1.0) UI

                                         3
Web 2.0 by example                                          JGD




•   DoubleClick              •   Google AdSense
•   Ofoto                    •   Flickr
•   Britannica Online        •   Wikipedia
•   mp3.com                  •   Napster
•   Personal websites        •   Blogging
•   Directories (Taxonomy)   •   Tagging (Folksonomy)
•   Screen Scraping          •   Web Services


                                                        4
Web 2.0 Definition – by Tim O'Reilly                JGD




• Web as a Platform
• Collective Intelligence
  > Folksonomy – Collaborative Categorization
• Data is key and should be shared
• Software is in constantly evolving
  > Software release cycles dead?
• Lightweight Programming Models
  > SOAP/REST
• The Network is the computer
  > (iTunes, mobile devices)
• Rich User Experience
                                                5
So what is Web 2.0?                                           JGD




• Fuzzy Term, as popularized by O'Reilly...
  > ... some negative reaction (“obvious marketing
    fluff”)
  > ... but trying to capture a real qualitative change
  > ... featured recently in Time and Business Week
• Technologies
  > Blogging, Syndication, RSS/Atom
  > Wikis, Web Services (REST)
  > AJAX, Rich Internet Clients
• Attitudes
  > Sharing, Connected, Participatory
  > Services, Perpetual Beta, Users Engaged
                                                          6
What is Web 2.0? (cont.)                           JGD




• Services
  >   Flickr, BitTorrent, iTunes
  >   Maps (Yahoo, Google), Wikipedia
  >   Gmail, AdSense
  >   Yahoo & Google Services
• Drivers
  > Faster Connectivity
  > More Available Connectivity, esp at home
  > More Powerful Machines
  > Customers More Comfortable with
    Technology
  > Browser wars (mostly) over
                                               7
Blogs / RSS / Atom                                   JGD




 • RSS – Really Simple Syndication
   > A number of (not fully compatible) specs
   > Atom is latest, IETF, Standard
 • Provide Syndicated Information through HTTP
 • Blogs build on RSS/Atom
   > Aggregation, Content Reuse, Caching
 • Strong Social Phenomenon (e.g. politics)
 • Rome – a popular RSS/Atom library
 • Roller – Apache project donated by Sun
   > Runs on AS 9
 • Blogs.sun.com
                                                 8
Wikis / Collaboration                                  JGD




  • Wikis are...
    > Simplified Web sites (Management, Content)
    > Collaboratively Created Web Sites
  • Example: Wikipedia (uses MediaWiki)
  • Java Wiki: JSPWiki (many others)
  • Portal Server 7.0
    > Uses JSP Wiki
    > Focused on Collaboration



                                                   9
REST                                             JGD




 • Web 2.0 delivers Services over the Web
 • Pretty much all seems to be over REST
  > HTTP + typed XML content
  > (or JSON)
 • JAX-WS 2.0 provides some support
  > More is needed
  > WSDL is an imperfect match




                                            10
Conventional Rich Web Applications        JGD




•   Plugins/Applets
•   Frames/ iframes
•   Dumb browser
•   Server Centric
•   Page to Page navigation based




                                     11
Conventional Interaction Model        JGD




                                 12
High Level AJAX Interaction Model        JGD




                                    13
AJAX                                         JGD




Asynchronous JavaScript + XML
AJAX is using JavaScript, namely the
XmlHttpRequest object, to communicate
asynchronously with a server-side
component and dynamically update the
source of an HTML page based on the
resulting XML/Text response.




                                        14
Anatomy of an AJAX Interaction        JGD




                                 15
HTML Page Event                                                                  JGD




<form name=quot;autofillformquot; action=quot;autocompletequot; method=quot;getquot;>
 <table border=quot;0quot; cellpadding=quot;5quot; cellspacing=quot;0quot;>
    <tr><td><b>Employee Name:</b></td><td>
       <input type=quot;textquot; id=quot;complete-fieldquot; size=quot;20quot;
                 autocomplete=quot;offquot;
                 onkeyup=quot;doCompletion();quot;>
     </td><td align=quot;leftquot;>
       <input id=quot;submit_btnquot; type=quot;Submitquot; value=quot;Lookup Employeequot;>
     </td></tr>
    <tr><td id=quot;auto-rowquot; colspan=quot;2quot;>&nbsp;<td/></tr>
  </table>
</form>
<div style=quot;position: absolute; top:170px;left:140pxquot; id=quot;menu-popupquot;>
 <table id=quot;completeTablequot; border=quot;1quot; bordercolor=quot;blackquot; cellpadding=quot;0quot;
cellspacing=quot;0quot; />
</div>




                                                                            16
JavaScript Event Handler                                      JGD




function getXHR() {
    if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        return new ActiveXObject(quot;Microsoft.XMLHTTPquot;);
    }
}

function doCompletion() {
    var url = quot;autocomplete?action=complete&id=quot; +
encodeURI(target.value);
    var req = getXHR();
    req.onreadystatechange = processRequest;
    req.open(quot;GETquot;, url, true);
    req.send(null);
}




                                                         17
Servlet                                                                                         JGD




public   void doGet(HttpServletRequest request, HttpServletResponse   response)
             throws IOException, ServletException {
    String targetId = request.getParameter(quot;idquot;);
    Iterator it = employees.keySet().iterator();
    while (it.hasNext()) {
        EmployeeBean e = (EmployeeBean)employees.get((String)it.next());
        if ((e.getFirstName().toLowerCase().startsWith(targetId) ||
            e.getLastName().toLowerCase().startsWith(targetId)) && !targetId.equals(quot;quot;))   {
            sb.append(quot;<employee>quot;);
            sb.append(quot;<id>quot; + e.getId() + quot;</id>quot;);
            sb.append(quot;<firstName>quot; + e.getFirstName() + quot;</firstName>quot;);
            sb.append(quot;<lastName>quot; + e.getLastName() + quot;</lastName>quot;);
            sb.append(quot;</employee>quot;);
            namesAdded = true;
        } }
    if (namesAdded) {
         response.setContentType(quot;text/xmlquot;);
         response.setHeader(quot;Cache-Controlquot;, quot;no-cachequot;);
        response.getWriter().write(quot;<employees>quot; + sb.toString() + quot;</employees>quot;);
    } else response.setStatus(HttpServletResponse.SC_NO_CONTENT);
}




                                                                                               18
JavaScript Client Callback                                                  JGD




function postProcess(responseXML) {
    clearTable();
   var employees = responseXML.getElementsByTagName(quot;employeesquot;)[0];
    if (employees.childNodes.length > 0) {
        completeTable.setAttribute(quot;bordercolorquot;, quot;blackquot;);
        completeTable.setAttribute(quot;borderquot;, quot;1quot;);
    } else {
        clearTable();
    }
    for (loop = 0; loop < employees.childNodes.length; loop++) {
       var employee = employees.childNodes[loop];
        var firstName = employee.getElementsByTagName(quot;firstNamequot;)[0];
        var lastName = employee.getElementsByTagName(quot;lastNamequot;)[0];
        var employeeId = employee.getElementsByTagName(quot;idquot;)[0];
     appendEmployee(firstName.childNodes[0].nodeValue,
lastName.childNodes[0].nodeValue, employeeId.childNodes[0].nodeValue);
    }
}




                                                                         19
Agenda                                                JGD




• Definitions: Web 2.0, Rich Web Applications,
  AJAX
• Guidelines
• JSF Approach
• AJAX BluePrints




                                                 20
AJAX Guidelines                 JGD




•   JavaScript Libraries
•   Usability Issues
•   AJAX Design
•   HTTP methods
•   Security
•   Desktop and AJAX




                           21
JavaScript Libraries                                                             JGD




•    Prototype
•    RICO
•    Script.aculo.us
•    Dojo
•    Zimbra



    Recommendation: Adopt a library and don't try to re-invent the wheel.

                                                                            22
Usability                                                         JGD




•   Back/Forward/Refresh Buttons
•   Bookmarking
•   URL Sharing
•   Printing
•   508 Compliance
•   Fallback Strategies
•   Remember <blink>?

Recommendation: Consider the meaning of each and weigh the
benefits when designing your application.
                                                             23
XMLHttpRequest (XHR)                                                     JGD




 • HTTP Method
    > GET - When the result of N > 0 requests is the
      same.
    > POST - When operation has “side-effects” and
      changes the state on the server.
 • Concurrent Requests
    > Max is 2 (IE) Consider - Pooling
    > JavaScript Closures – Inline functions


Recommendation: Take care using the XHR. Use Closures to track the
requests/callbacks. Consider using a library.

                                                                     24
AJAX Design                                                                   JGD




 • Add Around the Edges
    > Small components (autocomplete, tree, partial
      submit)
 • Page is the Application
    > Client and Server split MVC responsibilities




Recommendation: Consider designing initial AJAX applications around the
edges as you gain experience. Don't go overboard.

                                                                          25
Response Content Type                                                          JGD




 • XML
 • HTML
 • Text
    > Post processing on client
    > Inject directly into the page
 • JavaScript
    > Evaluated in JavaScript using eval()
    > JavaScript object representations of data(JSON)


Recommendation: Use XML for structured portable data. Use plain text for
when injecting content into the HTML. Use JavaScript to return object
representations data.
                                                                           26
Security                                                            JGD




 • Sandboxed
    > Cross Domain XMLHttpRequest restricted
    > Access to file system restricted
 • HTTPS – Requires a page refresh
 • JavaScript Libraries for Encryption Exist
 • JavaScript code visible to the world



Recommendation: Use HTTPS when you want to secure AJAX
communication. Don't put compromising code in your JavaScript

                                                                27
Desktop and AJAX                                            JGD




• AJAX is best for
  > Internet deployments (no separate runtime)
  > Frequently updated, data intensive service apps
  > Certain kinds of UI methods (HTML & CSS centric)
• Swing (with or without Java Webstart) is
  best for
  >   Disconnected / High Latency use
  >   Computationally intensive apps
  >   Very rich GUI needs
  >   When you need a mature environment NOW


      Recommendation: Use the right tool for the job

                                                       28
Agenda                                                JGD




• Definitions: Web 2.0, Rich Web Applications,
  AJAX
• Guidelines
• JSF Approach
• AJAX BluePrints




                                                 29
JSF Component Approach                               JGD




    Benefits Include:

•   Control Content Rendering
•   Control of Server Side Logic
•   All in one component
•   Reusable
•   Usable in a tool
•   Hide AJAX complexity from page developers

                                                30
Anatomy of an AJAX enabled JSF        JGD




Component




                                 31
Page Developer's View of JSF Component        JGD




 <ajaxTags:completionField
   size=quot;40quot; id=quot;cityFieldquot;
   completionMethod=quot;
     #{ApplicationBean.completeName}quot;
 />




                                         32
Server Side Logic for JSF Component                                   JGD




public String[] completeName() {
  ArrayList results = new ArrayList();
  Iterator it = employees.keySet().iterator();
  while (it.hasNext()) {
  EmployeeBean e = (EmployeeBean)employees.get((String)it.next());
  if ((e.getFirstName().toLowerCase().startsWith(targetId) ||
        e.getLastName().toLowerCase().startsWith(targetId)) &&
        !targetId.equals(quot;quot;)) {

        results.add(e.getId() + quot; quot; +
                  e.getFirstName() +
                  e.getLastName());
         }
    }
    return (String[])results.toArray();
}




                                                                     33
Agenda                                                JGD




• Definitions: Web 2.0, Rich Web Applications,
  AJAX
• Guidelines
• JSF Approach
• AJAX BluePrints




                                                 34
AJAX BluePrints                                                 JGD




• BluePrints Solutions Catalog Entries on AJAX
 > For both NetBeans and command line
 > Written for GlassFish (http://glassfish.dev.java.net)
 > More entries posted all the time
• Java Petstore Demo
 > Will be released at JavaOne
• Blueprints AJAX components
 > Google Maps, Paypal
 > Autocomplete, Ratings, File Upload
 > Usable in Java Studio Creator, included in updates


                                                           35
Resources                                            JGD




• BluePrints AJAX Page:
  http://java.sun.com/blueprints/ajax.html
• AJAX FAQ for the Java Developer
 http://blueprints.dev.java.net/ajax-faq.html




                                                36
jim.driscoll@sun.com

Más contenido relacionado

Destacado

20 SEP 13 - 20th EN BDE ORG DAY
20 SEP 13 - 20th EN BDE ORG DAY20 SEP 13 - 20th EN BDE ORG DAY
20 SEP 13 - 20th EN BDE ORG DAY20ENGBDE
 
Cumberland County Easter Events
Cumberland County Easter EventsCumberland County Easter Events
Cumberland County Easter Events20ENGBDE
 
HACER NEGOCIO EN INTENET
HACER NEGOCIO EN INTENETHACER NEGOCIO EN INTENET
HACER NEGOCIO EN INTENETADON189
 
OpenAjax Alliance: Driving Ajax Standards and Interoperability
OpenAjax Alliance: Driving Ajax Standards and InteroperabilityOpenAjax Alliance: Driving Ajax Standards and Interoperability
OpenAjax Alliance: Driving Ajax Standards and Interoperabilityelliando dias
 
реляционная база Access
реляционная база Accessреляционная база Access
реляционная база AccessVladimir Burdaev
 

Destacado (6)

Deployment de Rails
Deployment de RailsDeployment de Rails
Deployment de Rails
 
20 SEP 13 - 20th EN BDE ORG DAY
20 SEP 13 - 20th EN BDE ORG DAY20 SEP 13 - 20th EN BDE ORG DAY
20 SEP 13 - 20th EN BDE ORG DAY
 
Cumberland County Easter Events
Cumberland County Easter EventsCumberland County Easter Events
Cumberland County Easter Events
 
HACER NEGOCIO EN INTENET
HACER NEGOCIO EN INTENETHACER NEGOCIO EN INTENET
HACER NEGOCIO EN INTENET
 
OpenAjax Alliance: Driving Ajax Standards and Interoperability
OpenAjax Alliance: Driving Ajax Standards and InteroperabilityOpenAjax Alliance: Driving Ajax Standards and Interoperability
OpenAjax Alliance: Driving Ajax Standards and Interoperability
 
реляционная база Access
реляционная база Accessреляционная база Access
реляционная база Access
 

Similar a Web 2.0 And Ajax

Google G Data Reading And Writing Data On The Web
Google G Data Reading And Writing Data On The WebGoogle G Data Reading And Writing Data On The Web
Google G Data Reading And Writing Data On The WebQConLondon2008
 
Google G Data Reading And Writing Data On The Web 1
Google G Data Reading And Writing Data On The Web 1Google G Data Reading And Writing Data On The Web 1
Google G Data Reading And Writing Data On The Web 1QConLondon2008
 
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008Association Paris-Web
 
IPhone Web Development With Grails from CodeMash 2009
IPhone Web Development With Grails from CodeMash 2009IPhone Web Development With Grails from CodeMash 2009
IPhone Web Development With Grails from CodeMash 2009Christopher Judd
 
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies
Rob Tweed :: Ajax and the Impact on Caché and Similar TechnologiesRob Tweed :: Ajax and the Impact on Caché and Similar Technologies
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologiesgeorge.james
 
GTLAB Installation Tutorial for SciDAC 2009
GTLAB Installation Tutorial for SciDAC 2009GTLAB Installation Tutorial for SciDAC 2009
GTLAB Installation Tutorial for SciDAC 2009marpierc
 
Frank Mantek Google G Data
Frank Mantek Google G DataFrank Mantek Google G Data
Frank Mantek Google G Datadeimos
 
JavaScript Library Overview
JavaScript Library OverviewJavaScript Library Overview
JavaScript Library Overviewjeresig
 
Grails Introduction - IJTC 2007
Grails Introduction - IJTC 2007Grails Introduction - IJTC 2007
Grails Introduction - IJTC 2007Guillaume Laforge
 
JavaScript Libraries (@Media)
JavaScript Libraries (@Media)JavaScript Libraries (@Media)
JavaScript Libraries (@Media)jeresig
 
2009 Java One State Of The Open Web
2009 Java One State Of The Open Web2009 Java One State Of The Open Web
2009 Java One State Of The Open WebPatrick Chanezon
 
GWT + Gears : The browser is the platform
GWT + Gears : The browser is the platformGWT + Gears : The browser is the platform
GWT + Gears : The browser is the platformDidier Girard
 
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13Fred Sauer
 
Ajax World Oracle Ria
Ajax World Oracle RiaAjax World Oracle Ria
Ajax World Oracle Riarajivmordani
 

Similar a Web 2.0 And Ajax (20)

Google G Data Reading And Writing Data On The Web
Google G Data Reading And Writing Data On The WebGoogle G Data Reading And Writing Data On The Web
Google G Data Reading And Writing Data On The Web
 
Google G Data Reading And Writing Data On The Web 1
Google G Data Reading And Writing Data On The Web 1Google G Data Reading And Writing Data On The Web 1
Google G Data Reading And Writing Data On The Web 1
 
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
 
IPhone Web Development With Grails from CodeMash 2009
IPhone Web Development With Grails from CodeMash 2009IPhone Web Development With Grails from CodeMash 2009
IPhone Web Development With Grails from CodeMash 2009
 
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies
Rob Tweed :: Ajax and the Impact on Caché and Similar TechnologiesRob Tweed :: Ajax and the Impact on Caché and Similar Technologies
Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies
 
GTLAB Installation Tutorial for SciDAC 2009
GTLAB Installation Tutorial for SciDAC 2009GTLAB Installation Tutorial for SciDAC 2009
GTLAB Installation Tutorial for SciDAC 2009
 
ICEfaces and JSF 2.0 on GlassFish
ICEfaces and JSF 2.0 on GlassFishICEfaces and JSF 2.0 on GlassFish
ICEfaces and JSF 2.0 on GlassFish
 
GWT Extreme!
GWT Extreme!GWT Extreme!
GWT Extreme!
 
Grails and Dojo
Grails and DojoGrails and Dojo
Grails and Dojo
 
GWT
GWTGWT
GWT
 
Open Social Summit Korea
Open Social Summit KoreaOpen Social Summit Korea
Open Social Summit Korea
 
Gwt Presentation
Gwt PresentationGwt Presentation
Gwt Presentation
 
Frank Mantek Google G Data
Frank Mantek Google G DataFrank Mantek Google G Data
Frank Mantek Google G Data
 
JavaScript Library Overview
JavaScript Library OverviewJavaScript Library Overview
JavaScript Library Overview
 
Grails Introduction - IJTC 2007
Grails Introduction - IJTC 2007Grails Introduction - IJTC 2007
Grails Introduction - IJTC 2007
 
JavaScript Libraries (@Media)
JavaScript Libraries (@Media)JavaScript Libraries (@Media)
JavaScript Libraries (@Media)
 
2009 Java One State Of The Open Web
2009 Java One State Of The Open Web2009 Java One State Of The Open Web
2009 Java One State Of The Open Web
 
GWT + Gears : The browser is the platform
GWT + Gears : The browser is the platformGWT + Gears : The browser is the platform
GWT + Gears : The browser is the platform
 
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
 
Ajax World Oracle Ria
Ajax World Oracle RiaAjax World Oracle Ria
Ajax World Oracle Ria
 

Más de elliando dias

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slideselliando dias
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScriptelliando dias
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structureselliando dias
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de containerelliando dias
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agilityelliando dias
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Librarieselliando dias
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!elliando dias
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Webelliando dias
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduinoelliando dias
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorceryelliando dias
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Designelliando dias
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makeselliando dias
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.elliando dias
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebookelliando dias
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Studyelliando dias
 

Más de elliando dias (20)

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
 
Geometria Projetiva
Geometria ProjetivaGeometria Projetiva
Geometria Projetiva
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
 
Ragel talk
Ragel talkRagel talk
Ragel talk
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
 
Minicurso arduino
Minicurso arduinoMinicurso arduino
Minicurso arduino
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
 
Rango
RangoRango
Rango
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makes
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
 

Último

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Último (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Web 2.0 And Ajax

  • 1. Web 2.0 and AJAX Jim Driscoll Manager, Java Web Tier
  • 2. Agenda JGD • Definitions: Web 2.0, AJAX > Wikis, RSS/Blogs, and REST > AJAX Overview • Guidelines • JSF Approach • AJAX BluePrints 2
  • 3. A Little Web History JGD • CGI / Perl & C • Servlets • JSP / ASP / PHP • Other scripting > Python, Ruby • Java based web frameworks > Struts, JSF, (many) others • Scripting based frameworks • But all these kept the same (1.0) UI 3
  • 4. Web 2.0 by example JGD • DoubleClick • Google AdSense • Ofoto • Flickr • Britannica Online • Wikipedia • mp3.com • Napster • Personal websites • Blogging • Directories (Taxonomy) • Tagging (Folksonomy) • Screen Scraping • Web Services 4
  • 5. Web 2.0 Definition – by Tim O'Reilly JGD • Web as a Platform • Collective Intelligence > Folksonomy – Collaborative Categorization • Data is key and should be shared • Software is in constantly evolving > Software release cycles dead? • Lightweight Programming Models > SOAP/REST • The Network is the computer > (iTunes, mobile devices) • Rich User Experience 5
  • 6. So what is Web 2.0? JGD • Fuzzy Term, as popularized by O'Reilly... > ... some negative reaction (“obvious marketing fluff”) > ... but trying to capture a real qualitative change > ... featured recently in Time and Business Week • Technologies > Blogging, Syndication, RSS/Atom > Wikis, Web Services (REST) > AJAX, Rich Internet Clients • Attitudes > Sharing, Connected, Participatory > Services, Perpetual Beta, Users Engaged 6
  • 7. What is Web 2.0? (cont.) JGD • Services > Flickr, BitTorrent, iTunes > Maps (Yahoo, Google), Wikipedia > Gmail, AdSense > Yahoo & Google Services • Drivers > Faster Connectivity > More Available Connectivity, esp at home > More Powerful Machines > Customers More Comfortable with Technology > Browser wars (mostly) over 7
  • 8. Blogs / RSS / Atom JGD • RSS – Really Simple Syndication > A number of (not fully compatible) specs > Atom is latest, IETF, Standard • Provide Syndicated Information through HTTP • Blogs build on RSS/Atom > Aggregation, Content Reuse, Caching • Strong Social Phenomenon (e.g. politics) • Rome – a popular RSS/Atom library • Roller – Apache project donated by Sun > Runs on AS 9 • Blogs.sun.com 8
  • 9. Wikis / Collaboration JGD • Wikis are... > Simplified Web sites (Management, Content) > Collaboratively Created Web Sites • Example: Wikipedia (uses MediaWiki) • Java Wiki: JSPWiki (many others) • Portal Server 7.0 > Uses JSP Wiki > Focused on Collaboration 9
  • 10. REST JGD • Web 2.0 delivers Services over the Web • Pretty much all seems to be over REST > HTTP + typed XML content > (or JSON) • JAX-WS 2.0 provides some support > More is needed > WSDL is an imperfect match 10
  • 11. Conventional Rich Web Applications JGD • Plugins/Applets • Frames/ iframes • Dumb browser • Server Centric • Page to Page navigation based 11
  • 13. High Level AJAX Interaction Model JGD 13
  • 14. AJAX JGD Asynchronous JavaScript + XML AJAX is using JavaScript, namely the XmlHttpRequest object, to communicate asynchronously with a server-side component and dynamically update the source of an HTML page based on the resulting XML/Text response. 14
  • 15. Anatomy of an AJAX Interaction JGD 15
  • 16. HTML Page Event JGD <form name=quot;autofillformquot; action=quot;autocompletequot; method=quot;getquot;> <table border=quot;0quot; cellpadding=quot;5quot; cellspacing=quot;0quot;> <tr><td><b>Employee Name:</b></td><td> <input type=quot;textquot; id=quot;complete-fieldquot; size=quot;20quot; autocomplete=quot;offquot; onkeyup=quot;doCompletion();quot;> </td><td align=quot;leftquot;> <input id=quot;submit_btnquot; type=quot;Submitquot; value=quot;Lookup Employeequot;> </td></tr> <tr><td id=quot;auto-rowquot; colspan=quot;2quot;>&nbsp;<td/></tr> </table> </form> <div style=quot;position: absolute; top:170px;left:140pxquot; id=quot;menu-popupquot;> <table id=quot;completeTablequot; border=quot;1quot; bordercolor=quot;blackquot; cellpadding=quot;0quot; cellspacing=quot;0quot; /> </div> 16
  • 17. JavaScript Event Handler JGD function getXHR() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } else if (window.ActiveXObject) { return new ActiveXObject(quot;Microsoft.XMLHTTPquot;); } } function doCompletion() { var url = quot;autocomplete?action=complete&id=quot; + encodeURI(target.value); var req = getXHR(); req.onreadystatechange = processRequest; req.open(quot;GETquot;, url, true); req.send(null); } 17
  • 18. Servlet JGD public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String targetId = request.getParameter(quot;idquot;); Iterator it = employees.keySet().iterator(); while (it.hasNext()) { EmployeeBean e = (EmployeeBean)employees.get((String)it.next()); if ((e.getFirstName().toLowerCase().startsWith(targetId) || e.getLastName().toLowerCase().startsWith(targetId)) && !targetId.equals(quot;quot;)) { sb.append(quot;<employee>quot;); sb.append(quot;<id>quot; + e.getId() + quot;</id>quot;); sb.append(quot;<firstName>quot; + e.getFirstName() + quot;</firstName>quot;); sb.append(quot;<lastName>quot; + e.getLastName() + quot;</lastName>quot;); sb.append(quot;</employee>quot;); namesAdded = true; } } if (namesAdded) { response.setContentType(quot;text/xmlquot;); response.setHeader(quot;Cache-Controlquot;, quot;no-cachequot;); response.getWriter().write(quot;<employees>quot; + sb.toString() + quot;</employees>quot;); } else response.setStatus(HttpServletResponse.SC_NO_CONTENT); } 18
  • 19. JavaScript Client Callback JGD function postProcess(responseXML) { clearTable(); var employees = responseXML.getElementsByTagName(quot;employeesquot;)[0]; if (employees.childNodes.length > 0) { completeTable.setAttribute(quot;bordercolorquot;, quot;blackquot;); completeTable.setAttribute(quot;borderquot;, quot;1quot;); } else { clearTable(); } for (loop = 0; loop < employees.childNodes.length; loop++) { var employee = employees.childNodes[loop]; var firstName = employee.getElementsByTagName(quot;firstNamequot;)[0]; var lastName = employee.getElementsByTagName(quot;lastNamequot;)[0]; var employeeId = employee.getElementsByTagName(quot;idquot;)[0]; appendEmployee(firstName.childNodes[0].nodeValue, lastName.childNodes[0].nodeValue, employeeId.childNodes[0].nodeValue); } } 19
  • 20. Agenda JGD • Definitions: Web 2.0, Rich Web Applications, AJAX • Guidelines • JSF Approach • AJAX BluePrints 20
  • 21. AJAX Guidelines JGD • JavaScript Libraries • Usability Issues • AJAX Design • HTTP methods • Security • Desktop and AJAX 21
  • 22. JavaScript Libraries JGD • Prototype • RICO • Script.aculo.us • Dojo • Zimbra Recommendation: Adopt a library and don't try to re-invent the wheel. 22
  • 23. Usability JGD • Back/Forward/Refresh Buttons • Bookmarking • URL Sharing • Printing • 508 Compliance • Fallback Strategies • Remember <blink>? Recommendation: Consider the meaning of each and weigh the benefits when designing your application. 23
  • 24. XMLHttpRequest (XHR) JGD • HTTP Method > GET - When the result of N > 0 requests is the same. > POST - When operation has “side-effects” and changes the state on the server. • Concurrent Requests > Max is 2 (IE) Consider - Pooling > JavaScript Closures – Inline functions Recommendation: Take care using the XHR. Use Closures to track the requests/callbacks. Consider using a library. 24
  • 25. AJAX Design JGD • Add Around the Edges > Small components (autocomplete, tree, partial submit) • Page is the Application > Client and Server split MVC responsibilities Recommendation: Consider designing initial AJAX applications around the edges as you gain experience. Don't go overboard. 25
  • 26. Response Content Type JGD • XML • HTML • Text > Post processing on client > Inject directly into the page • JavaScript > Evaluated in JavaScript using eval() > JavaScript object representations of data(JSON) Recommendation: Use XML for structured portable data. Use plain text for when injecting content into the HTML. Use JavaScript to return object representations data. 26
  • 27. Security JGD • Sandboxed > Cross Domain XMLHttpRequest restricted > Access to file system restricted • HTTPS – Requires a page refresh • JavaScript Libraries for Encryption Exist • JavaScript code visible to the world Recommendation: Use HTTPS when you want to secure AJAX communication. Don't put compromising code in your JavaScript 27
  • 28. Desktop and AJAX JGD • AJAX is best for > Internet deployments (no separate runtime) > Frequently updated, data intensive service apps > Certain kinds of UI methods (HTML & CSS centric) • Swing (with or without Java Webstart) is best for > Disconnected / High Latency use > Computationally intensive apps > Very rich GUI needs > When you need a mature environment NOW Recommendation: Use the right tool for the job 28
  • 29. Agenda JGD • Definitions: Web 2.0, Rich Web Applications, AJAX • Guidelines • JSF Approach • AJAX BluePrints 29
  • 30. JSF Component Approach JGD Benefits Include: • Control Content Rendering • Control of Server Side Logic • All in one component • Reusable • Usable in a tool • Hide AJAX complexity from page developers 30
  • 31. Anatomy of an AJAX enabled JSF JGD Component 31
  • 32. Page Developer's View of JSF Component JGD <ajaxTags:completionField size=quot;40quot; id=quot;cityFieldquot; completionMethod=quot; #{ApplicationBean.completeName}quot; /> 32
  • 33. Server Side Logic for JSF Component JGD public String[] completeName() { ArrayList results = new ArrayList(); Iterator it = employees.keySet().iterator(); while (it.hasNext()) { EmployeeBean e = (EmployeeBean)employees.get((String)it.next()); if ((e.getFirstName().toLowerCase().startsWith(targetId) || e.getLastName().toLowerCase().startsWith(targetId)) && !targetId.equals(quot;quot;)) { results.add(e.getId() + quot; quot; + e.getFirstName() + e.getLastName()); } } return (String[])results.toArray(); } 33
  • 34. Agenda JGD • Definitions: Web 2.0, Rich Web Applications, AJAX • Guidelines • JSF Approach • AJAX BluePrints 34
  • 35. AJAX BluePrints JGD • BluePrints Solutions Catalog Entries on AJAX > For both NetBeans and command line > Written for GlassFish (http://glassfish.dev.java.net) > More entries posted all the time • Java Petstore Demo > Will be released at JavaOne • Blueprints AJAX components > Google Maps, Paypal > Autocomplete, Ratings, File Upload > Usable in Java Studio Creator, included in updates 35
  • 36. Resources JGD • BluePrints AJAX Page: http://java.sun.com/blueprints/ajax.html • AJAX FAQ for the Java Developer http://blueprints.dev.java.net/ajax-faq.html 36