SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie Introduction to ajax

Ähnlich wie 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
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 

Kürzlich hochgeladen (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 

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/

Hinweis der Redaktion

  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.