2009 11 25 ajax training

58
Visual DataFlex AJAX Library 2.0 Eddy Kleinjan, Data Access Europe Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Upload: wjacomine

Post on 04-Mar-2015

39 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 2009 11 25 AJAX Training

Visual DataFlex AJAX Library 2.0

Eddy Kleinjan, Data Access Europe

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 2: 2009 11 25 AJAX Training

• Meet the AJAX Library• Hands-on part 1• Into the AJAX Library• Hands-on part 2

Overview

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 3: 2009 11 25 AJAX Training

The AJAX Library

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 4: 2009 11 25 AJAX Training

• A set of tools to build sophisticated rich web applications for database usage.

• An extension of the Visual DataFlex web application framework.

• Library available at no cost for owners of a Visual DataFlex license.

What is the Visual DataFlex AJAX Library?

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 5: 2009 11 25 AJAX Training

• HTML and JavaScript• No runtime installation• Rich desktop-like controls• Client side validations• Declarative page definition• Supports popular browsers• Ready to use CSS design• Easily switch designs• Get started using the wizards• Complete documentation• Sample applications• Direct custom server calls• 3rd party tool friendly

Features• Data controls

• Input box• Textarea• Select• Checkbox• Radio• Password• Grid• Lookup• Calendar

• Controls• Menu• Modal dialog• Tabcontainer

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 6: 2009 11 25 AJAX Training

• Redesigned JavaScript Client Engine• Dynamically loading JavaScript modules• Form scoped context• Less data• Asynchronous communication• Better debugging with Visual DataFlex 15.0• New graphical designs• Improved mask support (date & numeric masks)• Improved error handling• No need for error place holder

Changes for 2.0

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 7: 2009 11 25 AJAX Training

• AJAX Order Entry• AJAX Contact Management• AJAX Wines

Sample Applications

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 8: 2009 11 25 AJAX Training

What is AJAX?

Without the Visual DataFlex AJAX Library….

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 9: 2009 11 25 AJAX Training

• HTML & CSS– Presentation of the data

• JavaScript– Client-side engine

• DOM Manipulation– The technique to update the displayed page

• XmlHttpRequest– Synchronous & Asynchronous data loading

Involved techniques

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 10: 2009 11 25 AJAX Training

• Hyper Text Markup Language• Standardized by W3C

• More info:– http://www.w3schools.com/html/default.asp

• Standard:– http://www.w3.org/TR/REC-html40/

HTML

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 11: 2009 11 25 AJAX Training

HTML Example

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 12: 2009 11 25 AJAX Training

• Defines the style of HTML elements• Standardized by W3C

• More Info:– http://www.w3schools.com/css/default.asp

• Standard:– http://www.w3.org/Style/CSS/

Cascading Style Sheets (CSS)

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 13: 2009 11 25 AJAX Training

CSS Example

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 14: 2009 11 25 AJAX Training

• Selectors are:– Tagname– Id– Class (<div class=“box”..)– Any property

• Usually in include:

More CSS

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 15: 2009 11 25 AJAX Training

• Script language (ECMAScript)• Not Java!• Runs in the browser on the client

• More info:– http://www.w3schools.com/js/default.asp

JavaScript

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 16: 2009 11 25 AJAX Training

JavaScript Example

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 17: 2009 11 25 AJAX Training

• Very flexible language• Prototypal instead of classical• Can be hard to debug• Case sensitive

• Usually included

More JavaScript

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 18: 2009 11 25 AJAX Training

• Object that is available within the browser and can be used to send HTTP requests.

• Able to handle POST and GET requests.• Designed to load XML but can also handle

plain text.• Also known as the ActiveX component

Msxml2.XMLHTTP.

XmlHttpRequest

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 19: 2009 11 25 AJAX Training

Example XmlHttpRequest

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 20: 2009 11 25 AJAX Training

• Can’t be send cross domain!• Since Internet Explorer 5.5– Before 7 the objects was created using new

ActiveXObject("Msxml2.XMLHTTP");– In IE 7+ and all other browsers:

new XMLHttpRequest();

• The AJAX Library does this for you!

More XmlHttpRequest

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 21: 2009 11 25 AJAX Training

• Document Object Model• Object representation of a HTML page inside a browser• Can be manipulated using JavaScript• Tree structure with properties, collections and events

• More information:– http://www.w3schools.com/htmldom/default.asp

• Standard:– http://www.w3.org/DOM/

DOM

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 22: 2009 11 25 AJAX Training

DOM Example

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 23: 2009 11 25 AJAX Training

• Exposing functionality to the web using a predefined API• SOAP defines the standard in which XML is used as the data

format

• More information:– Visual DataFlex Help– Vincents training yesterday ;)

• Standard:– http://www.w3.org/TR/soap11/

Web Services

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 24: 2009 11 25 AJAX Training

• Script language• Runs on the server in IIS• VBScript syntax• Can communicate with VDF WebApps using

published Web Objects• Usually used to generate HTML pages

ASP

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 25: 2009 11 25 AJAX Training

AJAX & VDF

The whole picture

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 26: 2009 11 25 AJAX Training

Visual DataFlex Applications

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 27: 2009 11 25 AJAX Training

Visual DataFlex Web Applications

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 28: 2009 11 25 AJAX Training

Visual DataFlex Web Applications

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 29: 2009 11 25 AJAX Training

Visual DataFlex AJAX Applications

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 30: 2009 11 25 AJAX Training

Visual DataFlex AJAX Applications

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 31: 2009 11 25 AJAX Training

Into the AJAX Library

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 32: 2009 11 25 AJAX Training

• VDF workspace with only packages• Attached to the application workspace

What is a Library?

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 33: 2009 11 25 AJAX Training

• AppHtml– JavaScript– CSS– Images

• AppSrc– Several classes & packages

AJAX Library Workspace

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 34: 2009 11 25 AJAX Training

• MetaData…– Set of functions used to load meta data of the webapp application

• Request– The main function used to execute find, save, delete and clear actions

• ValidateField– Called to do the asynchronous server side field validation

• RemoteMethodInvocation– Used to make custom server calls to published WO functions

Web service interface

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 35: 2009 11 25 AJAX Training

AJAX VDF WebApp

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 36: 2009 11 25 AJAX Training

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 37: 2009 11 25 AJAX Training

• Within the HTML controls are declared using additional HTML attributes

• The browser loads the HTML page and after it has finished the DOM the AJAX Library engine scans the DOM for the additional HTML attributes

• For each components it includes the JavaScript module (if required)

• After the JavaScript module is loaded it creates an JavaScript object for the component

• The JavaScript component attaches event handlers and starts manipulating the DOM

Declarative HTML API

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 38: 2009 11 25 AJAX Training

HTML Declarations – JavaScript Objects

<form vdfControlType="form" vdfControlName="order_form">

<input type="text" name="orderhea__order_number" />

<input type="text" name="orderhea__order_date" />

<input type="button" vdfControlType="popupcalendar" />

<select name="orderhea__ship_via"></select>

<table vdfControlType="grid" vdfControlName="order_detail"> <tr vdfRowType="header"> <th vdfDataBinding="invt__item_id">Item ID</th> </tr> <tr vdfRowType="display"> <td vdfDataBinding="invt__item_id"></td> </tr> <tr vdfRowType="edit"> <td><input type="text" name="invt__item_id" /></td> </tr> </table></form>

<form vdfControlType="form" vdfControlName="order_form">

<input type="text" name="orderhea__order_number" />

<input type="text" name="orderhea__order_date" />

<input type="button" vdfControlType="popupcalendar" />

<select name="orderhea__ship_via"></select>

<table vdfControlType="grid" vdfControlName="order_detail"> <tr vdfRowType="header"> <th vdfDataBinding="invt__item_id">Item ID</th> </tr> <tr vdfRowType="display"> <td vdfDataBinding="invt__item_id"></td> </tr> <tr vdfRowType="edit"> <td><input type="text" name="invt__item_id" /></td> </tr> </table></form>

vdf.core.Form

vdf.deo.Text

vdf.deo.Text

vdf.gui.PopupCalendar

vdf.deo.Grid

vdf.deo.DOM

vdf.deo.DOM

vdf.deo.Text

vdf.deo.Select

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 39: 2009 11 25 AJAX Training

• Deployment– Minified single JavaScript file– 290KB

• Debug– Single JavaScript file without multi line comments– 463KB

• Full– Separate JavaScript files– 800KB

AJAX Library versions

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 40: 2009 11 25 AJAX Training

• ASP Include

Including the AJAX Library

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 41: 2009 11 25 AJAX Training

• The session system (before <html> tag)

• The toolbar (inside the <body> tag)

Optional server side includes

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 42: 2009 11 25 AJAX Training

Hands on

Create your first AJAX 2.0 application using the Quick Start

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 43: 2009 11 25 AJAX Training

Components

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 44: 2009 11 25 AJAX Training

• The main component of data entry views• Comparable to the dbView in VDF• Maintains references to all controls inside• Rebuilds the DD structure on the client

vdf.core.Form

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 45: 2009 11 25 AJAX Training

• Single line text field• Comparable to the dbForm in VDF• Inherits the DEO interface• Data bindable using its name or the vdfDataBinding

attribute

vdf.core.Text

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 46: 2009 11 25 AJAX Training

• Displays a lookup dialog• Only needs a list of the fields to show• Can be used with and without relations

vdf.core.LookupDialog

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 47: 2009 11 25 AJAX Training

• Displays a grid with multiple records• Comparable to the dbGrid in VDF

vdf.deo.Grid

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 48: 2009 11 25 AJAX Training

• Displays a tab container• Comparable to dbTabDialog in VDF

vdf.gui.TabContainer

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 49: 2009 11 25 AJAX Training

Events

Client-side events

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 50: 2009 11 25 AJAX Training

function InitCustomerForm(oForm){

oForm.getControl("customer__status").onChange.addListener(ShowCustomerStatus);

}

function ShowCustomerStatus(oEvent){

var oElement = document.getElementById("CustomerStatus");if (oEvent.oSource.getValue() == "Y"){

oElement.style.display = "none"}else{

oElement.style.display = "";}

}

Handling events

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 51: 2009 11 25 AJAX Training

• Multiple listeners per event• Can be canceled• Receive an object with information

About events

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 52: 2009 11 25 AJAX Training

• ClientDataDictionary– onBeforeFind– onAfterFind– onBeforeSave– onAfterSave– onValidate

• Field– onChange– onValidate

• Grid / Lookup– onNewRow

Available events

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 53: 2009 11 25 AJAX Training

Custom calls

Calling published VDF functions on the server

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 54: 2009 11 25 AJAX Training

function LoadOrderStatus(iCustomerId){ var oCall = new vdf.ajax.VdfCall("oCustomer",

"GET_CalculateOrders", [ iCustomerId ]); oCall.onFinished.addListener(displayOrderStatus); oCall.send(true);}

function displayOrderStatus(oEvent){ var eElement = document.getElementById("customer_status"); eElement.innerHTML = "Customer status: " +

oEvent.oSource.getReturnValue();}

Sending a custom call

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 55: 2009 11 25 AJAX Training

Hands on

Finish your first AJAX Application using the Quick Start Extended

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 56: 2009 11 25 AJAX Training

• File name: Finished Ajax Library 2.0 Quick Start.zip• The password is: completed

Encrypted zip

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 57: 2009 11 25 AJAX Training

Questions?

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK

Page 58: 2009 11 25 AJAX Training

Thanks!

Eddy Kleinjan, Technical Director, Data Access Europe, November 25th, Wyboston Lakes, UK