Peter Laird. | 1 Getting Started Building Mashups using JavaScript, Ajax, and Google Maps Peter Laird Managing Architect WebLogic Portal BEA Systems.

Slides:



Advertisements
Similar presentations
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Introduction to Ajax.
Advertisements

By Loukik Purohit & Rohit Ghatol
JavaScript and AJAX Jonathan Foss University of Warwick
University of Virginia 1 Modern Web Application Development Overview of some newer web applications methods Web 2.0 Ajax fundamentals Ruby on Rails.
BEA Confidential. | 1 Building REST Service APIs for Rich Internet Applications Peter Laird Managing Architect WebLogic Portal BEA Systems.
AJAX Presented by: Dickson Fu Dimas Ariawan Niels Andreassen Ryan Dial Jordan Nielson CMPUT 410 University of Alberta 2006.
1 Cleaning up the Internet Using AJAX, SOAP and Comet CS526 Mike Gerschefske Justin Gray James Yoo 02 May 2006.
Does Ajax suck? CS575 Spring 2007 Chanwit Suebsureekul.
5/3/2006 Mike/Justin/JYoo AJAX/SOAP/Comet 1 Cleaning up the Internet Using AJAX, SOAP and Comet CS526 Mike Gerschefske Justin Gray James Yoo 02 May 2006.
1 JavaScript & AJAX CS , Spring JavaScript.
More APIs: Web Services CMPT 281. Announcements Project milestone Lab: – Web services examples.
Chapter 6 DOJO TOOLKITS. Objectives Discuss XML DOM Discuss JSON Discuss Ajax Response in XML, HTML, JSON, and Other Data Type.
Web Services & Widgets Godmar Back. Mash-Ups Applications that combine information from different sources in one web page Different architectural choices.
Prof. James A. Landay University of Washington Spring 2008 Web Interface Design, Prototyping, and Implementation Rich Internet Applications: AJAX, Server.
NextGen Technology upgrade – Synerizip - Sandeep Kamble.
Christopher Paolini Computational Science Research Center College of Engineering San Diego State University Computational Science 670 Fall 2009 Monday.
Chris Pinski.  History  What is Ajax  Who uses Ajax  Underlying Technologies  SE Aspect  Common Problems  Conclusion.
Web Applications Harry R. Erwin, PhD University of Sunderland CIT304/CSE301.
Ajax (Asynchronous JavaScript and XML). AJAX  Enable asynchronous communication between a web client and a server.  A client is not blocked when an.
JavaScript & jQuery the missing manual Chapter 11
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
GIS technologies and Web Mapping Services
Server-side Scripting Powering the webs favourite services.
ASP.NET + Ajax Jesper Tørresø ITNET2 F08. Ajax Ajax (Asynchronous JavaScript and XML) A group of interrelated web development techniques used for creating.
AJAX Without the “J” George Lawniczak. What is Ajax?
Intro to JavaScript Events. JavaScript Events Events in JavaScript let a web page react to some type of input Many different ways to handle events due.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Intro to Ajax Fred Stluka Jan 25, /25/2006Intro to AjaxFred Stluka2 What is Ajax? "Asynchronous JavaScript and XML" New name for an old technique:
1 rfXcel Confidential Copyright 2007 Web Technology JavaScript 12/10/07.
Cross Site Integration “mashups” cross site scripting.
Peter Laird. | 1 Building Dynamic Google Gadgets in Java Peter Laird Managing Architect WebLogic Portal BEA Systems.
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
Lecture 9: AJAX, Javascript review..  AJAX  Synchronous vs. asynchronous browsing.  Refreshing only “part of a page” from a URL.  Frameworks: Prototype,
AJAX Compiled from “AJAX Programming” [Sang Shin] (Asynchronous JavaScript and XML)
Rails & Ajax Module 5. Introduction to Rails Overview of Rails Rails is Ruby based “A development framework for Web-based applications” Rails uses the.
Asynchronous Javascript And XML AJAX : an introduction UFCEUS-20-2 : Web Programming.
School of Computing and Information Systems CS 371 Web Application Programming AJAX.
CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:
Unleash the Power of jQuery Learning & Development Team Telerik Software Academy.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
 AJAX – Asynchronous JavaScript and XML  Ajax is used to develop fast dynamic web applications  Allows web pages to be updated asynchronously by transferring.
Web Technologies Lecture 7 Synchronous vs. asynchronous.
JSON – Java Script Object Notation. What is JSON JSON is a data interchange format Interactive Web 2.0 applications, no more use page replacement. Data.
SE-2840 Dr. Mark L. Hornick 1 Introduction to Ajax Asynchronous Javascript And XML.
AJAX. Overview of Ajax Ajax is not an API or a programming language Ajax aims to provide more responsive web applications In normal request/response HTTP.
Event Handling & AJAX IT210 Web Systems. Question How do we enable users to dynamically interact with a website? Answer: Use mouse and keyboard to trigger.
CHAPTER 8 AJAX & JSON WHAT IS AJAX? Ajax lets you…
AJAX and REST. Slide 2 What is AJAX? It’s an acronym for Asynchronous JavaScript and XML Although requests need not be asynchronous It’s not really a.
AJAX Use Cases for WSRP Subbu Allamaraju BEA Systems Inc WSRP F2F Meeting, May 2006.
What is AJAX ? Asynchronous Javascript and XML. Not a stand-alone language or technology. It is a technique that combines a set of known technologies in.
AJAX – Asynchronous JavaScript And XML By Kranthi Kiran Nuthi CIS 764 Kansas State University.
Web Technology (NCS-504) Prepared By Mr. Abhishek Kesharwani Assistant Professor,UCER Naini,Allahabad.
AJAX CS456 Fall Examples Where is AJAX used? Why do we care?
NCCUCS 軟體工程概論 Lecture 5: Ajax, Mashups April 29, 2014.
JQuery, JSON, AJAX. AJAX: Async JavaScript & XML In traditional Web coding, to get information from a database or a file on the server –make an HTML form.
AJAX. Objectives Understand and apply AJAX Using AJAX in DOJO library.
Open Solutions for a Changing World™ Eddy Kleinjan Copyright 2005, Data Access WordwideNew Techniques for Building Web Applications June 6-9, 2005 Key.
National College of Science & Information Technology.
AJAX and REST.
Subbu Allamaraju BEA Systems Inc
AJAX.
AJAX.
DWR: Direct Web Remoting
AJAX Robin Burke ECT 360.
MIS JavaScript and API Workshop (Part 3)
Intro to Ajax Fred Stluka Jan 25, 2006.
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
Introduction to JavaScript
Presentation transcript:

Peter Laird. | 1 Getting Started Building Mashups using JavaScript, Ajax, and Google Maps Peter Laird Managing Architect WebLogic Portal BEA Systems

BEA Confidential About the Speaker Has 10 years of server side Java development experience Leads the architecture team for BEA WebLogic Portal, a leading Java enterprise portal product Has worked on WebLogic Portal for 7 years as a developer and architect Holds the following certifications  Oracle DBA  Cisco CCNA Regular contributor to BEA’s developer website 

BEA Confidential Agenda What is a Mashup? The Mashup Toolbox The Simple Google Maps Mashup Invoking the REST Data Service from JavaScript Plotting Addresses with Google Maps

BEA Confidential Housekeeping This is a 30 Minute Presentation  A lot to cover, will move very fast  Will assume you have a basic understanding of: HTML XML Role of browsers and web servers HTTP request/response model A modern programming language, like Java, JavaScript, PHP, C# No network connectivity in this building  Google Maps necessarily requires internet access for live demos  Will show movies of demos instead

BEA Confidential What is a Mashup?

BEA Confidential What is a Mashup? Difficult to define adequately One of those “I know it when I see it” types of things Try this definition to start: “Websites or applications that combine content from more than one source into an integrated experience have become a popular way to rapidly assemble new applications. These applications can be called Mashups.” Note that an client, for example, satisfies this definition, but is definitely not what we mean Better to look at an example

BEA Confidential Mashup Example What we will build:

BEA Confidential Key Characteristics for Web Mashups Components can be implemented in a variety of technology stacks: Java,.NET, Ruby on Rails, PHP, static HTML, etc. Rich user interaction and inter-application communication allow components to create dynamic interfaces Components are integrated using lightweight approaches  JavaScript  REST services  iFrames  HTML Script includes End-user ideally has some control over defining and customizing the composite application

BEA Confidential Mashup Toolbox

BEA Confidential Mashup Toolbox Programming Technologies  JavaScript  AJAX and XmlHttpRequest  JSON Service Technologies  REST APIs  Google Maps

BEA Confidential JavaScript Full programming language with wide support Two major features we care about today DOM Manipulation  Browsers expose the rendered page as a tree of nodes (DOM)  JavaScript is a powerful means to dynamically update the DOM // find the tag with id 'greet_div' var div = document.getElementById('greet_div'); div.innerHTML = 'Hello ' + name; Event Handlers  A JavaScript function can be attached to DOM elements  Example: onclick event for a button  Function is executed when the event is triggered My Link

BEA Confidential Ajax and XmlHttpRequest Ajax – Asynchronous JavaScript and XML  Allows pieces of browser pages to update without a full page refresh  Implemented in JavaScript using to the XmlHttpRequest to create an out-of- band request back to the server  XML may be returned, but alternatives are popular (more on this later) Ajax frameworks have sprung up to build higher level abstractions  XMLHttpRequest infrastructure  Widget libraries  JavaScript libraries Popular Ajax frameworks  DOJO  DWR  GWT

BEA Confidential Ajax and XmlHttpRequest Sample // create a request object var xhr = new XMLHttpRequest(); // define the request properties xhr.open("GET", " true); xhr.onreadystatechange = myHandler; // define the callback handler xhr.send(null); // send the request function myHandler() // callback definition { if (xhr.readyState == 4) // response has been received { if (xhr.status != 404) { var data=eval(‘(’ + xhr.responseText + ‘)’); // invoke JS to manipulate the response }

BEA Confidential XmlHttpRequest and the Single Origin Policy A safety feature is present in all browser implementations  To protect users from malicious code writers Same Origin PolicySame Origin Policy prevents an XMLHttpRequest from targeting a server in any network domain other than the network domain that provided the page  Outer page:  Inner XmlHttpRequest:  The request would be blocked because it does not target bea.com This is an issue when implementing Mashups on the client Two resource types are immune to this policy  A page can load cross domain images and scripts.  By being clever with appending parameters to these resource requests, some implementations have worked around the limitation.

BEA Confidential JavaScript Object Notation (JSON) A text based serialized object format that is expressed in the JavaScript language An alternative to XML When working in JavaScript in a browser, a far more useful format  The returned JSON payload may be deserialized into an object with a single call  XML needs to be parsed or traversed

BEA Confidential REST APIs An approach to providing data services in an easily consumable form – as an alternative to approaches such as SOAP REST services are often invoked from JavaScript in a browser REST services are implemented using the basics of the web  Service end points are resources  HTTP requests, with the verb being important (GET, POST, PUT)  Services are stateless  GETs are idempotent  Return payload is usually JSON or XML

BEA Confidential A REST Example Google, Amazon, Flickr, del.icio.us, etc also offer REST APIs REST call to YouTube API The response: YouTube User I love OK GO and more.... Source: YouTube

BEA Confidential Google Maps Google provides a JavaScript library that interacts with its mapping service Allows mashup developers to easily plot addresses on a map Service is metered  Each developer needs to obtain an API key  Limited to 50,000 requests per day Single Origin Policy is not an issue  Google Maps API uses a Script Include instead of an XmlHttpRequest

BEA Confidential The Simple Google Maps Mashup

BEA Confidential How the Mashup Works Initial HTML page will render without any data User clicks a button to load the addresses  JavaScript event handler fires  XmlHttpRequest is sent to a URL to retrieve a list of addresses  Response contains a JSON payload of addresses  Callback processes the list of addresses and injects into the HTML page User clicks on one of the addresses  JavaScript event handler fires  Google Maps JavaScript API is called from the handler  Google Map is updated to depict the location

BEA Confidential Mashup Example What we will build:

BEA Confidential Invoking the REST Location Service from JavaScript

BEA Confidential How the Mashup Works Initial HTML page will render without any data User clicks a button to load the addresses  JavaScript event handler fires  XmlHttpRequest is sent to a URL to retrieve a list of addresses  Response contains a JSON payload of addresses  Callback processes the list of addresses and injects into the HTML page User clicks on one of the addresses  JavaScript event handler fires  Google Maps JavaScript API is called from the handler  Google Map is updated to depict the location

BEA Confidential Triggering the Event Handler Button is defined in HTML like this: <input value="Get the Locations" type="submit" onclick="javascript:getLocationsAndMap();return false" />

BEA Confidential The Address List Event Handler The event handler looks like this: var receiveReq = getXmlHttpRequestObject(); function getLocationsAndMap() { // getD2DSites.html is a REST service that returns the list of locations as JSON receiveReq.open("GET", 'getD2DSites.html', true); receiveReq.onreadystatechange = getLocationsAndMapCallback; receiveReq.send(null); }

BEA Confidential JSON Address REST Service The address service returns this in the response (only show one address here for brevity): {"locations": {"location":[ {"id": "WashingtonDC", "city": "Washington DC", "location": "Hilton Hotel, McLean Tysons Corner", "address": "7920 Jones Branch Drive, McLean, VA 22102", "date": "May 2nd, 2007" } ]} }

BEA Confidential The Address List Callback function getLocationsAndMapCallback() { if (receiveReq.readyState == 4) { // deserialize the JSON response. This creates an array of location objects. var response = eval("(" + receiveReq.responseText + ")"); // generate HTML listing the locations and update the page DOM var locations_div = document.getElementById('locations_div'); for(i=0; i < response.locations.location.length; i++) { // removed for brevity, computing the URL for each address locations_div.innerHTML += ' '+ city + ' ' + link + ' ' + addr + ' '; } }}

BEA Confidential Plotting Addresses with Google Maps

BEA Confidential How the Mashup Works Initial HTML page will render without any data User clicks a button to load the addresses  JavaScript event handler fires  XmlHttpRequest is sent to a URL to retrieve a list of addresses  Response contains a JSON payload of addresses  Callback processes the list of addresses and injects into the HTML page User clicks on one of the addresses  JavaScript event handler fires  Google Maps JavaScript API is called from the handler  Google Map is updated to depict the location

BEA Confidential Event Handler Invokes Google Maps API The address service returns this in the response (only show one address here for brevity): function showAddress(address) { var map = new GMap2(document.getElementById("google_map_div")); var geocoder = new GClientGeocoder(); geocoder.getLatLng(address, function(point) { if (!point) { alert(address + " not found"); } else { map.setCenter(point, 13); var marker = new GMarker(point); map.addOverlay(marker); marker.openInfoWindowHtml(address); } ); }

BEA Confidential Done!