Tincat stamp

End-to-end AJAX

Originally Presented to MultiValue Software Developers at
SAPUG June 15, 2006
Modifying in August 2006
Dawn M. Wolthuis
Tincat Group, Inc.
dwolt@tincat-group.com

              AJAX client-server architecture

Mid-level Overview

For the record...


		if (do != "can") { 
			teach(); 
		}
	    

In this session

Architecture

AJAX client-server architecture

Architecture

AJAX client-server architecture

JRE or .NET for Application Run-time Container? Neither.

run-time

Stepping Thru

AJAX client-server architecture

Stepping Thru

AJAX client-server architecture

Sample Web Page

Apologies that the sample code for this example is no longer available

demo1

Stepping Thru

AJAX client-server architecture

Sample xhtml Source Code

demo-html1

Stepping Thru

AJAX client-server architecture

Sample Event is "onblur"

demo2

demo-html2

Stepping Thru

AJAX client-server architecture

Custom JavaScript

demo-js

Stepping Thru

AJAX client-server architecture

Note about listening

Although I wrote that JavaScript "listens" it is the browser that is listening and passing the information to the JavaScript as you have specified.

User sees the screen

demo2b demo-php

Stepping Thru

AJAX client-server architecture

Uses prototype.js AJAX "framework"

demo-js2

Stepping Thru

AJAX client-server architecture

Results without New Page

demo3

Not your Grandma's Web Page

Sample Apps

Let's Go Clockwise Around

run-time2

XHTML: XML version of HTML

ajax-xhtml

XHTML 1.0

Partitions XHTML Tags into Modules

Module (Incomplete List) Tags (Also incomplete)
Block structural div, p
Block phrasal address, blockquote, pre, h1-h6
Inline structural br, span
Inline phrasal abbr, acronym, cite, code, dfn, em, kbd, q, samp, strong, var
Linking a, base, link
Lists dir, dl, dt, dd, ol, ul, li
Simple forms form, input, select, option, textarea
Extended forms button, fieldset, label, legend, optgroup, option, select, textarea
Simple tables table, td, th, tr
Extended tables caption, col, colgroup, tbody, tfoot, thead
Images img
Image maps area, map
Metadata meta, title
Structure html, head, body

Extensive Use of Two Attributes

XHTML Tidbits

Should Get Rid of Gen'ing Server-side HTML

PHP excerpt from the example. Note that I did not obey this, but at least feel guilty

    $cl = 'tr class="cle"';
    $rows = $result->results;
    if(is_Array($rows)) {
      $mz = sizeof($rows);
    } else {
      $rows[0] = $rows;
      $mz = 1;
    }

    for($rx = 0; $rx < $mz; $rx++) {
      if($cl == 'tr class="clo"')
        $cl = 'tr class="cle"';
      else
        $cl = 'tr class="clo"';

      $ret .= '<'.$cl.'>';
      $row = $rows[$rx];
      if(strstr($row, AM)) {
        $row = explode(AM, $row);
        $mx = sizeof($row);
      } else {
        $row[0] = $row;
        $mx = 1;
      }
		

HTML Validator: http://validator.w3.org//

html-valid

The DOM

"The Document Object Model is a platform- and language-neutral interface that will allow programs and scripts to dynamically access and update the content, structure and style of documents, both HTML and XML"

From w3schools.com/dom

Each Page has a DOM

dom

DOM Inspector

dom-inspect

Cascading Style Sheets?

ajax-css

CSS

demo-css

CSS Cross-Browser

But CSS Can be as Cool as csszengarden.com

Each of the pages in this graphic is done with the exact same html, different css

www.csszengarden.com

CSS Current Status

CSS Validator: http://jigsaw.w3.org/css-validator/

css-valid

User Events

ajax-events

Events are User Events

Event Issues

Event possibilities

Validations HCI

From http://justaddwater.dk/2006/02/08/ajax-businesscase/

validation HCI

Human—Event—Service

It's time for JavaScript?

ajax-js

ECMAScript

Executing JavaScript

DOM Methods

getElementById('thisid') or $('thisid') if using prototype.js

dom2 dom-methods

JavaScript Objects

JavaScript Object

JavaScript Object Notation (JSON)

{"Customer": [{
	"lastName": "Doe",
	"firstName": "Jane",
	"hobbies": ["knitting", "tennis"]
	}
]};
		
for
var Customer = {
	lastName: "Doe",
	firstName: "Jane",
	hobbies: ["knitting", "tennis"]
}
		
or
var Customer = new Object(); 
Customer["lastName"] = "Doe";
Customer["firstName"] = "Jane";
Customer["hobbies"] = ["knitting", "tennis"];
		
or
var Customer = {};
Customer.lastName = "Doe";
Customer.firstName = "Jane";
Customer.hobbies = ["knitting", "tennis"];
		

Associative Array

Arrays, don't use them for Associative Arrays

XMLHttpRequest (XHR)

From prototype.js

var Ajax = {
  getTransport: function() {
    return Try.these(
      function() {return new ActiveXObject('Msxml2.XMLHTTP')},
      function() {return new ActiveXObject('Microsoft.XMLHTTP')},
      function() {return new XMLHttpRequest()}
    ) || false;
    ...
	    

Back Button & UNDO

Passing Data

JavaScript Tidbits

Framework Libraries

UI JavaScript Libraries

The Server & Services

ajax-server

Input to the Browser from AJAX Server-side

AJAX client-server architecture

onreadystatechange

Back-end

End-to-end AJAX

Developer Tools

developer

FireFox Add-ins

ff=add-ins

FireFox Developer Tools

ff=dev-tools

Other Tools I Use

Other Resources

Questions?

Wrap-up

Hey, that's it, that's all I've got for now

This talk is available at www.tincat-group.com/talks/ajax.html

             --dawn