360 likes | 618 Views
Writing All Your Code In OpenEdge Architect. Peter van Dam. Agenda. Agenda Item 1 Eclipse Plug-ins ABL JavaScript HTML XML OpenEdge GUI for .NET (tomorrow). Installing Plugins. OpenEdge Architect 10.2A is based on Eclipse 3.4 You can install additional Plug-ins. Installing Plugins.
E N D
Writing All Your Code In OpenEdge Architect Peter van Dam
Agenda • Agenda Item 1 • Eclipse Plug-ins • ABL • JavaScript • HTML • XML • OpenEdge GUI for .NET (tomorrow) Making Progress With Ajax
Installing Plugins • OpenEdge Architect 10.2A is based on Eclipse 3.4 • You can install additional Plug-ins
Installing Plugins • Progress Software conveniently provides a number of Plug-ins on the Progress Download Center • These are listed under “Eclipse Components for OpenEdge/Sonic Development Integration” • We are using the Web Tools Project (WTP) • Provides HTML, JavaScript and WSDL editors (among other things)
What Is Ajax? • An inaccurate acronym for the clever combination of the following existing techniques: • Asynchronous data retrieval using XMLHttpRequest • JavaScript • Data interchange and manipulation using XML
What Is Ajax (2)? • It does not have to be Asynchronous • It does not have to be XML • You definitely need JavaScript • Relies heavily on: • DHTML (Dynamic HTML) for DOMmanipulation • CSS (Cascading Style Sheets) in order to separate presentation from data
The Bottom Line: NO PAGE RELOADS!
How To Set Up Google Maps • Obtain a Google Maps Key • Geocode Your Addresses • Create Your Google Maps Web Page • Bonus: Integrate Google Maps with .NET
Obtaining a Google Maps Key • Simply go to http://code.google.com/apis/maps/and follow the instructions • A Key is free for public web sites only • You need a Google Account (also free) • The Key is valid for a single URL • There is no page view limit • There is a limit of 15,000 Geocode requests per day • Of course there is a paid alternative…
How To Set Up Google Maps • Obtain a Google Maps Key • Geocode Your Addresses • Create Your Google Maps Web Page • Bonus: Integrate Google Maps with .NET
What Is Geocoding? • Geocoding is the process of converting addresses into geographical coordinates • A coordinate (any point on earth) is defined by a latitude and a longitude • Latitude is between -90 and + 90 and longitude between -180 and + 180 • They are represented as numbers with 6 decimals • You must add these to the addresses in your database
Google Maps Geocoding Services • Google Maps allows you to geocode 15,000 addresses a day • You can either use a JavaScript object or a direct HTTP request • We can issue HTTP requests from the ABL using httpget.i
Httpget.i • Procedure httpget has 4 input parameters: • Host • Port • Path • File
The Geocoder • The URL is http://maps.google.com/maps/geo? • There are 3 parameters: • key • output • q • Example: key=<yourkey>&output=csv&q=276%20North%20Drive%20%20Burlington%2001730%20USA
Geocoder csv Response HTTP/1.0 200 OK Cache-Control: private Last-Modified: Sun, 27 Jan 2008 13:39:03 GMT Content-Type: text/plain; charset=UTF-8; charset=ISO-8859-1 Set-Cookie: PREF=ID=ca4d6eaca99623eb:TM=1201441143:LM=1201441143:S=fFnZXx06nDdguvB_; expires=Tue, 26-Jan-2010 13:39:03 GMT; path=/; domain=.google.com Server: mfe Date: Sun, 27 Jan 2008 13:39:03 GMT Connection: Close 200,8,42.512095,-71.284913
Geocoder csv Response (2) 200,8,42.512095,-71.284913 • The last line contains 4 items • HTTP status code (200: success) • Accuracy • Latitude • Longitude
How To Set Up Google Maps • Obtain a Google Maps Key • Geocode Your Addresses • Create Your Google Maps Web Page • Bonus: Integrate Google Maps with .NET
How To Call A Progress Server? • You can call the server from JavaScript using the XMLHttpRequest object • This object is the basis for Ajax • The server needs to accept HTTP requests • Two possibilities: • WebSpeed • Web Services • In this example we will use WebSpeed
Web Server Ajax Engine User Interface (HTML) Documents Database Calling Progress Using WebSpeed WebSpeed Ajax Architecture BrowserClient WebSpeed Agent Making Progress With Ajax
Creating the XMLHttpRequest function createRequest() { if (window.XMLHttpRequest) return new XMLHttpRequest(); else return new ActiveXObject("Microsoft.XMLHTTP"); }
Calling the Server from JavaScript var gRequest; function callServer(url) { gRequest = createRequest(); gRequest.open("POST", url, false); gRequest.setRequestHeader("Content-Type","text/xml"); gRequest.send(null); } callServer('<url>'); var data = gRequest.responseXML;
The WebSpeed Program {src/web2/wrap-cgi.i} RUN outputContentType IN web-utilities-hdl ("text/xml":U). DEFINE VARIABLE hTable AS HANDLE NO-UNDO. /* Create and populate temp-table */ hTable:WRITE-XML("STREAM", "WEBSTREAM"). DELETE OBJECT hTable.
Processing the XML in JavaScript <?xml version="1.0"?> <myTable xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <myTableRow> <Name>HangonPotkulautaKy</Name> <Address>Puistokatu7A45</Address> <City>Hanko</City> <latitude>59.82</latitude> <longitude>22.97</longitude> </myTableRow> <myTableRow> <Name>EspoonPallokeskus</Name> <Address>Sinikalliontie18</Address> <City>Espoo</City> <latitude>60.21</latitude> <longitude>24.76</longitude> </myTableRow>
Processing the XML in JavaScript var tableNode = data.getElementsByTagName("myTable")[0]; if (tableNode) { var rowNode = tableNode.firstChild; // first myTableRow while (rowNode) { var yAttr = new Array; var fieldNode = rowNode.firstChild; // first field while (fieldNode) { yAttr[fieldNode.nodeName] = ""; if (fieldNode.firstChild) // text node yAttr[fieldNode.nodeName] = fieldNode.firstChild.nodeValue; fieldNode = fieldNode.nextSibling; // next field } // for each field rowNode = rowNode.nextSibling; // next myTableRow } // for each row } // tableNode
Creating the Map <body onload="load()" onunload="GUnload()"> <table border=1> <tr> <td> <div id="map" style="width: 800px; height: 380px"></div> </td> </tr> </table> </body> var map = new GMap2(document.getElementById("map")); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); // Initialize the map map.setCenter(new GLatLng(0, 0), 0);
Creating the Markers var point = new GLatLng(yAttr["latitude"], yAttr["longitude"]); var title = yAttr["Name"]; var html = "<b>" + title + "</b><br>" + yAttr["Address"] + "<br>" + yAttr["City"]; var marker = createMarker(point, title, html); map.addOverlay(marker); function createMarker(point, title, html) { var options = {title: title}; var marker = new GMarker(point, options); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); return marker; }
Managing Bounds var bounds = new GLatLngBounds(); For each address: // Adjust the center and zoom level bounds.extend(point); map.setCenter(bounds.getCenter()); map.setZoom(map.getBoundsZoomLevel(bounds));
? Questions
www.futureproofsoftware.com peter@futureproofsoftware.com