SlideShare una empresa de Scribd logo
1 de 28
Introduction to AJAX
Venkat pinagadi
What is Ajax?
 Asynchronous
 JavaScript
 And

 XmlHttpRequest (XHR)


Some use XML, but to me that’s misleading
Why Ajax?


XHR Support across all browsers




Emergence of broadband





Based on DOM, CSS, XHTML
AJAX-based JavaScript can take considerable
bandwidth to download

The “Killer App” - Google Maps
A Catchy Acronym


Coined by Jesse James Garrett of Adaptive Path
(February 2005)
Why Ajax?
Why Ajax?
AJAX Alternatives


Macromedia Flash


Requires a plug-in





Java Web Start/Applets
.NET – No Touch Deployment




So what? It comes already with almost every browser

Both need a runtime preinstalled

Handheld device browsers generally do not
support the full range of Ajax technologies.
Implementing AJAX


To implement AJAX we need to answer three
questions:


What triggers the AJAX request?




What is the server process that handles the AJAX
request and issues the response?




Usually a JavaScript event (onblur, onclick, etc.)

Some kind of URL (use a Service Locator)

What processes the response from the server(what is
the callback method)?


A JavaScript function that gets the response and
manipulates the DOM, based on the text returned.
XmlHttpRequest Object (XHR)





The Heart of AJAX
First implemented in IE in 1997 as part of the
new DHTML standard
Response comes in one of two properties:




responseXML – Returns a DOM document (can use
functions such as, getElementById())
responseText – A text string (can be HTML, or even
JavaScript code)
XHR : Creating
XHR : Sending the Request

true = asynchronous
XHR : Using a callback handler
Handling the Response



Response can be one of the following:


Formatted data (XML, other custom format)
 XMLHttpRequest.responseXML





Decouples the server from presentation issues
Could perform XSLT transformation on returned XML

HTML
 XMLHttpRequest.responseText


Server generates HTML, script “injects” HTML via

innerHTML




Server is now concerned with presentation

JavaScript
 XMLHttpRequest.responseText
 Use the eval() JavaScript command


Again, our server code is concerned with presentation
AJAX Concerns






Security
Browser Compatibility
Accessibility
The Back Button
What if JavaScript is Turned Off?
AJAX and the Back Button






Huge usability issue
Returning to the previous state may not be
possible when a page is updated dynamically
Difficult to bookmark on a particular page state
Really Simple History (RSH) framework
addresses these issues


http://codinginparadise.org/projects/dhtml_history/README.html
AJAX Security – Server of Origin
Policy
AJAX Security


Browsers impose security restrictions


Cannot make requests via the XHR outside of
the domain the web page came from
Can set security on IE to get around this (but you
really don’t want to)
 Mozilla-based browsers require digitally signing
your script (Yuck!)




User must approve going to site.


Firefox requires additional code
AJAX Security


Calling third-party web-services




Application Proxies – Call the web-service
from a servlet
Apache Proxy – Configure Apache to invisibly
reroute from the server to the target web
service domain
Encapsulating our AJAX Logic
Encapsulating our AJAX Logic
(cont.)
Problems with JavaScript


Most Java developers know enough
JavaScript to be dangerous.




If you don’t know what you are doing, you
could cause memory leaks on the client
machine.

Most JavaScript functionality can be
factored out and encapsulated
Ajax Without the J
It would be nice to encapsulate all of the
JavaScript within our components, so we
don’t have to write any JavaScript.

JavaServer Faces (JSF) provides a way to
accomplish this.
JSF and AJAX
Why JSF makes sense
- JSF Lifecycle
- Separates the things that don’t change
(client-side) from the things that do
change (server-side)
- Echo2 is another Java component-based
web framework that supports AJAX.
-

http://www.nextapp.com/platform/echo2/echo/
Sun BluePrints Solutions
Catalog
Sun defines best practices for integrating
AJAX into JSF applications.
https://bpcatalog.dev.java.net/nonav/ajax/
Java Studio Creator 2
Sun has released several AJAX components that
are available for Creator 2
- Auto-Complete Text Field
- Progress Bar
- Map Viewer
- Select Value Text Field
Obtain components via Creator’s “Update Center”
Demo – Creator 2 AJAX
Components




Auto Complete
Map Viewer
Drag-and-drop components


Code server-based functionality
Demo – DWR (Direct Web
Remoting)




Call methods from a POJO that reside on
the server.
Wraps objects in a JavaScript wrapper
Links


Original AJAX Blog by Jesse James Garrett




“Fixing AJAX: XMLHttpRequest Considered Harmful”




http://www.jsfcentral.com/listings/A10500?link

Really Simple History (RSH) Framework




https://bpcatalog.dev.java.net/nonav/ajax/index.html

“AJAX Without the J” Blog




http://getahead.ltd.uk/dwr/

Java AJAX BluePrints Solutions Catalog




http://www.xml.com/pub/a/2005/11/09/fixing-ajax-xmlhttprequest-considered-harmful.html

DWR (Direct Web Remoting) Home Page




http://adaptivepath.com/publications/essays/archives/000385.php

http://codinginparadise.org/projects/dhtml_history/README.html

ECHO 2 Web Framework
-

http://www.nextapp.com/platform/echo2/echo/
Questions


My E-mail is:
Venkat.pinagadi@gmail.com

Más contenido relacionado

La actualidad más candente (20)

Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
Ajax Ppt
Ajax PptAjax Ppt
Ajax Ppt
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
PHP - Introduction to PHP AJAX
PHP -  Introduction to PHP AJAXPHP -  Introduction to PHP AJAX
PHP - Introduction to PHP AJAX
 
Ajax ppt
Ajax pptAjax ppt
Ajax ppt
 
Ajax presentation
Ajax presentationAjax presentation
Ajax presentation
 
What is Ajax technology?
What is Ajax technology?What is Ajax technology?
What is Ajax technology?
 
Ajax ppt - 32 slides
Ajax ppt - 32 slidesAjax ppt - 32 slides
Ajax ppt - 32 slides
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
Ajax.ppt
Ajax.pptAjax.ppt
Ajax.ppt
 
Overview of AJAX
Overview of AJAXOverview of AJAX
Overview of AJAX
 
Ajax PPT
Ajax PPTAjax PPT
Ajax PPT
 
Advantages and disadvantages of an ajax based client application
Advantages and disadvantages of an ajax based client applicationAdvantages and disadvantages of an ajax based client application
Advantages and disadvantages of an ajax based client application
 
An Introduction to Ajax Programming
An Introduction to Ajax ProgrammingAn Introduction to Ajax Programming
An Introduction to Ajax Programming
 
Architecture in Ajax Applications
Architecture in Ajax ApplicationsArchitecture in Ajax Applications
Architecture in Ajax Applications
 
Using Ajax In Domino Web Applications
Using Ajax In Domino Web ApplicationsUsing Ajax In Domino Web Applications
Using Ajax In Domino Web Applications
 
Jquery Ajax
Jquery AjaxJquery Ajax
Jquery Ajax
 
AJAX
AJAXAJAX
AJAX
 

Destacado

Ipsos Consumer Confidence Index April 2013
Ipsos Consumer Confidence Index April 2013Ipsos Consumer Confidence Index April 2013
Ipsos Consumer Confidence Index April 2013Ipsos UK
 
9 icms instructions_for_authors
9 icms instructions_for_authors9 icms instructions_for_authors
9 icms instructions_for_authorsa2shafi
 
IAFE Zone 3/6 - New Digital Priorities: Trends in Digital Marketing
IAFE Zone 3/6 - New Digital Priorities: Trends in Digital MarketingIAFE Zone 3/6 - New Digital Priorities: Trends in Digital Marketing
IAFE Zone 3/6 - New Digital Priorities: Trends in Digital MarketingSaffire
 
인천펜션 노보텔호텔
인천펜션 노보텔호텔인천펜션 노보텔호텔
인천펜션 노보텔호텔jdhfrter
 
B100 board presentation
B100 board presentationB100 board presentation
B100 board presentationrjoana
 
Introducción a la biotecnología
Introducción a la biotecnologíaIntroducción a la biotecnología
Introducción a la biotecnologíabkt_6
 
0406web creators night_DeNA
0406web creators night_DeNA0406web creators night_DeNA
0406web creators night_DeNADeNA_open_events
 
Online marketing and distribution
Online marketing and distributionOnline marketing and distribution
Online marketing and distributionViệt Long Plaza
 
Impacto De Las Tics En La Cultura De La Mediacion A Distancia Para La Educaci...
Impacto De Las Tics En La Cultura De La Mediacion A Distancia Para La Educaci...Impacto De Las Tics En La Cultura De La Mediacion A Distancia Para La Educaci...
Impacto De Las Tics En La Cultura De La Mediacion A Distancia Para La Educaci...GUILLERMO MOLINA JARA
 
Dynamics CRM 2013 Customization and Configuration
Dynamics CRM 2013 Customization and ConfigurationDynamics CRM 2013 Customization and Configuration
Dynamics CRM 2013 Customization and ConfigurationSatish
 

Destacado (12)

Ipsos Consumer Confidence Index April 2013
Ipsos Consumer Confidence Index April 2013Ipsos Consumer Confidence Index April 2013
Ipsos Consumer Confidence Index April 2013
 
AcreditacióN 9 SesióN
AcreditacióN 9 SesióNAcreditacióN 9 SesióN
AcreditacióN 9 SesióN
 
9 icms instructions_for_authors
9 icms instructions_for_authors9 icms instructions_for_authors
9 icms instructions_for_authors
 
IAFE Zone 3/6 - New Digital Priorities: Trends in Digital Marketing
IAFE Zone 3/6 - New Digital Priorities: Trends in Digital MarketingIAFE Zone 3/6 - New Digital Priorities: Trends in Digital Marketing
IAFE Zone 3/6 - New Digital Priorities: Trends in Digital Marketing
 
인천펜션 노보텔호텔
인천펜션 노보텔호텔인천펜션 노보텔호텔
인천펜션 노보텔호텔
 
B100 board presentation
B100 board presentationB100 board presentation
B100 board presentation
 
Introducción a la biotecnología
Introducción a la biotecnologíaIntroducción a la biotecnología
Introducción a la biotecnología
 
0406web creators night_DeNA
0406web creators night_DeNA0406web creators night_DeNA
0406web creators night_DeNA
 
Daily Newsletter: 17th May, 2011
Daily Newsletter: 17th May, 2011Daily Newsletter: 17th May, 2011
Daily Newsletter: 17th May, 2011
 
Online marketing and distribution
Online marketing and distributionOnline marketing and distribution
Online marketing and distribution
 
Impacto De Las Tics En La Cultura De La Mediacion A Distancia Para La Educaci...
Impacto De Las Tics En La Cultura De La Mediacion A Distancia Para La Educaci...Impacto De Las Tics En La Cultura De La Mediacion A Distancia Para La Educaci...
Impacto De Las Tics En La Cultura De La Mediacion A Distancia Para La Educaci...
 
Dynamics CRM 2013 Customization and Configuration
Dynamics CRM 2013 Customization and ConfigurationDynamics CRM 2013 Customization and Configuration
Dynamics CRM 2013 Customization and Configuration
 

Similar a Introduction to ajax

Similar a Introduction to ajax (20)

Ajax: User Experience
Ajax: User ExperienceAjax: User Experience
Ajax: User Experience
 
Beyond HTML: Tools for Building Web 2.0 Apps
Beyond HTML: Tools for Building Web 2.0 AppsBeyond HTML: Tools for Building Web 2.0 Apps
Beyond HTML: Tools for Building Web 2.0 Apps
 
25250716 seminar-on-ajax text
25250716 seminar-on-ajax text25250716 seminar-on-ajax text
25250716 seminar-on-ajax text
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
AJAX in ASP.NET
AJAX in ASP.NETAJAX in ASP.NET
AJAX in ASP.NET
 
Ajax assignment help
Ajax assignment helpAjax assignment help
Ajax assignment help
 
Make your gui shine with ajax solr
Make your gui shine with ajax solrMake your gui shine with ajax solr
Make your gui shine with ajax solr
 
Ajax
AjaxAjax
Ajax
 
mukesh
mukeshmukesh
mukesh
 
Copy of ajax tutorial
Copy of ajax tutorialCopy of ajax tutorial
Copy of ajax tutorial
 
Ajax Introduction
Ajax IntroductionAjax Introduction
Ajax Introduction
 
Ajax
AjaxAjax
Ajax
 
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnitWriting and Testing JavaScript-heavy Web 2.0 apps with JSUnit
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
 
GWT = easy AJAX
GWT = easy AJAXGWT = easy AJAX
GWT = easy AJAX
 
M Ramya
M RamyaM Ramya
M Ramya
 
AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
 
Aspnet Ajax Performance Improvement
Aspnet Ajax Performance ImprovementAspnet Ajax Performance Improvement
Aspnet Ajax Performance Improvement
 
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
 

Último

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
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
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 

Último (20)

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
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
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 

Introduction to ajax

  • 2. What is Ajax?  Asynchronous  JavaScript  And  XmlHttpRequest (XHR)  Some use XML, but to me that’s misleading
  • 3. Why Ajax?  XHR Support across all browsers   Emergence of broadband    Based on DOM, CSS, XHTML AJAX-based JavaScript can take considerable bandwidth to download The “Killer App” - Google Maps A Catchy Acronym  Coined by Jesse James Garrett of Adaptive Path (February 2005)
  • 6. AJAX Alternatives  Macromedia Flash  Requires a plug-in    Java Web Start/Applets .NET – No Touch Deployment   So what? It comes already with almost every browser Both need a runtime preinstalled Handheld device browsers generally do not support the full range of Ajax technologies.
  • 7. Implementing AJAX  To implement AJAX we need to answer three questions:  What triggers the AJAX request?   What is the server process that handles the AJAX request and issues the response?   Usually a JavaScript event (onblur, onclick, etc.) Some kind of URL (use a Service Locator) What processes the response from the server(what is the callback method)?  A JavaScript function that gets the response and manipulates the DOM, based on the text returned.
  • 8. XmlHttpRequest Object (XHR)    The Heart of AJAX First implemented in IE in 1997 as part of the new DHTML standard Response comes in one of two properties:   responseXML – Returns a DOM document (can use functions such as, getElementById()) responseText – A text string (can be HTML, or even JavaScript code)
  • 10. XHR : Sending the Request true = asynchronous
  • 11. XHR : Using a callback handler
  • 12. Handling the Response  Response can be one of the following:  Formatted data (XML, other custom format)  XMLHttpRequest.responseXML    Decouples the server from presentation issues Could perform XSLT transformation on returned XML HTML  XMLHttpRequest.responseText  Server generates HTML, script “injects” HTML via innerHTML   Server is now concerned with presentation JavaScript  XMLHttpRequest.responseText  Use the eval() JavaScript command  Again, our server code is concerned with presentation
  • 14. AJAX and the Back Button     Huge usability issue Returning to the previous state may not be possible when a page is updated dynamically Difficult to bookmark on a particular page state Really Simple History (RSH) framework addresses these issues  http://codinginparadise.org/projects/dhtml_history/README.html
  • 15. AJAX Security – Server of Origin Policy
  • 16. AJAX Security  Browsers impose security restrictions  Cannot make requests via the XHR outside of the domain the web page came from Can set security on IE to get around this (but you really don’t want to)  Mozilla-based browsers require digitally signing your script (Yuck!)   User must approve going to site.  Firefox requires additional code
  • 17. AJAX Security  Calling third-party web-services   Application Proxies – Call the web-service from a servlet Apache Proxy – Configure Apache to invisibly reroute from the server to the target web service domain
  • 19. Encapsulating our AJAX Logic (cont.)
  • 20. Problems with JavaScript  Most Java developers know enough JavaScript to be dangerous.   If you don’t know what you are doing, you could cause memory leaks on the client machine. Most JavaScript functionality can be factored out and encapsulated
  • 21. Ajax Without the J It would be nice to encapsulate all of the JavaScript within our components, so we don’t have to write any JavaScript. JavaServer Faces (JSF) provides a way to accomplish this.
  • 22. JSF and AJAX Why JSF makes sense - JSF Lifecycle - Separates the things that don’t change (client-side) from the things that do change (server-side) - Echo2 is another Java component-based web framework that supports AJAX. - http://www.nextapp.com/platform/echo2/echo/
  • 23. Sun BluePrints Solutions Catalog Sun defines best practices for integrating AJAX into JSF applications. https://bpcatalog.dev.java.net/nonav/ajax/
  • 24. Java Studio Creator 2 Sun has released several AJAX components that are available for Creator 2 - Auto-Complete Text Field - Progress Bar - Map Viewer - Select Value Text Field Obtain components via Creator’s “Update Center”
  • 25. Demo – Creator 2 AJAX Components    Auto Complete Map Viewer Drag-and-drop components  Code server-based functionality
  • 26. Demo – DWR (Direct Web Remoting)   Call methods from a POJO that reside on the server. Wraps objects in a JavaScript wrapper
  • 27. Links  Original AJAX Blog by Jesse James Garrett   “Fixing AJAX: XMLHttpRequest Considered Harmful”   http://www.jsfcentral.com/listings/A10500?link Really Simple History (RSH) Framework   https://bpcatalog.dev.java.net/nonav/ajax/index.html “AJAX Without the J” Blog   http://getahead.ltd.uk/dwr/ Java AJAX BluePrints Solutions Catalog   http://www.xml.com/pub/a/2005/11/09/fixing-ajax-xmlhttprequest-considered-harmful.html DWR (Direct Web Remoting) Home Page   http://adaptivepath.com/publications/essays/archives/000385.php http://codinginparadise.org/projects/dhtml_history/README.html ECHO 2 Web Framework - http://www.nextapp.com/platform/echo2/echo/

Notas del editor

  1. Non-standard extensions to the web-browser DOM.
  2. Non-standard extensions to the web-browser DOM.
  3. Non-standard extensions to the web-browser DOM.