Client-side Web Engineering From HTML to AJAX



Similar documents
It is highly recommended that you are familiar with HTML and JavaScript before attempting this tutorial.

JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK

Credits: Some of the slides are based on material adapted from

Web application development (part 2) Netzprogrammierung (Algorithmen und Programmierung V)

HTML Forms and CONTROLS

SUBJECT CODE : 4074 PERIODS/WEEK : 4 PERIODS/ SEMESTER : 72 CREDIT : 4 TIME SCHEDULE UNIT TOPIC PERIODS 1. INTERNET FUNDAMENTALS & HTML Test 1

Preface. Motivation for this Book

Internet Technologies

HTML Form Widgets. Review: HTML Forms. Review: CGI Programs

Dynamic Web-Enabled Data Collection

Overview. In the beginning. Issues with Client Side Scripting What is JavaScript? Syntax and the Document Object Model Moving forward with JavaScript

Web Programming Step by Step

AJAX and JSON Lessons Learned. Jim Riecken, Senior Software Engineer, Blackboard Inc.

InternetVista Web scenario documentation

An introduction to creating Web 2.0 applications in Rational Application Developer Version 8.0

Performance Testing for Ajax Applications

c. Write a JavaScript statement to print out as an alert box the value of the third Radio button (whether or not selected) in the second form.

AJAX The Future of Web Development?

Chapter 12: Advanced topic Web 2.0

AJAX. Gregorio López López Juan Francisco López Panea

Web Development 1 A4 Project Description Web Architecture

JavaScript and Dreamweaver Examples

WIRIS quizzes web services Getting started with PHP and Java

IMRG Peermap API Documentation V 5.0

JavaScript Basics & HTML DOM. Sang Shin Java Technology Architect Sun Microsystems, Inc. sang.shin@sun.com

Visualizing a Neo4j Graph Database with KeyLines

Performance Testing Web 2.0. Stuart Moncrieff (Load Testing Guru) /

Intell-a-Keeper Reporting System Technical Programming Guide. Tracking your Bookings without going Nuts!

InPost UK Limited GeoWidget Integration Guide Version 1.1

Building Ajax Applications with GT.M and EWD. Rob Tweed M/Gateway Developments Ltd

Script Handbook for Interactive Scientific Website Building

Spectrum Technology Platform

Example. Represent this as XML

The purpose of jquery is to make it much easier to use JavaScript on your website.

Introduction to XHTML. 2010, Robert K. Moniot 1

CS412 Interactive Lab Creating a Simple Web Form

JavaScript: Client-Side Scripting. Chapter 6

Yandex.Widgets Quick start

Chapter 1 Programming Languages for Web Applications

Introducing Apache Pivot. Greg Brown, Todd Volkert 6/10/2010

Google Web Toolkit (GWT) Architectural Impact on Enterprise Web Application

AJAX and jmaki for Web 2.0 Development using Java. Inyoung Cho Java Technology Evangelist Sun Microsystems, Inc.

MASTERTAG DEVELOPER GUIDE

Website Login Integration

What is AJAX? Ajax. Traditional Client-Server Interaction. What is Ajax? (cont.) Ajax Client-Server Interaction. What is Ajax? (cont.

Outline. 1.! Development Platforms for Multimedia Programming!

ICT 6012: Web Programming

Visualizing an OrientDB Graph Database with KeyLines

JISIS and Web Technologies

WEB DEVELOPMENT COURSE (PHP/ MYSQL)

Introduction to Ajax

Lesson Review Answers

Abusing HTML5. DEF CON 19 Ming Chow Lecturer, Department of Computer Science TuCs University Medford, MA

Web Design Specialist

Slide.Show Quick Start Guide

Sample HP OO Web Application

A Tale of the Weaknesses of Current Client-Side XSS Filtering

Multimedia im Netz Online Multimedia Winter semester 2015/16. Tutorial 03 Major Subject

Course Information Course Number: IWT 1229 Course Name: Web Development and Design Foundation

Configuring iplanet 6.0 Web Server For SSL and non-ssl Redirect

Advanced Web Development SCOPE OF WEB DEVELOPMENT INDUSTRY

Mobile Web Design with HTML5, CSS3, JavaScript and JQuery Mobile Training BSP-2256 Length: 5 days Price: $ 2,895.00

How To Write An Ria Application

Website Planning Checklist

XML Processing and Web Services. Chapter 17

A Tale of the Weaknesses of Current Client-side XSS Filtering

HTML Tables. IT 3203 Introduction to Web Development

TIME SCHEDULE OBJECTIVES

Further web design: HTML forms

Rich Internet Applications

Outline. CIW Web Design Specialist. Course Content

Web Cloud Architecture

jquery Tutorial for Beginners: Nothing But the Goods

Short notes on webpage programming languages

Web application Architecture

«W3Schools Home Next Chapter» JavaScript is THE scripting language of the Web.

Web Development. Owen Sacco. ICS2205/ICS2230 Web Intelligence

IT6503 WEB PROGRAMMING. Unit-I

Modern browsers support many technologies beyond (X)HTML, CSS, and JavaScript.

Adding Panoramas to Google Maps Using Ajax

Chapter 2: Interactive Web Applications

Eclipse Web Tools Platform. Naci Dai (Eteration), WTP JST Lead

Cisco Adaptive Security Appliance (ASA) Web VPN Portal Customization: Solution Brief

Security starts in the head(er)

PELLISSIPPI STATE TECHNICAL COMMUNITY COLLEGE MASTER SYLLABUS CIW JAVASCRIPT FUNDAMENTALS WEB 2300

WebRTC_call. Authorization. function logintowsc() { var wscdemobaseurl = " window.location.href =

Developing XML Solutions with JavaServer Pages Technology

Ajax Design and Usability

Finding XSS in Real World

Transcription:

Client-side Web Engineering From HTML to AJAX SWE 642, Spring 2008 Nick Duan 1 What is Client-side Engineering? The concepts, tools and techniques for creating standard web browser and browser extensions HTML/XHTML/DHTML, CCS, JavaScript (including AJAX), ActiveXScript, etc. Plug-ins: Adobe Flash, QuickTime, etc. Java Applet running inside the browser Tools and techniques for creating nonbrowser based client applications Standalone RSS Reader, Google Desktop, Java WebStart, J2EE web client applications, etc. Emphasis: Dynamic browser-based web applications January 23, 2008 Nick Duan 2 1

HTML as a presentation language HTML serves two purposes Collecting user input to server (HTML Form) Formatting and presenting of data content from server (the rest of HTML) Basic Web browser functions HTTP client responsible for manage communications between client and server HTML parser responsible for converting textual string to graphical objects (e.g. VBControl in Visual Basic, or Swing object in Java) HTML graphic engine responsible for rending the graphic objects January 23, 2008 Nick Duan 3 Converting HTML text into Document Objects Text stream <html> <head> <title> <body> </body> </html> HTML Parser Document Objects document image form area input button text Graphic engine Document objects are programming constructs defined in the same containment hierarchy as the HTML structure W3C standard: Document Object Model (DOM) for HTML and XML) January 23, 2008 Nick Duan 4 2

What is JavaScript? JavaScript is not Java. Invented by Netscape in mid 90s. The latest version is 1.6 JavaScript is a scripting language, initially designed to support user interactions with document objects Provide APIs to access and manipulate document objects. Now a standard supported by all major browser vendors Embedded in HTML pages, extensible to include userspecified functions and libraries Interpreted as the page is loaded Save time and bandwidth for simple manipulations (Data validation, simple math and other functions) A JavaScript program is embedded in a single HTML page, and is executed within the browser when that page is rendered It is not strong-typed, but is case-sensitive. January 23, 2008 Nick Duan 5 JavaScript Example <HTML> <HEAD> <TITLE>Calculator Example</TITLE> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function a_plus_b(form) { a=eval(form.a.value) b=eval(form.b.value) c=a+b form.ans.value = c // End --> </SCRIPT> </HEAD> <H1>Calculator Example</H2> <TABLE> <TR> <TD><input type=text size=4 value=12 name="a"> </TD> A JavaScript program is defined as a set of functions within the <script> element embedded in the <head> element of the same HTML page Invocation of JavaScript functions are either during loading the page or via user events generated in an HTML form. Most DOM objects contains one or more event handlers <TD width=30><input type="button" value=" + " onclick="a_plus_b(this.form)"> <input type="button" value=" - " size="20" onclick="a_minus_b(this.form)"> January 23, 2008 Nick Duan 6 3

JavaScript as an OO language Standard global objects Array, Boolean, Date, Error, Number, Object, String, Each has its own properties and methods Global functions Object constructors, eval, decodeurl, encodeurl, parseint, Statements if.. else, for, while, do.. while, function, Operators +, -, *, /, ++, --,, &, >>, <<,. January 23, 2008 Nick Duan 7 The JavaScript object hierarchy Standard Global Objects Object BOM Objects Array String Math Error Window Navigator Location History document Frame Plugin MineType form link anchor area image DOM Objects textarea text button password checkbox select January 23, 2008 Nick Duan 8 4

Accessing DOM objects Use document as the default document of the HTML page (since one document object per page) Define the first hyperlink in the HTML page <A href= next.html name = next >next</a> Access the link object via the document object as a property document.links[0].onclick = verify; Same as Note: document.links[ next ] is an invalid expression <A href= next.html name = next onclick= verify(); >next</a> Since the initial HTML construct is fixed, you should be able to access any DOM object via the form document.x.y.z Dynamicity: to obtain/change values of the objects, or add or remove objects of the page January 23, 2008 Nick Duan 9 JavaScript Applications Two major purposes: I. Build HTML dynamically when page is loaded II. Monitor user events and take action Classes of applications 1. Customizing web pages 2. Making web pages more dynamic 3. Validating user input in HTML forms 4. Manipulating cookies 5. Interacting with frames 6. Create Asynchronous JavaScript and XML applications (AJAX) January 23, 2008 Nick Duan 10 5

What is AJAX A suite of development technique for creating fine-tuned interactive web applications at the document component level (instead of a the page level) The term was introduced by Jesse James Garrett in early 2005, but the underlying technologies are much older: New JavaScript object - XMLHttpRequest (initially invented by Microsoft in IE5, now a standard of W3C) XML (used as the data transfer format) DOM, CSS, etc. January 23, 2008 Nick Duan 11 Web Client Converting HTML text into Document Objects HTML Page with JavaScript Program document XMLHttpRequest Document Objects XML or other structure Web Server image form area input button text HTML Web Server XMLHttpRequest is able to make remote connections to a different web server. It can be considered as an embedded web client XML (HTML as being a subset of XML) is primarily used as the payload format for XMLHttpRequest January 23, 2008 Nick Duan 12 6

The XMLHttpRequest Object Event Handler: onreadystatechange; State constants: UNSENT = 0; OPENED = 1; HEADERS_RECEIVED = 2; LOADING = 3; DONE = 4; Read-only Attribute: readystate responsetext responsexml status statustext Methods open (in DOMString method, in DOMString url); open (in DOMString method, in DOMString url, in boolean async); open (in DOMString method, in DOMString url, in boolean async, in DOMString user); open (in DOMString method, in DOMString url, in boolean async, in DOMString user, in DOMString password); setrequestheader (in DOMString header, in DOMString value); send(); send(in DOMString data); send(in Document data); abort(); getallresponseheaders(); getresponseheader(in DOMString header);; January 23, 2008 Nick Duan 13 AJAX Example function AjaxRequest() { var requestobj; if (window.xmlhttprequest) { requestobj = new XMLHttpRequest(); else { requestobj = new ActiveXObject("Microsoft.XMLHTTP"); requestobj.onreadystatechange = function() { if (requestobj.readystate == 4) { if (requestobj.status == 200) { var data = requestobj.responsexml; document.textarea[0].value=data; var url = http://www.google.com ; requestobj.open( GET, url, true); Compatibility Test with older version of IE Inline Callback Function for the Request Object January 23, 2008 Nick Duan 14 7

Putting it together <html> <head> <script language= javascript > function AjaxRequest() {.. </script> </head> <body> <textarea rows="20" cols= 40"> <form> <input type= button value= GetText onclick= AjaxReqest() > </form> </body> January 23, 2008 Nick Duan 15 Leading the Wave of Web 2.0 AJAX is a convenient way to create Rich Client Applications Building AJAX through frameworks (Widgets and server site components for rapid web development) DOJO JaxBe Google Web Toolkit (GWT) Direct Web Remoting (DWR) Ajax JSP Tag Library AJAX Framework for Java and.net Main techniques behind Data Mash-ups in Web 2.0 Customized API on top of the XMLHttpRequest API GoogleMaps, MicroSoft Maps, Yahoo Pipes, etc. January 23, 2008 Nick Duan 16 8

HTML Specs Online References http://www.w3.org/hml DOM Specs http://www.w3.org/dom/ JavaScript Reference and Tutorials http://developer.mozilla.org/en/docs/core_javascript_ 1.5_Reference http://www.w3schools.com/js/default.asp AJAX References http://developer.mozilla.org/en/docs/ajax http://www.w3schools.com/ajax/default.asp http://www.w3.org/tr/xmlhttprequest/#ref-ecmascript January 23, 2008 Nick Duan 17 Summary Client-side engineering is moving from simple HTML page design to more robust rich client applications as higher bandwidth becomes available The development of rich client applications request the use of a combination of client-side techniques, including DOM/XTML, CSS, JavaScript, AJAX, etc. JavaScript provide a dynamic and programmatic way to manipulate web page component. It is the de-facto standard supported by all major browser vendors. AJAX applications, based on the use of XMLHttpRequest object, have the advantage of interacting with remote services at the page component level, enabling partial update of web pages and data mash-ups from multiple data sources at the client side January 23, 2008 Nick Duan 18 9

Quiz What is the syntax in JavaScript for getting the value of the first input field of an HTML page? Create a simple JavaScript program that ensures an input field value to be numeric Create an AJAX program that sends a text message to a server What are the design considerations for creating an AJAX application? January 23, 2008 Nick Duan 19 10