SlideShare uma empresa Scribd logo
1 de 43
AJAX:  The New Paradigm for Enterprise Web Applications Rizwan Ahmed
What is AJAX? ,[object Object],[object Object],[object Object],[object Object],[object Object]
Components of AJAX ,[object Object],[object Object],[object Object],[object Object],[object Object]
Characteristics of AJAX apps ,[object Object],[object Object],[object Object],[object Object],[object Object]
AJAX Model
Sequences of AJAX vs. Traditional web model
Who is using AJAX? ,[object Object]
Who is using AJAX? ,[object Object]
Who is using AJAX? ,[object Object]
Beneath the Hood  ,[object Object],[object Object],[object Object],[object Object],[object Object]
XMLHttpRequest ,[object Object],[object Object],[object Object],[object Object]
XMLHttpRequest Properties ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
XMLHttpRequest Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Server Resource public class ServerResourceServlet extends HttpServlet { public void doGet(req, res) { String key = req.getParameter(&quot;key&quot;); …… . if (key != null) { returnXML = new StringBuffer(&quot;<returnedData>&quot;); returnXML.append(…); returnXML.append(&quot;</returnedData>&quot;); // setup the response res.setContentType(&quot;text/xml&quot;); // write out the xml string res.getWriter().write(returnXML.toString()); } } }
Callback Callback can be either discrete functions or anonymously declared. function  callback (){  if (req.readyState==4){  if (req.status == 200){ modifyHTML (…);  }  }  clear();  }
Mining the Response function  modifyHTML (){  var resp = req.responseText; var parser = new DOMParser(); var dom = parser.parseFromString(resp); var val = dom.getElementsByTagName(..); var elemId = document.getElementbyId(..); elemId.value = val[0].childNodes[0].nodeValue; ……… . }
Cross Browser Compatibility if (window.XMLHttpRequest) {  req = new XMLHttpRequest();  } else if (window.ActiveXObject) {  try { req = new ActiveXObject(Msxml2.XMLHTTP);  } catch (Exception e) { req = new  ActiveXObject(Microsoft.XMLHTTP); } }
Data Vehicles ●  XML <returnedData> <zip>29203</zip> <city>Columbia</city> <state>SC</state> </returnedData> ●  Plain Text (Custom formatted eg. CSV, HTML) returnedData;29203;Columbia;SC
Data Vehicles (cont.) ●  JavaScript Object Notation (JSON) A lightweight data format based off the JavaScript syntax.  Definitions can be included and parsed with JavaScript.  {“returnedData”:{ “ zip”: “29203”, “ city”: “Columbia”, “ state”: “SC”} }
Some AJAX Libraries ●  DoJo Toolkit  (http://dojotoolkit.org/) ●  Rico Toolkit  (http://openrico.org/) ●  DWR Toolkit  (http://getahead.org/dwr/) ●  Prototype  (http://prototypejs.org) ●  AjaxTags  (http://ajaxtags.sourceforge.net)
AJAX Libraries (cont.) DoJo Toolkit ●   DoJo is an open source DHTML toolkit written in JavaScript and include the AJAX  specific libraries dojo.io; dojo.rpc; dojo.json var key = document.getElementById(&quot;key&quot;);  dojo.io.bind ({  url: &quot;/server/resource?key=&quot;+key.value, load: function(type, data, evt) { callback(data); }, error: function(type, data, evt) { reportError(data); },  mimetype: “text/plain” });
AJAX Libraries (cont.) Rico Toolkit Rico is an open source toolkit allows for registering AJAX request handlers and HTML elements as AJAX response objects ●   ajaxEngine.registerElement (‘rHdl’,’server url’) ajaxEngine.sendRequest (‘rHdl’,’key=‘+key.value) ●  Server resource must respond with XML formatted document. Rico matches id attributes in the document with fields in the HTML form and populates it accordingly ●  No callback functions are necessary
AJAX Libraries (cont.) DWR Toolkit Direct Web Remoting is an open source AJAX framework for Java/JSP ●   DWRServlet  on the server end runs the whole show. Instantiated during application load time ●  On browser side a  JavaScript wrapper library  is created using Java’s Reflections API that mirror the server side classes ●  An XML configuration file  dwr.xml  provides the plumbing that connects the server side classes with the JavaScript
AJAX Libraries (cont.) Prototype Framework ●   Prototype is another open source framework that does AJAX requests with browser differences abstracted from user parameterString = “key=&quot; + escape(key);  new  Ajax.Request (“/server/resource&quot;, { method: &quot;get&quot;, parameters: parameterString, onSuccess: function(request) { var result = request.responseText; … .. }, onFailure: function(request) {…...} });
AJAX Libraries (cont.) Prototype Framework (cont.) ●   Prototype includes enhanced library support for JSON, DOM and other utilities ●   Prototype is largely used in conjunction with scriptaculous ●   Scriptaculous toolkit provides easy to use, cross browser JS libraries. Includes animation framework, visual effects, drag and drop features and AJAX controls
AJAX Libraries (cont.) AJAX using Custom Tags ●   Writing Ajaxian code over and over can be tedious and error prone ●   Encapsulate the functionality into a custom JSP tag for easy reuse ●   Using Tag Libraries will save time and enhance reusability and maintainability of the code ●   Consists of a TLD and Tag Support class ●   There are a number of 3 rd  party Tags that encapsulate Ajaxian functionality
AJAX Libraries (cont.) AjaxTags ●  AjaxTags is a Sourceforge project.  Allows use of AJAX with minimal effort ●  Consists of the following representative tags: Autocomplete –  Displays list of entries that match text into the autocomplete field HTML Content Replace  -  Connects a content area to an HTML onclick event Portlet –  Adds a portlet to a JSP page Select/Dropdown –  Populates a select field based on selection in another select field
AJAX Design Patterns ,[object Object],[object Object],[object Object],[object Object]
AJAX Design Patterns ,[object Object],[object Object],[object Object],[object Object],[object Object]
AJAX Design Patterns (cont.) ,[object Object],[object Object],[object Object],[object Object],[object Object]
AJAX Design Patterns (cont.) ,[object Object],[object Object],[object Object],[object Object],[object Object]
AJAX Design Patterns (cont.) ,[object Object],[object Object],[object Object],[object Object],[object Object]
AJAX Design Patterns (cont.) ,[object Object],[object Object],[object Object],[object Object],[object Object]
AJAX Design Patterns (cont.) ,[object Object],[object Object],[object Object]
AJAX Design Patterns (cont.) ,[object Object],[object Object],[object Object],[object Object]
AJAX Design Patterns (cont.) ,[object Object],[object Object],[object Object],[object Object]
AJAX Design Patterns (cont.) ,[object Object],[object Object],[object Object],[object Object],[object Object]
AJAX Design Patterns (cont.) ,[object Object],[object Object],[object Object],[object Object]
Request Management ,[object Object],[object Object],[object Object],[object Object]
Request Management ●  Most browsers have inbuilt queuing mechanisms which is not robust ●  Works well when requests are few and far in between ●  In real world requests are being sent from various parts of the application at different times ●  No control over when requests are sent or what order they should be sent
Request Management (cont.) ,[object Object],[object Object],[object Object],[object Object]
Recap ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
References ,[object Object],[object Object],[object Object],[object Object],[object Object]

Mais conteúdo relacionado

Mais procurados

Web Development Presentation
Web Development PresentationWeb Development Presentation
Web Development PresentationTurnToTech
 
Introduction to Web Architecture
Introduction to Web ArchitectureIntroduction to Web Architecture
Introduction to Web ArchitectureChamnap Chhorn
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajaxNir Elbaz
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsVikash Singh
 
WEB I - 01 - Introduction to Web Development
WEB I - 01 - Introduction to Web DevelopmentWEB I - 01 - Introduction to Web Development
WEB I - 01 - Introduction to Web DevelopmentRandy Connolly
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applicationshchen1
 
Lecture-1: Introduction to web engineering - course overview and grading scheme
Lecture-1: Introduction to web engineering - course overview and grading schemeLecture-1: Introduction to web engineering - course overview and grading scheme
Lecture-1: Introduction to web engineering - course overview and grading schemeMubashir Ali
 
Introduction to Web Development
Introduction to Web DevelopmentIntroduction to Web Development
Introduction to Web DevelopmentParvez Mahbub
 

Mais procurados (20)

Ajax Ppt 1
Ajax Ppt 1Ajax Ppt 1
Ajax Ppt 1
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
 
PHP Presentation
PHP PresentationPHP Presentation
PHP Presentation
 
Backend Programming
Backend ProgrammingBackend Programming
Backend Programming
 
Web Development Presentation
Web Development PresentationWeb Development Presentation
Web Development Presentation
 
Introduction to Web Architecture
Introduction to Web ArchitectureIntroduction to Web Architecture
Introduction to Web Architecture
 
Laravel Tutorial PPT
Laravel Tutorial PPTLaravel Tutorial PPT
Laravel Tutorial PPT
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
WEB I - 01 - Introduction to Web Development
WEB I - 01 - Introduction to Web DevelopmentWEB I - 01 - Introduction to Web Development
WEB I - 01 - Introduction to Web Development
 
Express js
Express jsExpress js
Express js
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 
Tomcat
TomcatTomcat
Tomcat
 
File Uploading in PHP
File Uploading in PHPFile Uploading in PHP
File Uploading in PHP
 
Lecture-1: Introduction to web engineering - course overview and grading scheme
Lecture-1: Introduction to web engineering - course overview and grading schemeLecture-1: Introduction to web engineering - course overview and grading scheme
Lecture-1: Introduction to web engineering - course overview and grading scheme
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
Javascript 101
Javascript 101Javascript 101
Javascript 101
 
Web Development
Web DevelopmentWeb Development
Web Development
 
Introduction to Web Development
Introduction to Web DevelopmentIntroduction to Web Development
Introduction to Web Development
 

Semelhante a Ajax (20)

Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)Asynchronous JavaScript & XML (AJAX)
Asynchronous JavaScript & XML (AJAX)
 
Ajax Introduction
Ajax IntroductionAjax Introduction
Ajax Introduction
 
SynapseIndia dotnet development ajax client library
SynapseIndia dotnet development ajax client librarySynapseIndia dotnet development ajax client library
SynapseIndia dotnet development ajax client library
 
Ajax tutorial by bally chohan
Ajax tutorial by bally chohanAjax tutorial by bally chohan
Ajax tutorial by bally chohan
 
Using Ajax In Domino Web Applications
Using Ajax In Domino Web ApplicationsUsing Ajax In Domino Web Applications
Using Ajax In Domino Web Applications
 
Ajax presentation
Ajax presentationAjax presentation
Ajax presentation
 
M Ramya
M RamyaM Ramya
M Ramya
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
Unit-5.pptx
Unit-5.pptxUnit-5.pptx
Unit-5.pptx
 
Ajax
AjaxAjax
Ajax
 
Mashup
MashupMashup
Mashup
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
Ajax.ppt
Ajax.pptAjax.ppt
Ajax.ppt
 
Ajax
AjaxAjax
Ajax
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
Copy of ajax tutorial
Copy of ajax tutorialCopy of ajax tutorial
Copy of ajax tutorial
 
CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2CTS Conference Web 2.0 Tutorial Part 2
CTS Conference Web 2.0 Tutorial Part 2
 
Ajax Lecture Notes
Ajax Lecture NotesAjax Lecture Notes
Ajax Lecture Notes
 

Último

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
 
[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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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
 
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
 
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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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 Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 

Último (20)

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
 
[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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
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
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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 Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

Ajax

  • 1. AJAX: The New Paradigm for Enterprise Web Applications Rizwan Ahmed
  • 2.
  • 3.
  • 4.
  • 6. Sequences of AJAX vs. Traditional web model
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14. Server Resource public class ServerResourceServlet extends HttpServlet { public void doGet(req, res) { String key = req.getParameter(&quot;key&quot;); …… . if (key != null) { returnXML = new StringBuffer(&quot;<returnedData>&quot;); returnXML.append(…); returnXML.append(&quot;</returnedData>&quot;); // setup the response res.setContentType(&quot;text/xml&quot;); // write out the xml string res.getWriter().write(returnXML.toString()); } } }
  • 15. Callback Callback can be either discrete functions or anonymously declared. function callback (){ if (req.readyState==4){ if (req.status == 200){ modifyHTML (…); } } clear(); }
  • 16. Mining the Response function modifyHTML (){ var resp = req.responseText; var parser = new DOMParser(); var dom = parser.parseFromString(resp); var val = dom.getElementsByTagName(..); var elemId = document.getElementbyId(..); elemId.value = val[0].childNodes[0].nodeValue; ……… . }
  • 17. Cross Browser Compatibility if (window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if (window.ActiveXObject) { try { req = new ActiveXObject(Msxml2.XMLHTTP); } catch (Exception e) { req = new ActiveXObject(Microsoft.XMLHTTP); } }
  • 18. Data Vehicles ● XML <returnedData> <zip>29203</zip> <city>Columbia</city> <state>SC</state> </returnedData> ● Plain Text (Custom formatted eg. CSV, HTML) returnedData;29203;Columbia;SC
  • 19. Data Vehicles (cont.) ● JavaScript Object Notation (JSON) A lightweight data format based off the JavaScript syntax. Definitions can be included and parsed with JavaScript. {“returnedData”:{ “ zip”: “29203”, “ city”: “Columbia”, “ state”: “SC”} }
  • 20. Some AJAX Libraries ● DoJo Toolkit (http://dojotoolkit.org/) ● Rico Toolkit (http://openrico.org/) ● DWR Toolkit (http://getahead.org/dwr/) ● Prototype (http://prototypejs.org) ● AjaxTags (http://ajaxtags.sourceforge.net)
  • 21. AJAX Libraries (cont.) DoJo Toolkit ● DoJo is an open source DHTML toolkit written in JavaScript and include the AJAX specific libraries dojo.io; dojo.rpc; dojo.json var key = document.getElementById(&quot;key&quot;); dojo.io.bind ({ url: &quot;/server/resource?key=&quot;+key.value, load: function(type, data, evt) { callback(data); }, error: function(type, data, evt) { reportError(data); }, mimetype: “text/plain” });
  • 22. AJAX Libraries (cont.) Rico Toolkit Rico is an open source toolkit allows for registering AJAX request handlers and HTML elements as AJAX response objects ● ajaxEngine.registerElement (‘rHdl’,’server url’) ajaxEngine.sendRequest (‘rHdl’,’key=‘+key.value) ● Server resource must respond with XML formatted document. Rico matches id attributes in the document with fields in the HTML form and populates it accordingly ● No callback functions are necessary
  • 23. AJAX Libraries (cont.) DWR Toolkit Direct Web Remoting is an open source AJAX framework for Java/JSP ● DWRServlet on the server end runs the whole show. Instantiated during application load time ● On browser side a JavaScript wrapper library is created using Java’s Reflections API that mirror the server side classes ● An XML configuration file dwr.xml provides the plumbing that connects the server side classes with the JavaScript
  • 24. AJAX Libraries (cont.) Prototype Framework ● Prototype is another open source framework that does AJAX requests with browser differences abstracted from user parameterString = “key=&quot; + escape(key); new Ajax.Request (“/server/resource&quot;, { method: &quot;get&quot;, parameters: parameterString, onSuccess: function(request) { var result = request.responseText; … .. }, onFailure: function(request) {…...} });
  • 25. AJAX Libraries (cont.) Prototype Framework (cont.) ● Prototype includes enhanced library support for JSON, DOM and other utilities ● Prototype is largely used in conjunction with scriptaculous ● Scriptaculous toolkit provides easy to use, cross browser JS libraries. Includes animation framework, visual effects, drag and drop features and AJAX controls
  • 26. AJAX Libraries (cont.) AJAX using Custom Tags ● Writing Ajaxian code over and over can be tedious and error prone ● Encapsulate the functionality into a custom JSP tag for easy reuse ● Using Tag Libraries will save time and enhance reusability and maintainability of the code ● Consists of a TLD and Tag Support class ● There are a number of 3 rd party Tags that encapsulate Ajaxian functionality
  • 27. AJAX Libraries (cont.) AjaxTags ● AjaxTags is a Sourceforge project. Allows use of AJAX with minimal effort ● Consists of the following representative tags: Autocomplete – Displays list of entries that match text into the autocomplete field HTML Content Replace - Connects a content area to an HTML onclick event Portlet – Adds a portlet to a JSP page Select/Dropdown – Populates a select field based on selection in another select field
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40. Request Management ● Most browsers have inbuilt queuing mechanisms which is not robust ● Works well when requests are few and far in between ● In real world requests are being sent from various parts of the application at different times ● No control over when requests are sent or what order they should be sent
  • 41.
  • 42.
  • 43.

Notas do Editor

  1. Assuming you have used a web browser from the last few years – IE, Firefox, Safari or Opera you’ve seen AJAX at work if you’ve ever used Google Maps, GMail or Yahoo! News. Spurred on by little known and lesser used technologies that had been included in web browsers for some time, the web in the last few years has taken a bold step forward, shattering the traditional usage model that required a full page to load every time new data or a new part of the application logic was accessed. Companies began to experiment with dynamic reloading of web pages transmitting only a small amount of data to the client resulting in faster and arguably better user experience.