Notes
Slide Show
Outline
1
Developing With AJAX,
VFP-Style
  • Dave Bernard
  • The Intellection Group, Inc.
  • Duluth GA USA


2
Developing With AJAX, VFP-Style
  • Over 27 years as developer, manager, executive.
  • Developing in FoxPro family since 1990.
  • Vice President, Atlanta FoxPro Users Group.
  • MCSD (VFP), MCDBA (SQL 2000).
  • Develop custom extranets, EDI, PDA/eVC++, TabletPC apps.
  • VFP 9, COM+, SQL Server.
  • ASP/DHTML/CSS/JS, PHP/MySQL.
  • Emerging technology (SR, TTS, NLU, RFID) specialists.


  • There are no technical problems, only business problems.


3
Purpose
  • Define and demonstrate AJAX development techniques.


  • Discuss the past, present and future of AJAX development.


  • Discuss what AJAX means to VFP developers.
4
Agenda
  • Context
  • What, exactly is AJAX?
  • Demos
  • A History of AJAX
  • Why is AJAX suddenly popular?
  • Benefits and Cautions
  • AJAX + VFP?
  • VFP Examples
5
What, exactly is AJAX?
  • Asynchronous Javascript with XML (AJAX); Google engineers refer to their coding technique simply as JavaScript.
  • Consists primarily of DHTML, JavaScript and XMLHTTP ("superglue for web").
  • Create Web apps with mature, freely available technologies.
  • Browser client code calls server side code directly without reposting the entire page back to the Server.
  • Client side code pulls incremental UI updates in response to user action, enhancing the illusion of speed.
  • Contrast this with standard Web applications where typically all business logic and UI creation is managed on the server, with the client browser merely rendering the content.
  • AJAX makes the client an active part of the application.
  • Incidentally, despite the X in the AJAX name, XML is actually not used by most AJAX implementations. XML use is optional.


6
Demos
7
A History of AJAX
  • The pieces of AJAX have been available since 1998 (IE 5).
  • Recently, these pieces, especially XMLHTTP, have become broadly available in a standardized way in all browsers.
  • Start-ups and industry giants such as Microsoft continue to create complex developer tools (e.g., .NET) for delivering desktop-like applications over the Web.
  • That's prompted developers to take a second look at “legacy” technologies such as JavaScript and DTML.


8
Why is AJAX suddenly popular?
  • The interest isn't driven by some dot-com nostalgia.
  • Google Maps, Google Suggest and GMail convinced a mass audience that rich Internet applications deliver great benefits to the end user.
  • Proponents argue these older technologies, already embedded in common Web browsers, are good enough for the job.
  • Someone's given a name to what we've been working on for years, to the idea of using JavaScript and moving it to the next level.
  • It’s an effective interoperability enabler that supports SOA, Web Services, EDI, XML and other integration approaches.
9
Benefits and Cautions
  • Addresses the growing demand for richer Web user experiences.
  • Allows you to deliver applications that users actually enjoy more.
  • The simple "no wait time“ factor.
  • Reduced network traffic.
  • Offloads computation work onto the client.
  • Relies on JavaScript; could be disabled by the user.
  • The XMLHTTP object is an ActiveX object which is probably more serious because many IT departments lock out ActiveX usage on browsers completely.
  • Developing and debugging AJAX-style web applications can be difficult.
10
AJAX + VFP?
  • Similar to hitting a web service
    • Greater control
    • Simpler
    • Thinner
  • Use it from VFP forms, classes, procedural code.
  • VFP COM+ DLLs can be used to serve up web pages.
  • Use AFP, West Wind Web Connection, custom framework.
  • Methods in VFP DLLs are easily accessible via XMLHTTP.
  • http://www.intellectiongroup.com/Resources/SmallFramework.zip


11
MapQuest Example
  • lcSrcAddr  = [175+stanford+ridge]
  • lcSrcCity  = []
  • lcSrcState = []
  • lcSrcZip   = [30097]
  • lcTrgAddr  = [892+North+Main+St]
  • lcTrgCity  = [Alpharetta]
  • lcTrgState = [GA]
  • lcTrgZip   = []
  • lcURL      = [http://www.mapquest.com/directions/main.adp?go=1] +;
  •              [&1a=]  + lcSrcAddr + [&1c=] + lcSrcCity +;
  •              [&1s=] + lcSrcState + [&1z=] + lcSrcZip +;
  •              [&2a=]  + lcTrgAddr + [&2c=] + lcTrgCity +;
  •              [&2s=] + lcTrgState + [&2z=] + lcTrgZip +;
  •              [&2ah=] + [] + [&formtype1=address&formtype2=address]


  • oHTTP = CreateObject("MSXML2.XMLHTTP")
  • oHTTP.Open([GET], lcURL, .F.)
  • oHTTP.Send()
  • lcHTMLcode = oHTTP.ResponseText
  • RELEASE oHTTP


  • lcTarget = [Total Est. Distance:</b>&nbsp;<span>]
  • lnMiles  = VAL(SUBSTR(lcHTMLCode, AT(lcTarget, lcHTMLCode) + LEN(lcTarget), 20))
  • WAIT ALLTRIM(STR(lnMiles, 7, 2)) + " miles away" WINDOW
12
Current Weather Example
  • GetWeather.prg
    • For a given zip code, get the current weather information.
    • Need to be able to handle unavailable sites; two backup sites are used.
    • Need to be able to control site timeouts, too.
    • Need to be able to handle site-specific error messages.
    • Site URL’s and response format can change unexpectedly!
13
Client and Server Example
  • VFP system wants to exchange information with another VFP system across the Internet.
  • Same functionality as a web service.
  • Client component makes requests and receives responses (CWClient.prg).
  • Server component services client requests (CWServer.prg).
14
The End
  • Thanks!


  • Dave Bernard
  • The Intellection Group, Inc.
  • http://www.IntellectionGroup.com
  • dbernard@IntellectionGroup.com


  • http://fox.wikis.com/wc.dll?Wiki~AjaxResources