Debugging Ajax Pages: Firebug



Similar documents
Web Applications. For live Java training, please see training courses at

JHU/EP Server Originals of Slides and Source Code for Examples:

& JSP Technology Originals of Slides and Source Code for Examples:

2011 Marty Hall An Overview of Servlet & JSP Technology Customized Java EE Training:

What servlets and JSP are all about

Android Programming: Installation, Setup, and Getting Started

Java with Eclipse: Setup & Getting Started

The Google Web Toolkit (GWT): Overview & Getting Started

Building Web Services with Apache Axis2

Virtual Machine (VM) For Hadoop Training

Web Applications. Originals of Slides and Source Code for Examples:

CS Developing Web Applications with Java Technologies

Workshop for WebLogic introduces new tools in support of Java EE 5.0 standards. The support for Java EE5 includes the following technologies:

Application Security

1. Right click using your mouse on the desktop and select New Shortcut.

An Overview of Servlet & JSP Technology

The Google Web Toolkit (GWT): Declarative Layout with UiBinder Basics

Android Programming Basics

Google App Engine f r o r J av a a v a (G ( AE A / E J / )

Official Android Coding Style Conventions

Building and Using Web Services With JDeveloper 11g

Creating Web Services Applications with IntelliJ IDEA

Struts 2 - Practical examples

Administrator s Guide

Hadoop Distributed File System (HDFS) Overview

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

Reference Guide for WebCDM Application 2013 CEICData. All rights reserved.

Debugging JavaScript and CSS Using Firebug. Harman Goei CSCI 571 1/27/13

Installing Drupal on Your Local Computer

The Google Web Toolkit (GWT): The Model-View-Presenter (MVP) Architecture Official MVP Framework

Preface. Motivation for this Book

PingFederate. Identity Menu Builder. User Guide. Version 1.0

PHP+MYSQL, EASYPHP INSTALLATION GUIDE

Eclipse installation, configuration and operation

Creating Java EE Applications and Servlets with IntelliJ IDEA

WA2256 Responsive Mobile Web Development with HTML5, CSS3, JavaScript, and jquery Mobile. Classroom Setup Guide. Web Age Solutions Inc.

Quick Start Guide Mobile Entrée 4

BROWSER-BASED DEVELOPMENT & NETWORK MONITORING UTILITIES

Tutorial on Basic Android Setup

CREATE A CUSTOM THEME WEBSPHERE PORTAL

Usage Tracking for IBM InfoSphere Business Glossary

ITP 101 Project 3 - Dreamweaver

FlexSim LAN License Server

Google Web Toolkit. Introduction to GWT Development. Ilkka Rinne & Sampo Savolainen / Spatineo Oy

Managed Beans II Advanced Features

Macromedia Dreamweaver 8 Developer Certification Examination Specification


Hadoop Streaming coreservlets.com and Dima May coreservlets.com and Dima May

Tutorial: setting up a web application

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

3. Installation and Configuration. 3.1 Java Development Kit (JDK)

Web-JISIS Reference Manual

EVALUATION ONLY. WA2088 WebSphere Application Server 8.5 Administration on Windows. Student Labs. Web Age Solutions Inc.

Operational Decision Manager Worklight Integration

Web-based IDE for Interfacing View Controller

JavaScript Testing. Beginner's Guide. Liang Yuxian Eugene. Test and debug JavaScript the easy way PUBLISHING MUMBAI BIRMINGHAM. k I I.

ConvincingMail.com Marketing Solution Manual. Contents

WA2102 Web Application Programming with Java EE 6 - WebSphere RAD 8.5. Classroom Setup Guide. Web Age Solutions Inc. Web Age Solutions Inc.

Ricardo Perdigao, Solutions Architect Edsel Garcia, Principal Software Engineer Jean Munro, Senior Systems Engineer Dan Mitchell, Principal Systems

ShoreTel Advanced Applications Web Utilities

Advanced Java Client API

CrownPeak Java Web Hosting. Version 0.20

Apache Pig Joining Data-Sets

WebIOPi. Installation Walk-through Macros

Citrix StoreFront. Customizing the Receiver for Web User Interface Citrix. All rights reserved.

Basic Web Fullerton College

Map Reduce Workflows

A Tool for Evaluation and Optimization of Web Application Performance

Installing and using XAMPP with NetBeans PHP

isupplier PORTAL ACCESS SYSTEM REQUIREMENTS

Deploying Intellicus Portal on IBM WebSphere

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

The goal with this tutorial is to show how to implement and use the Selenium testing framework.

To begin, visit this URL:

Dreamweaver CS6 Basics

Installing and Running Tomcat 5.5

Web Development with the Eclipse Platform

Using Adobe Dreamweaver CS4 (10.0)

HDFS Installation and Shell

Tutorial: Building a Dojo Application using IBM Rational Application Developer Loan Payment Calculator

Dostek Remote Support Guide

DeskNow. Ventia Pty. Ltd. Advanced setup. Version : 3.2 Date : 4 January 2007

Virtual Office Remote Installation Guide

NetBeans IDE Field Guide

SSO Plugin. J System Solutions. Upgrading SSO Plugin 3x to 4x - BMC AR System & Mid Tier.

Term Paper. P r o f. D r. E d u a r d H e i n d l. H o c h s c h u l e F u r t w a n g e n U n i v e r s i t y. P r e s e n t e d T o :

SysPatrol - Server Security Monitor

Managed Devices - Web Browser/HiView

In this chapter, we lay the foundation for all our further discussions. We start

SQL Server Database Administration and Design By Dave Peru, October 2011

Crystal Reports for Eclipse

Front-End Performance Testing and Optimization

Table of Contents. Welcome Login Password Assistance Self Registration Secure Mail Compose Drafts...

Installing IBM WDT with Web Development Extension for Power Systems Software

WIRIS quizzes web services Getting started with PHP and Java

Design Approaches of Web Application with Efficient Performance in JAVA

Support Documentation

Welcome to the TransPerfect Translations Secure File Transfer Website What is Secure FTP?

Transcription:

2010 Marty Hall Ajax: Development and Debugging g Tools Originals of Slides and Source Code for Examples: http://courses.coreservlets.com/course-materials/ajax.html Customized Java EE Training: http://courses.coreservlets.com/ Servlets, JSP, JSF 1.x, JSF 2.0, Struts, Ajax, GWT 2.0, GXT, Spring, Hibernate/JPA, Java 5, Java 6. Developed and taught by well-known author and developer. At public venues or onsite at your location. 2010 Marty Hall For live Ajax & GWT training, see training courses at http://courses.coreservlets.com/. t / Taught by the author of Core Servlets and JSP, More Servlets and JSP, and this tutorial. Available at public venues, or customized versions can be held on-site at your organization. Courses developed d and taught by Marty Hall Java 6, servlets/jsp (intermediate and advanced), Struts, JSF 1.x, JSF 2.0, Ajax, GWT 2.0 (with GXT), custom mix of topics Ajax courses Customized can concentrate Java on 1 EE library Training: (jquery, Prototype/Scriptaculous, http://courses.coreservlets.com/ Ext-JS, Dojo, Google Closure) or survey several Courses developed and taught by coreservlets.com experts (edited by Marty) Servlets, Spring, JSP, Hibernate/JPA, JSF 1.x, JSF EJB3, 2.0, Web Struts, Services, Ajax, Ruby/Rails GWT 2.0, GXT, Spring, Hibernate/JPA, Java 5, Java 6. Developed and taught by well-known Contact author hall@coreservlets.com and developer. At public for details venues or onsite at your location.

Topics in This Section Tools for debugging Ajax Tools for debugging JavaScript Tools for building Ajax-based Web apps Tools for developing xhtml Tools for building and previewing style sheets Tools for validating xhtml 4 Debugging Ajax Pages: Firebug 5 Capabilities Debugs JavaScript Shows DOM (including dynamic values) Shows CSS Much more. Very highly recommended. Download site http://getfirebug.com/ Documentation: http://getfirebug.com/docs.html Used with Firefox (not Internet Explorer) But see later link on Firebug Lite Cost Free

Enabling Firebug 6 Firebug and performance Monitoring i network traffic slows down performance of Ajax-intensive sites like Yahoo Mail and Google Maps So most features disabled by default Enabling features Bring up page on site you want to monitor E.g., on localhost Hit Control-F12 Select all windows Press Enable selected panels for localhost To enable permanently, enter sites via Sites entry from tab at top of Console, Script, and Net Bringing Up Firebug Embedded in browser Click on Firebug logo at bottom right Or, hit F12 In separate window Control-click on logo Or, Control-F12 7

Firebug Example.innerHTML example: before button press 8 Firebug Example.innerHTML example: after button press 9

Firebug Logging 10 Firebug has a method called console.log that lets you use printf-like formatting to trace execution Also console.debug, console.info, console.warn, and console.error (same except for icon/color of printout) Details at http://getfirebug.com/console.html Problem It crashes in IE, so you cannot leave in debugging statements when testing on multiple browsers Solution Put in dummy console.log log function for IE See next page, but note that this code is already in my ajax-basics.js file Firebug Logging: Trick for IE // Trick so that the Firebug console.log function will // be ignored (instead of crashing) in Internet Explorer. // Also see Firebug Lite and Faux Console if you want // logging to actually do something in IE. // Firebug Lite: http://www.getfirebug.com/lite.html html // Faux Console: http://icant.co.uk/sandbox/fauxconsole/ try { console.log("loading l script"); } catch(e) { console = { log: function() {} }; } 11

Firebug Logging: Example function showresponsetext(resultregion) { if ((request.readystate readystate == 4) && (request.status == 200)) { console.log("response text is '%s'.", request.responsetext); document.getelementbyid(resultregion).innerhtml = request.responsetext; } } 12 function showtimeincity(resultregion) { var address = "show-time-in-city"; i it " console.log("selected city is '%s'.", getvalue("city")); var data = "city=" + getvalue("city") + "&usehtml=true"; address = address + "?" + data; ajaxresult(address, resultregion); } Firebug Logging: Example These two lines are from console.log. Firebug automatically monitors the outgoing URL, the parameters, the result text, and the HTTP response headers (including cookies). Click here to jump to the line of code that initiated this request. 13

Debugging JavaScript in Internet Explorer 14 Firebug Lite http://getfirebug.com/lite.html See especially the bookmarklet link DebugBar http://www.debugbar.com/ Free for personal, non-commercial use IE Web Developer http://www.ieinspector.com/dominspector/ p p Not free Internet Explorer 8 IE 8 (available as of 4/2009) has an integrated Ajax debugging environment. Not yet as good as Firebug. Debugging in IE 8 (Tools Developer Tools) JavaScript console, debugger, CSS Very good. Based on my limited testing, capabilities appear comparable to Firebug Network tracing None HTML display Major flaw: shows HTML as in original page (l (ala View Source ), not the HTML as modified by JavaScript Example from Ajax Basics I lecture, after result has been inserted in page. IE 8 does not show update, even if you restart tool. 15

16 Debugging JavaScript: Google Chrome Debugger Chrome browser The Chrome browser from Google includes an integrated Ajax debugging environment similar to Firebug JavaScript performance in Chrome is order of magnitude better than IE 7 and slightly better than Firefox Chrome still has very low market penetration As of 9/2009, well behind 3 rd place Safari by most measures Debugging JavaScript: The Firefox JavaScript Console Capabilities Simple JavaScript debugging built in with Firefox Shows error messages and lets you interactively evaluate JavaScript JvSc pvariables besand depessos expressions Nowhere nearly as good as Firebug or Venkman, but better than just Script Error Best approach is to use Firebug on your development machine, but fall back on this when on a third-party PC Open via Tools Error Console 17

Building Ajax-Enabled Web Apps: Eclipse Eclipse is the main development tool Organizes entire project Deploys to local server Always used for Editing Java Editing JavaScript Sometimes used for HTML XML CSS sftp Alternatives MyEclipse NetBeans IntelliJ IDEA 18 Installing Eclipse Overview Eli Eclipse is a free open-source development environment with support for Java and many other languages Downloading http://www.eclipse.org/downloads/ Choose Eclipse IDE for Java EE Developers As of 9/2009, version 3.5, called Eclipse Galileo Installing Unzip into directory of your choice Put shortcut to eclipse.exe on your desktop Integrating Tomcat in Eclipse http://www.coreservlets.com/ com/ Apache-Tomcat-Tutorial/eclipse.html 19

Configuring Eclipse Make sure Eclipse knows about Tomcat Click on Servers tab at bottom. R-click in window. New, Server, Apache, Tomcat v6.0, Next, navigate to folder, Finish. Suppress unnecessary compiler warnings Window Preferences Java Compiler Errors/Warnings Change Serializable class without... to Ignore 20 Making Web Apps in Eclipse Make empty project File New Project Web Dynamic Web Project Giveitaname(eg it (e.g., test ) Accept all other defaults Shortcut If you have made Dynamic Web Project recently in workspace, you can just do File New Dynamic Web Project 21

Adding Code to Eclipse Projects 22 Locations src Unpackaged Java code Packages strongly recommended src/somepackage Java code in somepackage package WebContent Web files (HTML, JavaScript, CSS, JSP, images, etc.) WebContent/some-subdirectory Web content in subdirectory WebContent/WEB-INF t/web web.xml (will be discussed later) Can also click on Deployment Descriptor Note Can cut/paste or drag/drop files into appropriate locations Starting Server in Eclipse 23 Start Tomcat Select Servers tab at bottom R-click on Tomcat Choose Start Verify server startup Open browser Enter http://localhost/ You should see blank directory listing If you want pretty Tomcat welcome page, search for a folder called ROOT in your Eclipse workspace. Copy files from C:\tomcat-dir\webapps\ROOT to that folder

Deploying App in Eclipse Deploy project Select Servers tab at bottom R-click on Tomcat Choose Add and Remove Projects Choose project Press Add Click Finish Restart Server R-click Tomcat at bottom Restart 24 Testing Deployed Apps in Eclipse 25 Start a browser Eclipse also has builtin browser, but I prefer to use Firefox or Internet Explorer Test base URL http://localhost/test/ Test Web content http://localhost/test/hello.html html (case sensitive!) http://localhost/test/hello.jsp If you used subdirectories es http://localhost/test/ some-subdirectory/blah.html Test servlets http://localhost/test/servlet/helloservlet http://localhost/test/servlet/coreservlets.helloservlet2 Note: custom URLs discussed in next section

Building HTML: Dreamweaver 26 Capabilities Very good support for HTML and xhtml Moderate support for CSS Moderate/weak support for JSP I personally develop in Eclipse, but pop the HTML files into Dreamweaver for any extensive editing Download site http://www.adobe.com/products/dreamweaver/ And many third-party sites Cost Expensive! Often accused of being overpriced, but nevertheless Dreamweaver is the single most popular HTML tool Dreamweaver: Example 27

Building CSS Pages: TopStyle Lite Capabilities Building style sheets Has a visual preview of styles Even the free version is better than what Dreamweaver supports. Eclipse has no real CSS support. Download site http://www.newsgator.com/individuals/topstyle/ Default.aspx Look for TopStyle Lite link near bottom Cost Lite version is free 28 TopStyle Lite: Example 29

Validating HTML: CSE HTML Validator Capabilities Powerful and helpful l HTML/xhtml validator Dreamweaver has moderately good validation built in, but not as good as the CSE tool Eclipse also has moderately good xhtml validation, but not as good as Dreamweaver Also see these online validators http://htmlhelp.com/tools/validator/ http://validator.w3.org/ Download site Lite: http://www.htmlvalidator.com/lite/ lid t /lit / Pro: http://www.htmlvalidator.com/ Cost Lite version is free for personal/educational use 30 CSE HTML Validator: Example 31

Summary 32 Monitoring and debugging Ajax Firebug Debugging JavaScript Venkman Firefox JavaScript Console Building Ajax-based Web apps Eclipse Developing xhtml Dreamweaver Building and previewing style sheets TopStyle Lite Validating xhtml CSE HTML Validator Online validators 2010 Marty Hall Questions? Customized Java EE Training: http://courses.coreservlets.com/ Servlets, JSP, JSF 1.x, JSF 2.0, Struts, Ajax, GWT 2.0, GXT, Spring, Hibernate/JPA, Java 5, Java 6. Developed and taught by well-known author and developer. At public venues or onsite at your location.