B a s e d o n S c h a u m ’ s Outline of HTML b y D av e M e r c e r A b r i d g e m e n t E d i t o r C h r i s t i n e S h a n n o n , Ph.D.
Contents Chapter 1 Introduction to HTML 1 Chapter 2 HTML Page Formatting Basics 13 Chapter 3 Advanced Web Page Formatting 28 Chapter 4 Web Graphics Basics 42 Chapter 5 Advanced Web Graphics 53 Chapter 6 Tables and Frames 62 Chapter 7 Web Page Forms 78 Chapter 8 Cascading Style Sheets and Dynamic HTML 93 Chapter 9 The XHTML Specification 105 Chapter 10 Introduction to XML 1.0 and the Future 117 Appendix HTML Start Tag Reference 129 Index 133
Thomas A. Powell Osborne/McGraw-Hill Berkeley New York St. Louis San Francisco Auckland Bogotá Hamburg London Madrid Mexico City Milan Montreal New Delhi Panama City Paris São Paulo Singapore Sydney Tokyo Toronto
Scott Duffy McGraw-Hill/Osborne New York Chicago San Francisco Lisbon London Madrid Mexico City Milan New Delhi San Juan Seoul Singapore Sydney Toronto
1. Introductory Concepts ............................................................................. 1 1.1 Introducing the Tools ...................................................................... 1 1.1.1 What Is an HTML Document?.............................................. 1 1.1.2 What Is Jav aScript?............................................................... 3 1.1.3 How Do You Create HTML/Ja vaScript Documents? 4 1.1.4 Some Typographic Conventions Used in This Book 7 1.1.5 Where Should I Look for More Information about HTML and Jav aScript? .............................................. 7 1.2 Your First HTML/Jav aScript Documents ....................................... 8 1.3 Accessing HTML Documents on the Web.................................... 16 1.4 Another Example .......................................................................... 18
2. HTML Document Basics......................................................................... 21 2.1 Documents, Elements, Attributes, and Values .............................. 21 2.1.1 Essential Elements .............................................................. 21 2.1.2 Some Other Imp ortant Elements......................................... 22 2.2 HTML Syntax and Style ............................................................... 29 2.3 Using the script Element ........................................................... 30 2.4 Creating and Organizing a Web Site............................................. 31 2.5 Selecting and Using Colors........................................................... 35 2.6 Using Cascading Style Sheets ....................................................... 36 2.7 Another Example .......................................................................... 42
3. HTML Tables, Forms, and Lists .............................................................. 43 3.1 The table Element ...................................................................... 43 3.1.1 Basic Table Formatting....................................................... 43 3.1.2 Merging Cells across Rows and Columns............................ 45 3.2 The form Element......................................................................... 49 3.3 Creating Pull-Down Lists.............................................................. 53 3.4 Combining Tables and Forms ....................................................... 54 3.5 E-Mailing the Contents of Forms.................................................. 57 3.6 The List Elements ......................................................................... 59 3.7 Another Example .......................................................................... 64 4. Fundamentals of the Jav aScript Language.................................................... 67 4.1 Capabilities of Jav aScript.............................................................. 67 4.2 Some Essential Terminology ........................................................ 69 4.3 Structure of Jav aScript Code......................................................... 70 4.3.1 Jav aScript Statements ......................................................... 70 4.3.2 Statement Blocks ................................................................ 71 4.3.3 Comments ........................................................................... 71 4.4 Data and Objects ........................................................................... 73 4.4.1 Data Declarations and Variables......................................... 73 4.4.2 Data Types .......................................................................... 74 4.4.3 Literals ................................................................................ 75 4.4.4 Case Sensitivity................................................................... 75 4.4.5 Objects and Methods for Input and Output......................... 76 4.4.6 String Methods.................................................................... 78 4.5 Tokens, Operators, Expressions, and Statements.......................... 80 4.5.1 Tokens................................................................................. 80 4.5.2 Arithmetic Operators .......................................................... 81 4.5.3 The Assignment Operator ................................................... 82 4.5.4 Shorthand Arithmetic/Assignment Operators..................... 83 4.6 The Jav aScript Math Object.......................................................... 85 4.7 Comparison Operators and Decision-Making Structures.............. 90 4.7.1 Relational and Logical Operators ....................................... 90 4.7.2 The if Construct (Branching Structures) ........................... 90 4.7.3 The switch Construct........................................................ 95 4.8 Loop Structures ............................................................................. 97 4.8.1 Count-Controlled Loops ..................................................... 97 4.8.2 Conditional Loops............................................................... 99 4.9 Using Jav aScript to Change Values in Form Fields.................... 102 4.10 Another Example......................................................................... 105
5. Using Arrays in HTML/Ja vaScript ........................................................107 5.1 Basic Array Properties ................................................................ 107 5.2 Some Operations on Arrays ........................................................ 111 5.2.1 Manipulating Stacks and Queues...................................... 111 5.2.2 Sorting............................................................................... 114 5.3 Creating Two-Dimensional Arrays ............................................. 115 5.4 Using Arrays to Access the Contents of Forms .......................... 118 5.4.1 Accessing Values of type= text Fields ...................... 118 5.4.2 Accessing type= radio and type= checkbox Fields................................................................................. 120 5.5 Hiding the Contents of a Jav aScript Script ................................. 122 5.6 Another Example ........................................................................ 124 6. Jav aScript Functions............................................................................. 127 6.1 The Purpose of Functions in Programming................................. 127 6.2 Defining Ja vaScript Functions .................................................... 128 6.3 Using Ja vaScript Functions with HTML Forms ......................... 131 6.3.1 Using Numerical Values as Input ..................................... 132 6.3.2 Using Field Name value Attributes as Input................... 135 6.3.3 Using Field Names as Input.............................................. 135 6.3.4 Using Entire Forms as Input ............................................. 136 6.4 Some Global Methods and Event Handlers .............................. 140 6.4.1 Global Methods .............................................................. 140 6.4.2 Using Event Handlers with Forms and Functions ............ 143 6.5 Recursive Functions .................................................................... 144 6.6 Passing Values from One Document to Another ........................ 149 6.7 Revisiting the Jav aScript sort() Method ................................. 151 6.8 More Examples ........................................................................... 152
Appendices .............................................................................................169 A.1 HTML Document Examples ...................................................... 169 A.2 Displaying Special Characters in an HTML Document ............. 171
Preface xix Before You Begin xxxi Part 1: Introduction 1 1 Dive Into® Web 2.0 2 1.1 Introduction 3 1.2 What Is Web 2.0? 4 1.3 Search 7 1.4 Content Networks 12 1.5 User-Generated Content 13 1.6 Blogging 16 1.7 Social Networking 19 1.8 Social Media 23 1.9 Tagging 26 1.10 Social Bookmarking 28 1.11 Software Development 29 1.12 Rich Internet Applications (RIAs) 32 1.13 Web Services, Mashups, Widgets and Gadgets 34 1.14 Location-Based Services 37 1.15 XML, RSS, Atom, JSON and VoIP 38 1.16 Web 2.0 Monetization Models 39 1.17 Web 2.0 Business Models 41 1.18 Future of the Web 44 1.19 Where to Go for More Web 2.0 Information 48 1.20 Web 2.0 Bibliography 49 1.21 Web 2.0 Glossary 56 Part 2: The Ajax Client 66 2 Introduction to XHTML 67 2.1 Introduction 68 2.2 Editing XHTML 69 2.3 First XHTML Example 69 2.4 W3C XHTML Validation Service 72 2.5 Headings 72 Cx Contents 2.6 Linking 73 2.7 Images 76 2.8 Special Characters and Horizontal Rules 79 2.9 Lists 81 2.10 Tables 84 2.11 Forms 88 2.12 Internal Linking 95 2.13 meta Elements 98 2.14 Web Resources 99 3 Cascading Style Sheets™ (CSS) 100 3.1 Introduction 101 3.2 Inline Styles 102 3.3 Embedded Style Sheets 103 3.4 Conflicting Styles 106 3.5 Linking External Style Sheets 109 3.6 Positioning Elements 111 3.7 Backgrounds 115 3.8 Element Dimensions 116 3.9 Box Model and Text Flow 118 3.10 Media Types 122 3.11 Building a CSS Drop-Down Menu 124 3.12 User Style Sheets 126 3.13 CSS 3 130 3.14 Web Resources 130 4 Jav aScript: Introduction to Scripting 131 4.1 Introduction 132 4.2 Simple Program: Displaying a Line of Text in a Web Page 133 4.3 Modifying Our First Program 136 4.4 Obtaining User Input with prompt Dialogs 141 4.4.1 Dynamic Welcome Page 141 4.4.2 Adding Integers 145 4.5 Data Types in Jav aScript 147 4.6 Arithmetic 147 4.7 Decision Making: Equality and Relational Operators 148 4.8 Web Resources 152 5 Ja vaScript: Control Statements I 153 5.1 Introduction 154 5.2 Control Statements 154 5.3 if Selection Statement 155 5.4 if…else Selection Statement 156 5.5 while Repetition Statement 160 5.6 Counter-Controlled Repetition 161Contents xi 5.7 Formulating Algorithms: Sentinel-Controlled Repetition 163 5.8 Formulating Algorithms: Nested Control Statements 166 5.9 Assignment Operators 169 5.10 Increment and Decrement Operators 170 5.11 Web Resources 173 6 Jav aScript: Control Statements II 174 6.1 Introduction 175 6.2 Essentials of Counter-Controlled Repetition 175 6.3 for Repetition Statement 177 6.4 Examples Using the for Statement 181 6.5 switch Multiple-Selection Statement 185 6.6 do…while Repetition Statement 190 6.7 break and continue Statements 192 6.8 Labeled break and continue Statements 195 6.9 Logical Operators 197 6.10 Web Resources 202 7 Jav aScript: Functions 203 7.1 Introduction 204 7.2 Program Modules in JavaScript 204 7.3 Programmer-Defined Functions 205 7.4 Function Definitions 205 7.5 Random Number Generation 210 7.6 Example: Game of Chance 215 7.7 Another Example: Random Image Generator 222 7.8 Scope Rules 223 7.9 JavaScript Global Functions 226 7.10 Recursion 227 7.11 Recursion vs. Iteration 230 7.12 Web Resources 231 8 Jav aScript: Arrays 232 8.1 Introduction 233 8.2 Arrays 233 8.3 Declaring and Allocating Arrays 234 8.4 Examples Using Arrays 235 8.5 Random Image Generator Using Arrays 242 8.6 References and Reference Parameters 243 8.7 Passing Arrays to Functions 244 8.8 Sorting Arrays 247 8.9 Multidimensional Arrays 249 8.10 Building an Online Quiz 253 8.11 Web Resources 255xii Contents 9 Jav aScript: Objects 256 9.1 Introduction 257 9.2 Introduction to Object Technology 257 9.3 Math Object 260 9.4 String Object 261 9.4.1 Fundamentals of Characters and Strings 261 9.4.2 Methods of the String Object 262 9.4.3 Character-Processing Methods 264 9.4.4 Searching Methods 265 9.4.5 Splitting Strings and Obtaining Substrings 268 9.4.6 XHTML Markup Methods 269 9.5 Date Object 272 9.6 Boolean and Number Objects 277 9.7 document Object 278 9.8 window Object 279 9.9 Using Cookies 284 9.10 Multipage HTML and JavaScript Application 288 9.11 Using JSON to Represent Objects 296 9.12 Web Resources 297 10 Document Object Model (DOM): Objects and Collections 298 10.1 Introduction 299 10.2 Modeling a Document: DOM Nodes and Trees 299 10.3 Traversing and Modifying a DOM Tree 302 10.4 DOM Collections 313 10.5 Dynamic Styles 315 10.6 Summary of the DOM Objects and Collections 321 10.7 Web Resources 322 11 Jav aScript: Events 323 11.1 Introduction 324 11.2 Registering Event Handlers 324 11.3 Event onlo ad 327 11.4 Event onmou semove, the event Object and this 328 11.5 Rollovers with onm ouseover and onmo useout 333 11.6 Form Processing with onfo cus and on blur 338 11.7 Form Processing with ons ubmit and onr eset 341 11.8 Event Bubbling 343 11.9 More Events 345 11.10 Web Resources 346 12 XML and RSS 347 12.1 Introduction 348
on 453 14.2 Flash Movie Development 454 14.3 Learning Flash with Hands-On Examples 456 14.3.1 Creating a Shape with the Oval Tool 458 14.3.2 Adding Text to a Button 460 14.3.3 Converting a Shape into a Symbol 461 14.3.4 Editing Button Symbols 463 14.3.5 Adding Keyfr ames 464 14.3.6 Adding Sound to a Button 465 14.3.7 Verifying Changes with Test Movie 466 14.3.8 Adding Layers to a Movie 467 14.3.9 Animating Text with Tweening 468 14.3.10 Adding a Text Field 470 14.3.11 Adding Acti onSc ript 471 14.4 Publishing Your Flash Movie 472xiv Contents 14.5 Creating Special Effects with Flash 473 14.5.1 Impoting and Manipulating Bitmaps 473 14.5.2 Creating an Advertisement Banner with Masking 474 14.5.3 Adding Online Help to Forms 477 14.6 Creating a Website Splash Screen 485 14.7 ActionS cript 491 14.8 Web Resources 491 15 Adobe® Flash® CS3: Building an Interactive Game 492 15.1 Introduction 493 15.2 Object-Oriented Programming 495 15.3 Objects in Flash 495 15.4 Cannon Game: Preliminary Instructions and Notes 497 15.5 Adding a Start Button 498 15.6 Creating Moving Objects 498 15.7 Adding the Rotating Cannon 503 15.8 Adding the Cannonball 505 15.9 Adding Sound and Text Objects to the Movie 508 15.10 Adding the Time Counter 509 15.11 Detecting a Miss 511 15.12 Adding Collision Detection 512 15.13 Finishing the Game 515 15.14 Act ionSc ript 3.0 Elements Introduced in This Chapter 516 16 Adobe® Flex™ 2 and Rich Internet Applications 517 16.1 Introduction 518 16.2 Flex Platform Overview 519 16.3 Creating a Simple User Interface 520 16.4 Accessing XML Data from Your Application 531 16.5 Interacting with Server-Side Applications 545 16.6 Customizing Your User Interface 554 16.7 Creating Charts and Graphs 558 16.8 Connection Independent RIAs on the Desktop: Adobe Integrated Runtime (AIR) 566 16.9 Flex 3 Beta 567 16.10 Web Resources 567 Part 4: Rich Internet Application Server Technologies 568 17 Web Servers (IIS and Apache) 569 17.1 Introduction 570Contents xv 17.2 HTTP Transactions 570 17.3 Multitier Application Architecture 574 17.4 Client-Side Scripting versus Server-Side Scripting 575 17.5 Accessing Web Servers 576 17.6 Microsoft Internet Information Services (IIS) 576 17.6.1 Microsoft Internet Information Services (IIS) 5.1 and 6.0 576 17.6.2 Microsoft Internet Information Services (IIS) 7.0 579 17.7 Apache HTTP Server 581 17.8 Requesting Documents 583 17.9 Web Resources 584 18 Database: SQL, MySQL, ADO.NET 2.0 and Java DB 585 18.1 Introduction 586 18.2 Relational Databases 587 18.3 Relational Database Overview: A books Database 588 18.4 SQL 591 18.4.1 Basic SELECT Query 591 18.4.2 WHERE Clause 592 18.4.3 ORDER BY Clause 594 18.4.4 Combining Data from Multiple Tables: INNER JOIN 596 18.4.5 INSERT Statement 597 18.4.6 UPDATE Statement 598 18.4.7 DELETE Statement 599 18.5 MySQL 600 18.6 Instructions for Installing MySQL 600 18.7 Instructions for Setting Up a MySQL User Account 601 18.8 Creating a Database in MySQL 602 18.9 ADO.NET Object Model 602 18.10 Java DB/Apache Derby 604 18.11 Web Resources 604 19 PHP 606 19.1 Introduction 607 19.2 PHP Basics 608 19.3 String Processing and Regular Expressions 618 19.3.1 Comparing Strings 618 19.3.2 Regular Expressions 619 19.4 Form Processing and Business Logic 623 19.5 Connecting to a Database 630 19.6 Using Cookies 634 19.7 Dynamic Content 640 19.8 Operator Precedence Chart 649 19.9 Web Resources 651xvi Contents 20 Ruby on Rails 652 20.1 Introduction 653 20.2 Ruby 653 20.3 Rails Framework 660 20.4 ActionContr oller and ActionView 662 20.5 A Database-Driven Web Application 665 20.6 Case Study: Message Forum 670 20.6.1 Logging In and Logging Out 670 20.6.2 Embellishing the Models 674 20.6.3 Generating Scaffold Code 676 20.6.4 Forum Controller and Forum Views 677 20.6.5 Message Controller and Message Views 682 20.6.6 Ajax-Enabled Rails Applications 686 20.7 Script.aculo.us 691 20.8 Web Resources 699 21 ASP.NET 2.0 and ASP.NET Ajax 700 21.1 Introduction 701 21.2 Creating and Running a Simple Web Form Example 702 21.2.1 Examining an ASPX File 703 21.2.2 Examining a Code-Behind File 705 21.2.3 Relationship Between an ASPX File and a Code-Behind File 706 21.2.4 How the Code in an ASP.NET Web Page Executes 706 21.2.5 Examining the XHTML Generated by an ASP.NET Application 707 21.2.6 Building an ASP.NET Web Application 708 21.3 Web Controls 716 21.3.1 Text and Graphics Controls 716 21.3.2 AdRotator Control 721 21.3.3 Validation Controls 726 21.4 Session Tracking 737 21.4.1 Cookies 738 21.4.2 Session Tracking with HttpSessionState 746 21.5 Case Study: Connecting to a Database in ASP.NET 753 21.5.1 Building a Web Form That Displays Data from a Database 754 21.5.2 Modifying the Code-Behind File for the Guestbook Application 763 21.6 Case Study: Secure Books Database Application 765 21.6.1 Examining the Completed Secure Books Database Application 765 21.6.2 Creating the Secure Books Database Application 769 21.7 ASP.NET Ajax 793 21.8 Web Resources 797 22 JavaServer™ Faces Web Applications 798 22.1 Introduction 799 22.2 Java Web Technologies 800Contents xvii 22.2.1 Servlets 800 22.2.2 JavaServer Pages 801 22.2.3 JavaServer Faces 802 22.2.4 Web Technologies in Netbeans 802 22.3 Creating and Running a Simple Application in Netbeans 803 22.3.1 Examining a JSP File 804 22.3.2 Examining a Page Bean File 806 22.3.3 Event-Processing Life Cycle 810 22.3.4 Relationship Between the JSP and Page Bean Files 811 22.3.5 Examining the XHTML Generated by a Java Web Application 811 22.3.6 Building a Web Application in Netbeans 813 22.4 JSF Components 820 22.4.1 Text and Graphics Components 820 22.4.2 Validation Using Validator Components and Custom Validators 825 22.5 Session Tracking 833 22.5.1 Cookies 834 22.5.2 Session Tracking with the SessionBean Object 846 22.6 Web Resources 856 23 Ajax-Enabled JavaServer™ Faces Web Applications 858 23.1 Introduction 859 23.2 Accessing Databases in Web Applications 860 23.2.1 Building a Web Application That Displays Data from a Database 860 23.2.2 Modifying the Page Bean File for the AddressBook Application 869 23.3 Ajax-Enabled JSF Components 872 23.4 AutoComplete Text Field and Virtual Forms 873 23.4.1 Configuring Virtual Forms 874 23.4.2 JSP File with Virtual Forms and an AutoComplete Text Field 875 23.4.3 Providing Suggestions for an AutoComplete Text Field 879 23.5 Google Maps Map Viewer Component 881 23.5.1 Obtaining a Google Maps API Key 882 23.5.2 Adding a Map Viewer Component to a Page 882 23.5.3 JSP File with a Map Viewer Component 883 23.5.4 Page Bean That Displays a Map in the Map Viewer Component 887 23.6 Web Resources 890 24 Web Services 891 24.1 Introduction 892 24.2 Java Web Services Basics 894 24.3 Creating, Publishing, Testing and Describing a Web Service 894 24.3.1 Creating a Web Application Project and Adding a Web Service Class in Netbeans 895 24.3.2 Defining the HugeInteger Web Service in Netbeans 895 24.3.3 Publishing the HugeInteger Web Service from Netbeans 900xviii Contents 24.3.4 Testing the HugeInteger Web Service with Sun Java System Application Server’s Tester Web page 900 24.3.5 Describing a Web Service with the Web Service Description Language (WSDL) 904 24.4 Consuming a Web Service 905 24.4.1 Creating a Client in Netbe ans to Consume the HugeInt eger Web Service 905 24.4.2 Consuming the HugeInte ger Web Service 908 24.5 SOAP 914 24.6 Session Tracking in Web Services 915 24.6.1 Creating a Blackjack Web Service 916 24.6.2 Consuming the Blackjack Web Service 920 24.7 Consuming a Database-Driven Web Service from a Web Application 931 24.7.1 Configuring Java DB in Netbeans and Creating the Reservation Database 931 24.7.2 Creating a Web Application to Interact with the Reservation Web Service 934 24.8 Passing an Object of a User-Defined Type to a Web Service 939 24.9 REST-Based Web Services in ASP.NET 949 24.9.1 REST-Based Web Service Functionality 950 24.9.2 Creating an ASP.NET REST-Based Web Service 954 24.9.3 Adding Data Components to a Web Service 957 24.10 Web Resources 960 Index 962
Contents Preface ....................................................................................................... V Motivation for this Book ....................................................................... V Who Should Read this Book?...............................................................VI Outline to the Book Structure ............................................................. VII Prerequisite Skills .............................................................................. VIII Acknowledgements ........................................................................... VIII About the Author ..................................................................................IX Contents ................................................................................................... XI 1 What is Ajax?..........................................................................................1 1.1 Introduction ......................................................................................1 1.2 What is XMLHttpRequest? ..............................................................2 1.3 XMLHttpRequest Object Properties.................................................2 1.3.1 The readyState Property ............................................................3 1.3.2 The onreadystate change Property..............................................3
1.3.3 The responseText Property........................................................3 1.3.4 The responseXML Property ......................................................4 1.3.5 The status Property ....................................................................4 1.3.6 The statusText Property.............................................................4 1.4 XMLHttpRequest Object Methods...................................................5 1.4.1 The abort() Method....................................................................5 1.4.2 The open() Method ....................................................................5 1.4.3 The send() Method.....................................................................5 1.4.4 The setRequestHeader() Method ...............................................6 1.4.5 The getResponseHeader() Method ............................................6 1.4.6 The getAllResponseHeaders() Method......................................6 1.5 Sending an Ajax Request..................................................................7 1.6 Processing an Ajax Request..............................................................8 1.7 JDeveloper Integrated JavaScript Editor ........................................ 10 1.8 Summary......................................................................................... 17 2 Developing an Ajax Web Application................................................. 19 2.1 Introduction .................................................................................... 19 2.2 Setting the Environment ................................................................. 19 2.3 Sending an Ajax Request................................................................ 29 2.4 Processing an Ajax Request on the Server Side ............................. 31 2.5 Processing an Ajax Response........................................................ 35 2.6 Summary ....................................................................................... 44 3 Less JavaScript with Prototype ........................................................... 45 3.1 Introduction .................................................................................... 45 3.2 Overview of Prototype.................................................................... 45 3.2.1 $() function .............................................................................. 45 3.2.2 $F() function........................................................................... 46 3.2.3 $A() function .......................................................................... 46 3.2.4 $H() function ........................................................................... 46 3.2.5 $R() function .......................................................................... 46 3.2.6 $w() Function .......................................................................... 47 3.2.7 Try.these function() ................................................................ 47 3.2.8 Ajax.Request Class................................................................. 47 3.2.9 Ajax.Updater Class.................................................................. 49 3.2.10 Ajax.PeriodicalUpdater Class .............................................. 50 3.3 Installing Prototype ....................................................................... 50 3.4 Configuring Prototype in AJAX Web Application........................ 51 3.5 Updating a DOM Element with Ajax.Updater ............................... 58 3.6 Summary......................................................................................... 60 4 Ajax with Java-GWT ........................................................................... 61 4.1 Introduction .................................................................................... 61 4.2 Installing GWT ............................................................................... 61 4.3 Creating a GWT Application.......................................................... 62 4.4 GWT Class Libraries ...................................................................... 75 4.5 Creating a Form Validation Ajax Application................................ 77 4.6 Summary......................................................................................... 87 5 Ajax with Java-DWR ........................................................................... 89 5.1 Introduction .................................................................................... 89 5.2 Setting the Environment ................................................................. 89 5.3 Creating a DWR Application.......................................................... 90 5.4 Deploying and Running the DWR Application............................ 103 5.5 Summary....................................................................................... 106 6 Ajax without JavaScript – AjaxTags ................................................ 107 6.1 Introduction .................................................................................. 107 6.2 Setting the Environment ............................................................... 107 6.3 Overview of AjaxTags.................................................................. 111 6.4 Installing AjaxTags....................................................................... 113 6.5 Validating a Form with AjaxTags ................................................ 114 6.6 Summary....................................................................................... 128 7 Ajax with JSF-Ajax4jsf ...................................................................... 129 7.1 Introduction .................................................................................. 129 7.2 Overview of Ajax4jsf ................................................................... 129 7.2.1Ajax Filter............................................................................... 130 7.2.2 Ajax Action Components ...................................................... 130 7.2.3 Ajax Containers ..................................................................... 130 7.2.4 JavaScript Engine .................................................................. 130 7.2.5 Ajax4jsf Component Library................................................. 130 7.3 Setting the Environment ............................................................... 132 7.4 Creating an Ajax4jsf Application ................................................. 133 7.5 Sending an Ajax Request.............................................................. 145 7.6 Processing an Ajax Request.......................................................... 148 7.7 Processing the Ajax Response..................................................... 154 7.8 Summary....................................................................................... 158 8 Ajax with PHP-Xajax ......................................................................... 159 8.1 Introduction .................................................................................. 159 8.2 Setting the Environment ............................................................... 160 8.3 Integrating PHP with JDeveloper ................................................. 161 8.4 Creating a Database Table ............................................................ 164 8.5 Sending an Ajax Request............................................................. 167 8.6 Processing an Ajax Request.......................................................... 169 8.7 Processing the Ajax Response..................................................... 172 8.8 Summary....................................................................................... 179 9 RSS Feed with Ajax ............................................................................ 181 9.1 Introduction .................................................................................. 181 9.2 Overview of Google Ajax Feed API ............................................ 182 9.3 Setting the Environment ............................................................... 184 9.4 Receiving a RSS Feed .................................................................. 186 9.5 Receiving Multiple Feeds ............................................................. 191 9.6 Summary....................................................................................... 194 10 Web Search with Ajax...................................................................... 195 10.1 Introduction ................................................................................ 195 10.2 Setting the Environment for Google Search............................... 195 10.3 Overview of Google Ajax Search API ....................................... 197 10.4 Creating a Google Ajax Web Search Application ...................... 199 10.5 Web Search with Yahoo Web Services ..................................... 203 10.6 Creating an Ajax Web Search Application for Yahoo ............... 205 10.7 Sending an Ajax Request with Yahoo Search Web Services .... 210 10.8 Running the Yahoo Ajax Web Search Application ................... 217 10.9 Summary..................................................................................... 219 Index ....................................................................................................... 223
Buku karangan Wiwit Siswoutomo ini berusaha mengungkapkan aspek-aspek pemrograman PHP yang jarang diulas oleh penulis buku pemrograman PHP yang lain. Melihat judulnya yang keren dan berkesan techie sekali, yaitu “PHP Undercover”, rasanya agak janggal kalau buku ini sengaja menyasar tingkat keterampilan yang sangat luas, yaitu dari Tingkat Pemula, Tingkat Menengah dan Tingkat Mahir. Berhasilkah buku ini mencapai targetnya?
Judul Buku: PHP Undercover. Mengungkap Rahasia Pemrograman PHP (+CD) Pengarang: Wiwit Siswoutomo Penerbit: PT Elex Media Komputindo, Jakarta, @2005
Bermula Dari Rasa Janggal
Agak aneh sewaktu saya mencoba membaca buku yang saya beli di Gramedia Semarang 30 Desember 2005 ini. Mengapa saya merasa aneh? Seperti yang sudah saya ungkapkan di pengantar, buku ini menyasar ke semua kelas keterampilan dari 3 kelas yang didefinisikan oleh Gramedia, yaitu Tingkat Pemula, Tingkat Menengah dan Tingkat Mahir. Padahal judulnya seakan tingkat tinggi karena mengusung kata “Undercover” yang berarti “Rahasia” atau bisa juga diartikan “Menyamar”. Tentunya ini sangat disukai oleh para programer PHP tingkat lanjut yang benar-benar membaktikan waktunya untuk memprogram dengan PHP.
Tetapi isinya ternyata tidak salah dengan sasaran segmen Tingkat Pemula, karena Bagian I dari buku ini mengusung teori dasar tentang OOP, strategi mendesain class dan Unified Modeling Language (UML). Mengapa harus membahas teori dasar OOP? Tadinya saya sempat bingung juga. Dari judulnya yang “PHP Undercover” seharusnya bahasan ini dilewatkan saja dan lebih baik langsung membahas ke “Undercover”-nya. Sempat juga merasa janggal selama beberapa saat. Untungnya setelah membaca semuanya baru saya membaca “Kata Pengantar”-nya. Di bagian Kata Pengantar baru saya paham kalau ternyata pembaca digiring untuk memahami “rahasia” pemrograman PHP berbasis obyek (OOP: Object Oriented Programming).
Setelah itu saya baru paham kalau seharusnya (menurut saya) judul buku ini adalah: “PHP Undercover: Menguak Rahasia Pemrograman OOP di PHP”. Setidaknya rangkaian kata “menguak rahasia pemrograman OOP di PHP” ini dituliskan di Kata Pengantar. Dan saya rasa seharusnya memang kata “OOP” ditampilkan di judul buku ini sehingga saya tidak merasa janggal dengan buku ini. Dan lagi sayangnya Kata Pengantar ini kurang dapat mengantarkan pembaca memahami isi dari buku. Bagian ini tidak menjelaskan tujuan dan sasaran dari Bagian I (Dasar-dasar OOP), Bagian II (Implementasi Class) dan Bagian III (Strategi Pengembangan Aplikasi) sehingga kita tidak dapat memahami keterkaitan antar bagian. Saya masih bingung dengan Bagian III yang membahas Strategi Pengembangan Aplikasi dan lebih tepat jika bahasan ini diperuntukkan bagi mahasiswa jurusan TI. Jika memang bahasan ini adalah untuk materi kuliah, seharusnya dia bukan lagi “Undercover”.
Sebagai seorang programmer, membaca buku dengan judul “Undercover” selalu menarik. Untungnya buku ini dapat menarik minat baca saya. Sayangnya porsinya hanya sepertiga saja, yaitu pada Bagian II (Implementasi Class) yang membahas banyak class hasil sumbangan programmer seluruh dunia. Tambah menarik karena class-class ini sangat berguna bagi programmer PHP walau pun sebenarnya class-class ini sudah sangat jamak tersedia di internet, baik source-nya mau pun bahasannya (tutorialnya). Boleh dikata class-class yang dibahas di buku ini adalah class-class wajib bagi seorang programmer PHP. Jadi sebenarnya tidak bisa dikategorikan sebagai “Undercover”. Tetapi karena masih banyak programmer Indonesia yang merasa akses internet masih mahal dan susah, lebih baik buku ini dibeli dan dijadikan panduan yang berguna. Penilaian
Secara garis besar saya senang memiliki buku ini. Walau pun isinya termasuk basi karena class yang dibahas adalah class umum dan sudah sangat terkenal di dunia PHP, tetapi sudah cukup banyak membantu saya untuk tidak terkoneksi internet untuk mencari dan mendapatkan class-class terkenal dan terkemuka ini.
Saya juga menghargai penulisnya yang menyertakan sumber dari mana class tersebut diambil. Seperti kita tahu, source code class terkenal ini sangat dinamis sehingga walau pun semua class dan contoh tersedia di CD bawaan buku ini, banyak pembaca yang lebih nyaman jika mendownload versi yang terbaru untuk mendapatkan fitur dan kehandalan/kestabilan yang lebih baik.
Saya juga mengacungi jempol bagi susunan layout isi buku ini. Terutama bagian listing code-nya. Selain hurufnya pas, penulisan code memenuhi kaidah keindahan penulisan code, seperti digunakannya indentasi dan penempatan buka-tutup section. Tambah asyik lagi karena penulis rajin menyertakan baris komentar di bagian-bagian yang dianggap perlu.
Kesimpulan
Seharusnya buku ini menyasar segmen keterampilan: Tingkat Pemula saja. Kalau mau jujur, Tingkat Menengah dan Tingkat Mahir tidak perlu membeli dan membaca buku ini. Semuanya sudah tersedia di internet. Bukankah programmer PHP pasti harus sering (selalu) berhubungan dengan internet? Bukankah PHP itu berbasis internet? Menyambangi situs www.php.net saja sudah dapat memperoleh semua yang dibahas di buku ini.
Jika memang seharusnya sasarannya adalah Tingkat Pemula, maka judul “Undecover” memang layak ditampilkan. Tetapi jangan tampilkan judul “Undercover” bagi tingkat keterampilan di atasnya.
Catatan bagi penulis, sebaiknya tambahkan “OOP” di judul buku ini sehingga seharusnya judul buku menjadi: “Mengungkap Rahasia Pemrograman OOP di PHP”. Jangan lupa segmen pembaca dibatasi maksimal sampai Tingkat Menengah saja. Mungkin saya salah, tetapi menurut saya seharusnya demikian.
Day 1 Introduction to SQL Day 2 Introduction to the Query: The SELECT Statement Day 3 Expressions, Conditions, and Operators Day 4 Functions: Molding the Data You Retrieve Day 5 Clauses in SQL Day 6 Joining Tables Day 7 Subqueries: The Embedded SELECT Statement
Week 1 in Review Week 2 at a Glance
Day 8 Manipulating Data Day 9 Creating and Maintaining Tables Day 10 Creating Views and Indexes Day 11 Controlling Transactions Day 12 Database Security Day 13 Advanced SQL Topics Day 14 Dynamic Uses of SQL
Week 2 in Review Week 3 at a Glance
Day 15 Streamlining SQL Statements for Improved Performance Day 16 Using Views to Retrieve Useful Information from the Data Dictionary Day 17 Using SQL to Generate SQL Statements Day 18 PL/SQL: An Introduction Day 19 Transact-SQL: An Introduction Day 20 SQL*Plus Day 21 Common SQL Mistakes/Errors and Resolutions Week 3 in Review Appendixes
A Glossary of Common SQL Statements B Source Code Listings for the C++ Program Used on Day 14 C Source Code Listings for the Delphi Program Used on Day 14 D Resources E ASCII Table F Answers to Quizzes and Excercises
Introduction I Planning an Intranet Chapter 1 Intranets and Java
What Is an Intranet? Using Web Services on Your Intranet Why Build an Intranet? Intranets Are Affordable Intranets Save Money Intranets Are Highly Efficient Java in Brief Java: The Early Days Java Gets the Official Stamp of Approval Java in Action Rapid Development with Java Using Java on an Intranet Using a Java Application to Track Employee Files Using a Java Application to Schedule Appointments, Meetings, and Conferences Using a Java Application to Track Who Is in the Office Summary
Chapter 2 Designing Intranet Applications with Java
Intranet Programming with Java Applets versus Applications Conceptualization and Design of Intranet Applications Creating Applets The Benefits and Drawbacks of Applets Browsers for Your Applets Placing Applets in HTML Documents Introduction to HTML The Java Extensions to HTML Creating Applications More Options with Applications Applications Have a Different Structure Applications Have Different Security Considerations Running Applications and Applets Summary Chapter 3 Planning Your Intranet Environment
Building Blocks for Creating a Perfect Intranet Managing Expectations Managing Perceptions Managing Strategies Managing Goals Managing Rules Managing Behavior Determining the Best Organization for Your Intranet Learning from the Past Applying the Past to Your Intranet's Future Creating Content for Your Intranet Intranet Development Tools Implementing TCP/IP Networking Creating Web Services with HTTP Intranet Developer's Resource Tools HTML Development Tools Mapping Your Intranet in Four Easy Steps Step 1: Determining Requirements Step 2: Planning Step 3: Design Step 4: Implementation Summary
II Development Concepts and Environments Chapter 4 Java Development Environments
Introduction Selecting an IDE GUI Development Tools Portability of Code IDE Experience Multiple Language Development The Bottom Line Symantec Café System Requirements Overview Pricing and Additional Information SunSoft Java WorkShop System Requirements Overview Pricing and Additional Information SourceCraft NetCraft System Requirements Overview Pricing and Additional Information Other Offerings Borland C++ 5.0 with Java Enhancements MetroWerks CodeWarrior Java WebIDE Kalimantan Natural Intelligence Roaster Microsoft Visual J++ RogueWave JFactory Cosmo Code Summary
Chapter 5 Intranet Security
Introduction Why Security? What Are the Security Features of an Intranet? It's Your Call Security on Your Web Server Controlling Access Globally and Locally Username/Password Authentication Authentication Based on Network Hostname or Address Combined Authentication Secure/Encrypted Transactions Secure HTTP (S-HTTP) Secure Sockets Layer (SSL) The Common Gateway Interface (CGI) and Intranet Security Your Intranet and the Internet Firewalls Virtual Intranet Summary
Chapter 6 Database Connectivity Options
Introduction Database Overview Database Terminology Database Locations Local and Remote Tiering 1-2-3 Database Access Methods Native Drivers ODBC SQL Databases and Java Access via Web Server Access via Proprietary Server Network Access Direct Access JDBC JDBC Goals JDBC Overview JDBC Vendor Support Summary
III Extending Java for Intranets Chapter 7 A Model Intranet Application
Introduction A Quick Overview of Intranet Applications Configuration File Processing Logging to Disk or Screen Database Connectivity Look and Feel Coding Style Notes Code Layout Parentheses and Code Blocking Using Tabs Versus Spaces Liberal Use of Spaces Multiple Lines Per Statement Comments Code Order Summary
Chapter 8 Utility Classes
Introduction Timers Timer Operations Callbacks Event Timers Why Have Two Timers? Java Extensions Extending Java's Date Class Application Configuration Parameters Summary
Chapter 9 Logging Classes
Introduction The Log The Log Entry The Log Interface The Logging Classes DiskLog ScreenLog A Sample Logging Program Summary
Chapter 10 Database Classes
Introduction JDBC in Depth The DriverManager Class The Driver Class The Connection Class The Statement Class The ResultSet Class A JDBC Sample Program Making JDBC Easy to Use The Connector Interface The SQLFactory Interface The Classes The DBConnector Class OracleSequence Summary
Chapter 11 User Interface Classes
Introduction 3-D Effects The Effects Interface The JifPanel Class JifPanel Design Constructing a JifPanel Smoke and Mirrors Drawing 3-D Borders Tabbing Between Components SQL Generation The JifPanel Descendants The CalendarPanel Class The ImagePanel Class The JifLabel Class The JifTabPanel Class The StatusBar Class The JifDialog Class The MessageBox Class The PickList Class Java TextComponent Extensions Change Detection Summary
Chapter 12 Putting Them All Together
Introduction Java Compilation Basics Java Source Code Files Have You Got the Package? Making Java Packages Introducing the Java Intranet Framework Packaging the JIF Classes Extending the Framework Java Applets Making JIF Easy to Use The JifApplication Interface The Jiflet Class Instance Variables Constructors Methods Wrapping Up Jiflets Programming with Jiflets The Smallest Jiflet The HelloWorld Jiflet Extending Jiflets for Real-World Use DBRecord SimpleDBUI SimpleDBJiflet Summary
IV Applications Developing with JIF Chapter 13 Employee Files
Introduction Application Design Database Design Implementation Building the User Interface Interacting with the User Database Access Reading the Existing Schedule Storing Your Schedule Generating the SQL Programming Considerations Summary
Chapter 16 Online In/Out Board
Introduction Application Design Database Design Implementation User Interface Database Access A Refresh Timer Programming Considerations Summary
Introduction Who Would Use This Application? Johnston, Ulysses, Norman, and Kaiser Application Design Using a Pick List Database Design Implementation User Interface The Product Pick List Database Access Programming Considerations Summary
Chapter 20 Customer Support Maintenance
Introduction Application Design Database Design Implementation Building the User Interface Database Access Retrieving the Product and Problem Lists Product and Problem Selection Changes Programming Considerations Summary