JavaScript « Web Development « Java Articles

Java Articles
1. Build Deploy
2. Class
3. Core Library
4. Data Types
5. Database JDBC
6. Design
7. Development
8. File Input Output
9. Graphics Desktop
10. J2EE Enterprise
11. J2ME Wireless
12. JVM
13. Language
14. Library Product
15. Network
16. Security
17. SOA Web Services
18. Test
19. Web Development
20. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Products
Java by API
Photoshop Tutorial
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Articles » Web Development » JavaScript 
1. Create reusable routines in JavaScript
"When learning a new programming language, one of the first things you should do is create commonly used "plug-and-play" routines. If you're new to JavaScript, you might want to consider starting with a half-dozen or so simple routines that you think might be helpful. Even if you don't end up using them, you'll learn a lot about JavaScript in the process."

2. Understanding and using JavaScript statements
"JavaScript currently supports the following eleven statements. Note that some of these -- such as comment, var, and new -- aren't bona fide statements, but they are often treated as such. They are included in this discussion for the sake of completeness."

3. JavaScript and Netscape Frames
"With JavaScript, this control becomes even more useful. Although the browser cannot re-render a page that has already been brought up, you can send the other frames off to display new URLs or information. You can also access resources such as input fields and other form elements in the other frames. With this you can set events to change information in the other frames easily. We will quickly go over the Netscape FRAME system so that I know that we're on the same track. If you're going to use JavaScript, this new document system will come in very handy."

4. Bending over backward to make JavaScript work on 14 platforms
"BE: A lot of our content people are getting into JavaScript and Frames -- you can see their work at http://proto.netscape.com. I have many customers internal to our product development organization, including new server projects, the LiveWire team, and client folks who are helping to make Navigator more scriptable in future releases."

5. Debugging JavaScript programs
"Debugging a JavaScript program entails using problem-solving techniques that would impress Sherlock Holmes. Effective debugging of JavaScript requires some experience writing programs for it. After a while, you become familiar with the error messages JavaScript displays and learn ways to solve the errors. Of course, you may not have the time to devote yourself to learning all the intricacies of JavaScript. This column is your quick-reference guide to understanding how to effectively debug JavaScript programs, even without a debugging utility."

6. Bruce Johnson on writing JavaScript in a Java IDE
"Google Engineering Manager Bruce Johnson explains the steps involved in writing an Ajax application using your favorite Java IDE and Google Web Toollkit, in this talk with LinuxWorld Editor Don Marti."

7. Take advantage of user-defined variables in JavaScript
"(Note: As with most modern programming languages, JavaScript supports array variables in addition to the basic scalar variables used to hold the above data types. We'll concentrate on single-value variables for this column and devote a separate column to arrays.)"

8. New JavaScript features in Navigator 3.0
"Rather, it's the inside that's different, in ways the casual observer cannot see. One of the major improvements in Netscape 3.0 is JavaScript, the built-in scripting language that provides for interactive and intelligent control over the HTML content of a page. JavaScript is more mature and refined this time around, with many of its "version 1.0" bugs squashed. What's more, JavaScript supports a number of enhancements, including new object constructors, in-place image replacement, and direct communication between it and Java applets and plugins. Though JavaScript is far from being complete, it has taken another step in becoming a world-class user scripting language."

9. Is JavaScript here to stay?
"While the idea behind JavaScript is a noble one, as a Little Engine it's already showing signs of running out of steam. At least temporarily. JavaScript is an integral part of Netscape's much-heralded troika of enabling technologies -- the other two are Java and plugins -- so it's unlikely that JavaScript will derail any time soon. As Netscape is a company often with an extra ace or two up its sleeve, there's no telling what grand future plans they have for JavaScript."

10. JavaScript Column
"Debugging JavaScript programs Everyone makes mistakes writing JavaScript programs. Errors don't know experts from novices, so the next time you get an error message while trying to play a JavaScript program you've written, don't feel bad. JavaScript provides error messages as a means to help you spot mistakes. This column describes the errors you are likely to get when writing a JavaScript program and what to do about them. Gordon Mccomb, July 1996"

11. Expressing yourself in JavaScript
"This explanation may sound complex, but as you will soon see, an expression is really nothing more than a simple formula for addition. This column addresses the use of expressions in JavaScript, both for defining the content of variables, as well as for creating more elaborate schemes using other JavaScript constructs. Used in this way, expressions provide a way for your scripts to think on their own (although they may seem to act on their own more than you'd like them to!)."

12. Cooking with JavaScript & DHTML, Part 3
"Our latest sample recipe from JavaScript & DHTML Cookbook comes from Chapter 5 on "Browser Feature Detection." Learn how to detect object property and method support, thereby ensuring complete support for modern scriptable features. And check back here next week for a sample recipe on importing browser- or operating system-specific style sheets."

13. Cooking with JavaScript & DHTML, Part 5
"Sites Beautiful Code Databases Digital Media Emerging Telephony Inside Aperture Inside Lightroom Inside Port 25 InsideRIA.com LinuxDevCenter.com MacDevCenter.com ONJava.com ONLamp.com Apache BSD MySQL PHP Python Perl.com Ruby SysAdmin What Is? WindowsDevCenter.com XML.com WebServices.XML.com"

14. JavaScript: Windows and Frames
"Sites Beautiful Code Databases Digital Media Emerging Telephony Inside Aperture Inside Lightroom Inside Port 25 InsideRIA.com LinuxDevCenter.com MacDevCenter.com ONJava.com ONLamp.com Apache BSD MySQL PHP Python Perl.com Ruby SysAdmin What Is? WindowsDevCenter.com XML.com WebServices.XML.com"

15. Cooking with JavaScript & DHTML, Part 4
"Editor's note: Short and sweet: that's what our latest sample recipe from JavaScript & DHTML Cookbook is: a quick and simple solution to importing browser- or operating system-specific style sheets. This week's excerpt is from Chapter 11 on "Managing Style Sheets." And next week's recipe will also come from the same chapter--check back here then to learn how to read effective style sheet property values."

16. Cooking with JavaScript & DHTML, Part 2
"Sites Beautiful Code Databases Digital Media Emerging Telephony Inside Aperture Inside Lightroom Inside Port 25 InsideRIA.com LinuxDevCenter.com MacDevCenter.com ONJava.com ONLamp.com Apache BSD MySQL PHP Python Perl.com Ruby SysAdmin What Is? WindowsDevCenter.com XML.com WebServices.XML.com"

17. Cooking with JavaScript & DHTML
"Editor's note: This sample recipe is the first of six we've excerpted from JavaScript & DHTML Cookbook. We'll be running one per week over consecutive weeks so check back to this space often for recipes that cover arrays and objects; browser feature detection; style-sheet management; and HTML elements positioning. Today's recipe is from Chapter 8 on "Dynamic Forms.""

18. Cooking with JavaScript & DHTML, Part 6
"Editor's note: In this sixth and final sample recipe excerpted from JavaScript & DHTML Cookbook, Danny Goodman shows you how to determine the location of a nonpositioned element. And if you've enjoyed sampling the recipes presented thus far, we'll have another tempting morsel for you to sink your teeth into. Danny has written a bonus recipe you won't find in the book. Check back here in two weeks to try it out."

19. Dynamic Database Access from Client-Side JavaScript
"Imagine the advantages of being able to dynamically access a database from client-side JavaScript. You could dynamically query a database from JavaScript for client-side field validation, or dynamically populate a drop-down select list, to name just a few possibilities. In fact, you can do this, with the help of an applet-servlet pair (assuming you can constrain your users to compatible browsers, i.e., IE and Netscape.) This article describes the applet-servlet pair architecture and offers several sample applications."

20. Object Oriented JavaScript Demonstrated
"Before diving into the object-oriented features of JavaScript, let's first take a look at some of the basics. This chapter walks you through:"

21. Linking Javascript Objects with HTML Controls
"TYING JAVASCRIPT OBJECTS TO HTML CONTROLS Now that we know how to define our own JavaScript objects and how JavaScript creates objects for HTML elements, the question is, how do we tie the HTML-derived objects to our custom-made JavaScript objects? The answer is, event handlers. Almost all HTML controls have the ability to receive events from the Web browser and call a JavaScript function in response. All we need to do is plug our objects into the appropriate event handler and the rest will happen automatically. For example, let's take the simple object we created in our last installment ("anObject") and tie it to an HTML button. The code to do this is shown in Listing 2. The part we are interested in here is the "<input>" tag. Notice the "onClick" handler? It's telling the browser that, when the user clicks on this button, it should call the "sayHello" method of the object named "myObj." That's all there is to it! A JAVASCRIPT check box OBJECT Now that we can link JavaScript objects to HTML controls, let's look at a more complex task: using JavaScript to make HTML controls easier to use. For this, let us consider the lowly check box. HTML check boxes are rather simple things, but it can still be a pain to manage a large number of them. By creating a JavaScript check box object, we can use the same code to manage any number of HTML check boxes. The JavaScript code for a check box object is rather simple. The constructor is shown in Listing 3. As expected, this isn't an overly complicated object. It has two instance variables and three methods. THE "form" AND "name" VARIABLES To truly "link" a JavaScript object to an HTML control, you must be able to access that control from your JavaScript code. To do that, you have to know two things about the control: the name of the HTML form it is in and the name of the HTML control itself. The "form" and "name" instance variables allow us to keep track of this information for each control. (We've looked at this concept before.2) Once we have this information, we use it to access our control by using JavaScript's "eval" method. The eval method takes a string representing a valid JavaScript statement and executes it as if it had been hard-coded in your HTML file. So, for example, the statement: eval( "alert( 'Hello World!')"); will display an alert window with the string "Hello World!" in it, just as if you had coded: alert( 'Hello World!') By keeping the name of our form and the name of our control inside our object, we can create statements that, when passed to the eval method, let us access our HTML control. For example, in the code we will look at in a moment, our form is named "oCheckBoxExample," and our first check box control is named "testBox1." Inside the "oCheckBoxIsChecked" method, you will see the line of code:"

22. Tech Giants Woo Developers Seeking JavaScript Turf
"Both products allow developers to use their existing expertise in Java (GWT) or in .NET-supported languages (Volta) to write applications that will run on any device supporting JavaScript."

23. Enhancing HTML controls with JavaScript objects
"We examined a JavaScript object for enhancing HTML check boxes in the April 1999 column. 1 This time, we're going to use these concepts along with some new JavaScript objects to enhance three HTML controls: radio buttons, select lists, and text boxes. THE oRadio OBJECT HTML radio buttons are like check boxes that are kept in herds. Radio buttons are organized into "families," and only one radio button in each family can be on at any given time. The main reason to use a JavaScript object with a radio button family is to simplify the management of multiple radio buttons and/or families. In fact, a single JavaScript radio button object is all you need to manage an entire family of radio buttons no matter how many buttons are in the family. For example, if you have 100 radio buttons organized into two families of 50 buttons each, you would only need two JavaScript objects to manage all 100 buttons!"

24. NetBeans 6.1 Beta Features New JavaScript, Ruby and Spring Support
"The new version of NetBeans features a number of improvements, such as the addition of JavaScript technology features to support AJAX-based Web applications, plus tighter MySQL database integration, the company said. JavaScript improvements include code completion, semantic highlighting and type analysis, among others."

25. JavaScriptingBuilding a JavaScript object browser
"One such tool is a simple JavaScript object browser. The basis of this tool is the JavaScript for/in statement. This statement allows you to execute a set of statements for each and every property of an object. For example, consider the code shown in Listing 1. This simple program will loop through the properties of the built-in navigator object and write the name of each property to the browser window. (If this doesn't seem like a useful thing to do, try loading this page into various Web browsers. You might be very surprised by what you see!)"

26. Mastering Dojo: JavaScript and Ajax Tools for Great Web Experiences
"Dojo is a set of client-side JavaScript tools that help you build better web applications. Dojo blurs the line between local, native applications and browser-based applications; the browser becomes the user interface platform."

27. JavaScript and PHP Support in NetBeans 6.1
"In the past two years, NetBeans has become a multi-lingual IDE, supporting not only Java, C, and C++, but also Ruby and, with the recent release of NetBeans 6.1, PHP and JavaScript as well. Support for working with those languages in the IDE goes far beyond syntax highlighting. The IDE tries to understand as much about the code's structure as it can, and provides intelligent refactorings, code completion, and the ability to work with multiple languages within one source file."

28. Prototype and script.aculo.us: You never knew JavaScript could do this!
"Dive into Prototype, the library that makes JavaScript so much more powerful, and it looks a lot like Ruby code. Exploring the DOM, handling events, taming AJAX, and radically simplifying most of your scripting code: it all becomes easy and very portable with Prototype."

29. Compiling Java to JavaScript
"Have an opinion about the Google Web Toolkit or about Java-to-JavaScript compilation? Discuss this article in the Articles Forum topic, Compiling Java to JavaScript."

30. JavaScript as a Foundation Language for Your Web Apps
"This article explains why JavaScript is perfectly suited as a core, foundation language for your web applications. It introduces the lesser known and yet most powerful JavaScript features, and demonstrates how to leverage them to increase your productivity."

31. Integrate XForms with the Google Web Toolkit, Part 1: Introducing GWT's JavaScript Native Interface
"The Google Web Tookit (GWT) has become a very popular way to develop Ajax applications. It allows Java developers to rapidly create Ajax applications by leveraging their knowledge of Java? technology without requiring any knowledge of JavaScript. XForms represents an evolution in the HTML standard, and allows for simple constructs to create complex, dynamic behavior. Both GWT and XForms are powerful enough to provide complete solutions to many problems. So what about using them together? That's exactly what this series is going to show."

32. The cranky user: Curbing JavaScript dependency
"In summary, JavaScript should always be optional for users. Dependency on it cannot improve a page; it can only cripple it. In particular, be wary of the possibility that your tools will be creating a dependency when you're just looking for an enhancement. Enhancement is harmless and will not generally offend people. Don't tell people they have to use JavaScript to view your page; it's rude, and it won't win you any customers."

33. Finite state machines in JavaScript, Part 2: Implement a widget
"Part 1 asserted that JavaScript is well-suited as an execution environment for finite state machines, and mentioned some of its capabilities that were relevant to the design phase. In this article, you will work through the details of translating your design into JavaScript, taking advantage of some elegant language features, and accommodating some inelegant details that make the implementation tricky."

34. Mastering Ajax, Part 2: Make asynchronous requests with JavaScript and Ajax
"To make all this flash and wonder actually happen, you need to become intimately familiar with a JavaScript object called XMLHttpRequest. This little object -- which has actually been around in several browsers for quite a while -- is the key to Web 2.0, Ajax, and pretty much everything else you learn about in this column for the next several months. To give you a really quick overview, these are just a few of the methods and properties you'll use on this object:"

35. Use functional programming techniques to write elegant JavaScript
"Functional programming languages have been in academia for quite some time, but historically they do not have extensive tools and libraries available. With the advent of Haskell in the .NET platform, functional programming is becoming more popular. Some traditional programming languages, such as C++ and JavaScript, import constructs and features from functional programming. In many cases, repetitive code in JavaScript leads to clumsy coding. You can avoid all that if you use functional programming. Also, you can write more elegantl callbacks with a functional programming style."

36. Ajax and Java development made simpler, Part 1: Generate JavaScript code dynamically with JSP tag files
"This first article in the four-part series presents a JSP-based technique for generating JavaScript code, significantly reducing the amount of code you have to write manually. The sample application shows how to generate JavaScript functions for sending Ajax requests and processing Ajax responses. You can use the simple techniques discussed here in a real application if you want to be able to change the Ajax code easily. The broader goal of this article is to demonstrate how to use JSP tag files to produce JavaScript code for any purpose, not just Ajax routines."

37. JavaScript and the Document Object Model
"Note:This article uses a DOM-compatible browser such as Netscape 6.x, Internet Explorer 6, or Mozilla 1.0. Familiarity with the Document Object Model in Java technology or other languages, is helpful, but not required. You should, however, be familiar with JavaScript in general."

38. JavaScript EE, Part 1: Run JavaScript files on the server side
"In this first article of the series, you will use a simple script runner that lets you execute JavaScript files within a Java EE application. Scripts will have access to the so-called "implicit objects" that are used in JSP pages, such as application, session, request, and response. Most of the samples consist of reusable code so that you can easily start using JavaScript on the server in your own applications."

39. Finite state machines in JavaScript, Part 3: Test the widget
"In this final article you'll test the implementation in some popular browsers. You need to construct a simple test page that creates some FadingTooltip widgets and binds them to HTML elements. For comparison, your test page will also illustrate some built-in tooltips. Immediately you will encounter some should-not-occur conditions, and so will have the opportunity to see how gracefully the design adapts. This article concludes with some observations about performance, and ideas for further development of finite state machines for browser-based applications."

40. Finite state machines in JavaScript, Part 1: Design a widget
"Finite state machines have long been used as an organizing principle for designing and implementing complex behavior in event-driven programs, such as network adapters and compilers. Now, programmable Web browsers have opened a new event-driven environment to a new generation of applications. Browser-based applications, popularized by Ajax, are becoming more complex. Designers and implementers can benefit from the discipline and structure that finite state machines offer. In this article, you, learn how to use a finite state machine to design complex behavior for a simple Web widget -- an animated tooltip that fades into and out of view."

41. Craft Ajax applications using JSF with CSS and JavaScript, Part 1: Enhance the appearance of your JSF pages
"If a Web page has unique styles, you can define style rules within the <style> element of the page's header. You can also specify the style information for a single JSF component using the style attribute. In most cases, however, you will probably prefer including the style rules in separate CSS files so you can apply them on multiple pages. You can link an external style sheet to a Web page using the <link> tag as shown in Listing 1:"

42. Crossing borders: JavaScript's language features
"You probably recognize the dynamic typing model, functional programming in the form of higher-order functions, and an open object model as ideas I've presented in other Crossing borders articles. If you've not done any serious JavaScript development, you're likely thinking that these features belong in serious languages such as Python, Lisp, Smalltalk, and Haskell instead of "toy" languages like JavaScript. So I'll back these concepts up with real code examples."

43. Craft Ajax applications using JSF with CSS and JavaScript, Part 2: Dynamic JSF forms
"Andrei Cioroianu is the founder of Devsphere, a provider of Java EE development and Ajax/JSF consulting services. He's been using Java and Web technologies since 1997 and has 10 years of professional experience in solving complex technical problems and managing the full life cycle of commercial products, custom applications, and open source frameworks. You can reach Andrei through the contact form at devsphere.com."

44. Stick to the ECMAscript
"ECMAscript (better known to most people as JavaScript) has a particularly interesting history in that it started out as an anti-standard. That is, ECMAScript is essentially the same language as both JavaScript and JScript languages, the competing languages used respectively by Netscape and Microsoft."

45. Using Javascript Components in Java Studio Creator
"This article demonstrates an approach to including and using JavaScript components within Creator. Although not as easy as dragging and dropping JSF components onto a page, it does open up the possibility of using a large number of existing JavaScript components that are available now. The examples here are just the beginning. By using the approach outlined in this article, you should be able to harness any JavaScript libraries and components you want to use under Creator. In future articles, I may investigate constructing custom JSF controls that harness some of these third-party JavaScript libraries."

46. Implementing "Real" Classes in JavaScript
"With the presented compact implementation. JavaScript developers can take advantage of most of the features of Java classes, thus enabling the use of robust design patterns needed for AJAX and RIA applications. Use of this technique does not preclude mixing in other techniques or legacy code thus allowing the technique to be added to existing code."

47. Implementing Dynamic Scroll with Ajax, JavaScript, and XML
"For the front end to properly parse the response and dynamically append a row to the table, the back end should return XML similar to this code snippet:"

48. Java vs. JavaScript: So... what is the difference between Java and JavaScript anyway?
"Now let's talk about how Java and JavaScript differ. The main difference is that Java can stand on its own while JavaScript must be placed inside an HTML document to function. Java is a much larger and more complicated language that creates "standalone" applications. A Java "applet" (so-called because it is a little application) is a fully contained program. JavaScript is text that is fed into a browser that can read it and then is enacted by the browser."

49. Moving data to the browser using Java and JavaScript Part 1: From database to Web server
"Fortunately, the principles of object-oriented programming can solve this problem, because each object tells each of the other objects it communicates with how it wants to deal with data. In this article, I will outline a simple way to transfer data from Result Sets to Vectors, so that the Vectors can be distributed to a Web server. The Web server, in turn, can access the values in the Vector using Server-Side JavaScript."

50. User Code: Java Applet and JavaScript Communications
"The communications is reached by overwriting the toString() and showStatus() methods from the Applet class. These methods can be called by JavaScript's applet objects. This may be not very elegant, but it works."

51. Moving data to the browser using Java and JavaScript Part 2: On the browser
"In Part 1, I showed you a simple way to move data from back-end databases to Web servers using Server-Side LiveConnect, which is Netscape's name for its Java to JavaScript protocol. In this article, I will cover Client-Side LiveConnect, which allows the Java in an applet and the JavaScript on a Web page to communicate. And, yes, it works in both Communicator and Internet Explorer."

52. Accomplishing, in Java, the JavaScript "document.write()" function
"JavaScript programmers know that the most powerful command in that interpreted language is "document.write()". This command accepts a String as its input parameter and writes the String to the browser as if it came from a static HTML page. That simple concept allows JavaScript authors to dynamically create HTML Web pages. Unfortunately, Java does not contain a similar class or method. This article will explain a way around this deficiency."

w__w_w___._j___ava__2__s_.__c___o_m___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.